Skip to content
This repository has been archived by the owner on Aug 29, 2023. It is now read-only.

Commit

Permalink
fix(oidc): correctly authorize OIDC swagger UI
Browse files Browse the repository at this point in the history
  • Loading branch information
Christoph Bühler committed Jan 27, 2023
1 parent a2cbcf6 commit 881468c
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 10 deletions.
10 changes: 10 additions & 0 deletions infrastructure/prod/cloud-run.tf
Original file line number Diff line number Diff line change
Expand Up @@ -96,6 +96,16 @@ resource "google_cloud_run_service" "api" {
value = "https://${local.zitadel_issuer}"
}

env {
name = "AUTH_CLIENT_ID"
value = "181236603920908545@cas_fee_adv_qwacker_prod"
}

env {
name = "AUTH_REDIRECT_URI"
value = "https://qwacker-api-http-prod-4cxdci3drq-oa.a.run.app/rest/oauth2-redirect.html"
}

env {
name = "AUTH_JWT_KEY"
value_from {
Expand Down
22 changes: 12 additions & 10 deletions src/main.ts
Original file line number Diff line number Diff line change
Expand Up @@ -50,28 +50,30 @@ async function bootstrap() {
'Users',
'User related calls. Fetch information about users in the system.',
)
.addBearerAuth(
.addOAuth2(
{
type: 'openIdConnect',
description: 'ZITADEL Authentication',
name: 'ZITADEL',
in: 'header',
openIdConnectUrl:
'https://cas-fee-advanced-ocvdad.zitadel.cloud/.well-known/openid-configuration',
flows: {
authorizationCode: {
scopes: {
openid: 'openid',
profile: 'profile',
},
},
},
},
'ZITADEL',
)
.build();
const document = SwaggerModule.createDocument(app, swagger);
SwaggerModule.setup('rest', app, document);
SwaggerModule.setup('rest', app, document, {
swaggerOptions: {
persistAuthorization: true,
oauth2RedirectUrl: process.env.AUTH_REDIRECT_URI,
initOAuth: {
clientId: process.env.AUTH_CLIENT_ID,
scopes: 'openid profile email',
usePkceWithAuthorizationCodeGrant: true,
},
},
});

await app.startAllMicroservices();
log(
Expand Down

0 comments on commit 881468c

Please sign in to comment.