Skip to content

Commit 2ed0396

Browse files
GHkrishnatipusinghaw
authored andcommitted
feat: optionally enable OIDC modules (#1516)
* feat: add optionally enable disable oidc module Signed-off-by: Krishna Waske <[email protected]> * chore: add some descriptive logs Signed-off-by: Krishna Waske <[email protected]> * fix: update the registration of experimental modules Signed-off-by: Krishna Waske <[email protected]> * fix: common function from utils Signed-off-by: Krishna Waske <[email protected]> --------- Signed-off-by: Krishna Waske <[email protected]>
1 parent 94e6bbb commit 2ed0396

File tree

7 files changed

+24
-5
lines changed

7 files changed

+24
-5
lines changed

.env.demo

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -144,6 +144,8 @@ ELK_PASSWORD=xxxxxx # ELK user password
144144
ORGANIZATION=credebl
145145
CONTEXT=platform
146146
APP=api
147+
# Default is true too, if nothing is passed
148+
HIDE_EXPERIMENTAL_OIDC_CONTROLLERS=true
147149

148150
#Schema-file-server
149151
APP_PORT=4000

.env.sample

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,8 @@ POSTGRES_PORT=5432
6767
POSTGRES_USER='postgres'
6868
POSTGRES_PASSWORD='xxxxx'
6969
POSTGRES_DATABASE= // Please provide your DB name
70-
70+
# Default is true too, set to 'false', to view OIDC controllers in openAPI docs
71+
HIDE_EXPERIMENTAL_OIDC_CONTROLLERS=true
7172
SENDGRID_API_KEY=xxxxxxxxxxxxxx // Please provide your sendgrid API key
7273

7374
FRONT_END_URL=http://localhost:3000

apps/api-gateway/src/app.module.ts

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ import { AppService } from './app.service';
66
import { AuthzMiddleware } from './authz/authz.middleware';
77
import { AuthzModule } from './authz/authz.module';
88
import { ClientsModule, Transport } from '@nestjs/microservices';
9-
import { ConfigModule } from '@nestjs/config';
9+
import { ConditionalModule, ConfigModule } from '@nestjs/config';
1010
import { CredentialDefinitionModule } from './credential-definition/credential-definition.module';
1111
import { FidoModule } from './fido/fido.module';
1212
import { IssuanceModule } from './issuance/issuance.module';
@@ -33,6 +33,7 @@ import { ConfigModule as PlatformConfig } from '@credebl/config/config.module';
3333
import { Oid4vcIssuanceModule } from './oid4vc-issuance/oid4vc-issuance.module';
3434
import { X509Module } from './x509/x509.module';
3535
import { Oid4vpModule } from './oid4vc-verification/oid4vc-verification.module';
36+
import { shouldLoadOidcModules } from '@credebl/common/common.utils';
3637

3738
@Module({
3839
imports: [
@@ -66,9 +67,9 @@ import { Oid4vpModule } from './oid4vc-verification/oid4vc-verification.module';
6667
CacheModule.register(),
6768
GeoLocationModule,
6869
CloudWalletModule,
69-
Oid4vcIssuanceModule,
70-
Oid4vpModule,
71-
X509Module
70+
ConditionalModule.registerWhen(Oid4vcIssuanceModule, shouldLoadOidcModules),
71+
ConditionalModule.registerWhen(Oid4vpModule, shouldLoadOidcModules),
72+
ConditionalModule.registerWhen(X509Module, shouldLoadOidcModules)
7273
],
7374
controllers: [AppController],
7475
providers: [

apps/api-gateway/src/main.ts

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -118,5 +118,12 @@ async function bootstrap(): Promise<void> {
118118
);
119119
await app.listen(process.env.API_GATEWAY_PORT, `${process.env.API_GATEWAY_HOST}`);
120120
Logger.log(`API Gateway is listening on port ${process.env.API_GATEWAY_PORT}`);
121+
122+
if ('true' === (process.env.HIDE_EXPERIMENTAL_OIDC_CONTROLLERS || 'true').trim().toLowerCase()) {
123+
Logger.warn('Hiding experimental OIDC Controllers: OID4VC, OID4VP, x509 in OpenAPI docs');
124+
Logger.verbose(
125+
"To enable the use of experimental OIDC controllers. Set, 'HIDE_EXPERIMENTAL_OIDC_CONTROLLERS' env variable to false"
126+
);
127+
}
121128
}
122129
bootstrap();

apps/api-gateway/src/oid4vc-issuance/oid4vc-issuance.controller.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -54,6 +54,7 @@ import {
5454
GetAllCredentialOfferDto,
5555
UpdateCredentialRequestDto
5656
} from './dtos/issuer-sessions.dto';
57+
5758
@Controller()
5859
@UseFilters(CustomExceptionFilter)
5960
@ApiTags('OID4VC')

apps/api-gateway/src/oid4vc-verification/oid4vc-verification.controller.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,7 @@ import { Oid4vcVerificationService } from './oid4vc-verification.service';
4848
import { CreateVerifierDto, UpdateVerifierDto } from './dtos/oid4vc-verifier.dto';
4949
import { PresentationRequestDto, VerificationPresentationQueryDto } from './dtos/oid4vc-verifier-presentation.dto';
5050
import { Oid4vpPresentationWhDto } from '../oid4vc-issuance/dtos/oid4vp-presentation-wh.dto';
51+
5152
@Controller()
5253
@UseFilters(CustomExceptionFilter)
5354
@ApiTags('OID4VP')

libs/common/src/common.utils.ts

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -138,3 +138,9 @@ export const getAgentUrl = (agentEndPoint: string, urlFlag: string, paramId?: st
138138
const url = `${agentEndPoint}${resolvedUrlPath}`;
139139
return url;
140140
};
141+
142+
export function shouldLoadOidcModules(): boolean {
143+
const raw = process.env.HIDE_EXPERIMENTAL_OIDC_CONTROLLERS ?? 'true';
144+
const hide = 'true' === raw.toLowerCase();
145+
return !hide;
146+
}

0 commit comments

Comments
 (0)