Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

🎨 Added check for the oauth enabled or not #38

Merged
merged 1 commit into from
Dec 19, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 7 additions & 3 deletions gql-queries-generator/doc/queries.graphql
Original file line number Diff line number Diff line change
Expand Up @@ -442,7 +442,6 @@ query consoleGetCluster($name: String!) {
syncScheduledAt
}
updateTime
clusterToken
}
}

Expand Down Expand Up @@ -2491,7 +2490,6 @@ query consoleGetPvc($clusterName: String!, $name: String!) {
status {
accessModes
allocatedResources
allocatedResourceStatuses
capacity
conditions {
lastProbeTime
Expand Down Expand Up @@ -2559,7 +2557,6 @@ query consoleListPvcs($clusterName: String!, $search: SearchPersistentVolumeClai
status {
accessModes
allocatedResources
allocatedResourceStatuses
capacity
conditions {
lastProbeTime
Expand Down Expand Up @@ -2706,6 +2703,13 @@ query consoleGetBuildRun($repoName: String!, $buildRunName: String!) {
}
}

query authCheckOauthEnabled {
auth_listOAuthProviders {
enabled
provider
}
}

mutation authAddOauthCredientials($provider: String!, $state: String!, $code: String!) {
oAuth_addLogin(provider: $provider, state: $state, code: $code)
}
Expand Down
16 changes: 16 additions & 0 deletions src/apps/auth/routes/_auth._providers.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,22 @@ const Provider = () => {
};

export const restActions = async (ctx: IRemixCtx) => {
const { data: checkData, errors: checkError } = await GQLServerHandler(
ctx.request
).checkOauthEnabled({});

if (checkError) {
logger.error(checkError);
}

if (checkData.find((v) => !v.enabled)) {
return {
githubLoginUrl: '',
gitlabLoginUrl: '',
googleLoginUrl: '',
};
}

const { data, errors } = await GQLServerHandler(
ctx.request
).loginPageInitUrls();
Expand Down
18 changes: 18 additions & 0 deletions src/apps/auth/server/gql/saved-queries.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,11 +21,29 @@ import {
AuthVerifyEmailMutationVariables,
AuthWhoAmIQuery,
AuthWhoAmIQueryVariables,
AuthCheckOauthEnabledQuery,
AuthCheckOauthEnabledQueryVariables,
} from '~/root/src/generated/gql/server';

export const GQLServerHandler = ({ headers, cookies }: IGQLServerProps) => {
const executor = ExecuteQueryWithContext(headers, cookies);
return {
checkOauthEnabled: executor(
gql`
query Auth_listOAuthProviders {
auth_listOAuthProviders {
enabled
provider
}
}
`,
{
transformer(data: AuthCheckOauthEnabledQuery) {
return data.auth_listOAuthProviders;
},
vars(_: AuthCheckOauthEnabledQueryVariables) {},
}
),
addOauthCredientials: executor(
gql`
mutation Mutation($provider: String!, $state: String!, $code: String!) {
Expand Down
1 change: 1 addition & 0 deletions src/apps/console/page-components/new-cluster.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -132,6 +132,7 @@ export const NewCluster = ({ providerSecrets, cloudProvider }: props) => {
aws: {
region: selectedRegion.Name,
k3sMasters: {
nvidiaGpuEnabled: true,
instanceType: 'c6a.xlarge',
},
},
Expand Down
1 change: 0 additions & 1 deletion src/apps/console/server/gql/queries/cluster-queries.ts
Original file line number Diff line number Diff line change
Expand Up @@ -278,7 +278,6 @@ export const clusterQueries = (executor: IExecutor) => ({
syncScheduledAt
}
updateTime
clusterToken
}
}
`,
Expand Down
2 changes: 0 additions & 2 deletions src/apps/console/server/gql/queries/pvc-queries.ts
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,6 @@ export const pvcQueries = (executor: IExecutor) => ({
status {
accessModes
allocatedResources
allocatedResourceStatuses
capacity
conditions {
lastProbeTime
Expand Down Expand Up @@ -143,7 +142,6 @@ export const pvcQueries = (executor: IExecutor) => ({
status {
accessModes
allocatedResources
allocatedResourceStatuses
capacity
conditions {
lastProbeTime
Expand Down
2 changes: 1 addition & 1 deletion src/generated/codegen-sdl.yml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
overwrite: true
schema: "http://gateway-api.kl-core.svc.cluster.local"
schema: "http://gateway.karthik-testing.svc.cluster.local"
generates:
gql/sdl.graphql:
plugins:
Expand Down
2 changes: 1 addition & 1 deletion src/generated/codegen.yml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
overwrite: true
schema: "http://gateway-api.kl-core.svc.cluster.local"
schema: "http://gateway.karthik-testing.svc.cluster.local"
generates:
gql/server.ts:
documents:
Expand Down
10 changes: 4 additions & 6 deletions src/generated/gql/sdl.graphql
Original file line number Diff line number Diff line change
Expand Up @@ -187,7 +187,6 @@ type BuildRunPaginatedRecords {
type BYOCCluster {
accountName: String!
apiVersion: String!
clusterToken: String!
createdBy: Kloudlite__io___common__CreatedOrUpdatedBy!
creationTime: Date!
displayName: String!
Expand Down Expand Up @@ -271,7 +270,6 @@ type Cluster {
accountName: String!
adminKubeconfig: EncodedValue
apiVersion: String!
clusterToken: String!
createdBy: Kloudlite__io___common__CreatedOrUpdatedBy!
creationTime: Date!
displayName: String!
Expand All @@ -281,7 +279,7 @@ type Cluster {
markedForDeletion: Boolean
metadata: Metadata!
recordVersion: Int!
spec: Github__com___kloudlite___operator___apis___clusters___v1__ClusterSpec
spec: Github__com___kloudlite___operator___apis___clusters___v1__ClusterSpec!
status: Github__com___kloudlite___operator___pkg___operator__Status
syncStatus: Kloudlite__io___pkg___types__SyncStatus!
updateTime: Date!
Expand Down Expand Up @@ -541,6 +539,7 @@ type Github__com___kloudlite___operator___apis___clusters___v1__AWSK3sMastersCon

input Github__com___kloudlite___operator___apis___clusters___v1__AWSK3sMastersConfigIn {
instanceType: String!
nvidiaGpuEnabled: Boolean!
}

type Github__com___kloudlite___operator___apis___clusters___v1__AWSNodePoolConfig {
Expand Down Expand Up @@ -1467,19 +1466,19 @@ input K8s__io___api___core___v1__PersistentVolumeClaimSpecIn {
type K8s__io___api___core___v1__PersistentVolumeClaimStatus {
accessModes: [String!]
allocatedResources: Map
allocatedResourceStatuses: Map
capacity: Map
conditions: [K8s__io___api___core___v1__PersistentVolumeClaimCondition!]
phase: K8s__io___api___core___v1__PersistentVolumeClaimPhase
resizeStatus: String
}

input K8s__io___api___core___v1__PersistentVolumeClaimStatusIn {
accessModes: [String!]
allocatedResources: Map
allocatedResourceStatuses: Map
capacity: Map
conditions: [K8s__io___api___core___v1__PersistentVolumeClaimConditionIn!]
phase: K8s__io___api___core___v1__PersistentVolumeClaimPhase
resizeStatus: String
}

type K8s__io___api___core___v1__ResourceClaim {
Expand Down Expand Up @@ -2008,7 +2007,6 @@ type Mutation {
cr_triggerBuild(id: ID!): Boolean!
cr_updateBuild(build: BuildIn!, id: ID!): Build
cr_updateBuildCacheKey(buildCacheKey: BuildCacheKeyIn!, id: ID!): BuildCacheKey
generateClusterToken(accountName: String!, clusterName: String!): String!
infra_createBYOCCluster(byocCluster: BYOCClusterIn!): BYOCCluster
infra_createCluster(cluster: ClusterIn!): Cluster
infra_createDomainEntry(domainEntry: DomainEntryIn!): DomainEntry
Expand Down
18 changes: 12 additions & 6 deletions src/generated/gql/server.ts
Original file line number Diff line number Diff line change
Expand Up @@ -713,6 +713,7 @@ export type Github__Com___Kloudlite___Operator___Apis___Clusters___V1__AwsCluste
export type Github__Com___Kloudlite___Operator___Apis___Clusters___V1__Awsk3sMastersConfigIn =
{
instanceType: Scalars['String']['input'];
nvidiaGpuEnabled: Scalars['Boolean']['input'];
};

export type Github__Com___Kloudlite___Operator___Apis___Common____Types__SecretRefIn =
Expand Down Expand Up @@ -929,12 +930,12 @@ export type K8s__Io___Apimachinery___Pkg___Apis___Meta___V1__LabelSelectorRequir
export type K8s__Io___Api___Core___V1__PersistentVolumeClaimStatusIn = {
accessModes?: InputMaybe<Array<Scalars['String']['input']>>;
allocatedResources?: InputMaybe<Scalars['Map']['input']>;
allocatedResourceStatuses?: InputMaybe<Scalars['Map']['input']>;
capacity?: InputMaybe<Scalars['Map']['input']>;
conditions?: InputMaybe<
Array<K8s__Io___Api___Core___V1__PersistentVolumeClaimConditionIn>
>;
phase?: InputMaybe<K8s__Io___Api___Core___V1__PersistentVolumeClaimPhase>;
resizeStatus?: InputMaybe<Scalars['String']['input']>;
};

export type K8s__Io___Apimachinery___Pkg___Api___Resource__Format =
Expand Down Expand Up @@ -1280,7 +1281,7 @@ export type ConsoleListClustersQuery = {
}>;
message?: { RawMessage?: any };
};
spec?: {
spec: {
messageQueueTopicName: string;
kloudliteRelease: string;
accountId: string;
Expand Down Expand Up @@ -1334,7 +1335,6 @@ export type ConsoleGetClusterQuery = {
markedForDeletion?: boolean;
recordVersion: number;
updateTime: any;
clusterToken: string;
createdBy: { userEmail: string; userId: string; userName: string };
lastUpdatedBy: { userEmail: string; userId: string; userName: string };
metadata: {
Expand All @@ -1346,7 +1346,7 @@ export type ConsoleGetClusterQuery = {
name: string;
namespace?: string;
};
spec?: {
spec: {
accountId: string;
accountName: string;
availabilityMode: Github__Com___Kloudlite___Operator___Apis___Clusters___V1__ClusterSpecAvailabilityMode;
Expand Down Expand Up @@ -3387,7 +3387,6 @@ export type ConsoleGetPvcQuery = {
status?: {
accessModes?: Array<string>;
allocatedResources?: any;
allocatedResourceStatuses?: any;
capacity?: any;
phase?: K8s__Io___Api___Core___V1__PersistentVolumeClaimPhase;
conditions?: Array<{
Expand Down Expand Up @@ -3456,7 +3455,6 @@ export type ConsoleListPvcsQuery = {
status?: {
accessModes?: Array<string>;
allocatedResources?: any;
allocatedResourceStatuses?: any;
capacity?: any;
phase?: K8s__Io___Api___Core___V1__PersistentVolumeClaimPhase;
conditions?: Array<{
Expand Down Expand Up @@ -3592,6 +3590,14 @@ export type ConsoleGetBuildRunQuery = {
};
};

export type AuthCheckOauthEnabledQueryVariables = Exact<{
[key: string]: never;
}>;

export type AuthCheckOauthEnabledQuery = {
auth_listOAuthProviders?: Array<{ enabled: boolean; provider: string }>;
};

export type AuthAddOauthCredientialsMutationVariables = Exact<{
provider: Scalars['String']['input'];
state: Scalars['String']['input'];
Expand Down
Loading