well-known controller
This commit is contained in:
parent
64a675f36e
commit
b62208ba47
@ -1,47 +1,10 @@
|
|||||||
import { Controller, Get, Redirect } from '@nestjs/common';
|
import { Controller, Get, Redirect } from '@nestjs/common';
|
||||||
import { ConfigurationService } from './modules/config/config.service';
|
|
||||||
|
|
||||||
@Controller()
|
@Controller()
|
||||||
export class AppController {
|
export class AppController {
|
||||||
constructor(private config: ConfigurationService) {}
|
|
||||||
|
|
||||||
@Get()
|
@Get()
|
||||||
@Redirect('/account/general')
|
@Redirect('/account/general')
|
||||||
getHello() {
|
getHello() {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Get('/.well-known/openid-configuration')
|
|
||||||
openidConfiguration() {
|
|
||||||
const base = this.config.get<string>('app.base_url');
|
|
||||||
return {
|
|
||||||
issuer: this.config.get('jwt.issuer'),
|
|
||||||
authorization_endpoint: `${base}/oauth2/authorize`,
|
|
||||||
token_endpoint: `${base}/oauth2/token`,
|
|
||||||
jwks_uri: `${base}/oauth2/jwks`,
|
|
||||||
userinfo_endpoint: `${base}/api/user`,
|
|
||||||
introspection_endpoint: `${base}/oauth2/introspect`,
|
|
||||||
response_types_supported: ['code', 'id_token'],
|
|
||||||
id_token_signing_alg_values_supported: [this.config.get('jwt.algorithm')],
|
|
||||||
subject_types_supported: ['public'],
|
|
||||||
scopes_supported: ['openid', 'profile', 'picture', 'email'],
|
|
||||||
claims_supported: [
|
|
||||||
'aud',
|
|
||||||
'exp',
|
|
||||||
'iat',
|
|
||||||
'iss',
|
|
||||||
'sub',
|
|
||||||
'name',
|
|
||||||
'preferred_username',
|
|
||||||
'nickname',
|
|
||||||
'profile',
|
|
||||||
'picture',
|
|
||||||
'updated_at',
|
|
||||||
'email',
|
|
||||||
'email_verified',
|
|
||||||
],
|
|
||||||
code_challenge_methods_supported: ['plain', 'S256'],
|
|
||||||
grant_types_supported: ['authorization_code', 'refresh_token'],
|
|
||||||
};
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
@ -11,6 +11,7 @@ import { ConfigurationModule } from './modules/config/config.module';
|
|||||||
import { JWTModule } from './modules/jwt/jwt.module';
|
import { JWTModule } from './modules/jwt/jwt.module';
|
||||||
import { SSRFrontEndModule } from './modules/ssr-front-end/ssr-front-end.module';
|
import { SSRFrontEndModule } from './modules/ssr-front-end/ssr-front-end.module';
|
||||||
import { UtilityModule } from './modules/utility/utility.module';
|
import { UtilityModule } from './modules/utility/utility.module';
|
||||||
|
import { WellKnownModule } from './modules/well-known/well-known.module';
|
||||||
|
|
||||||
@Module({
|
@Module({
|
||||||
imports: [
|
imports: [
|
||||||
@ -26,6 +27,7 @@ import { UtilityModule } from './modules/utility/utility.module';
|
|||||||
UtilityModule,
|
UtilityModule,
|
||||||
JWTModule,
|
JWTModule,
|
||||||
SSRFrontEndModule,
|
SSRFrontEndModule,
|
||||||
|
WellKnownModule,
|
||||||
ApiModule,
|
ApiModule,
|
||||||
],
|
],
|
||||||
controllers: [AppController],
|
controllers: [AppController],
|
||||||
|
64
src/modules/well-known/well-known.controller.ts
Normal file
64
src/modules/well-known/well-known.controller.ts
Normal file
@ -0,0 +1,64 @@
|
|||||||
|
import { Controller, Get, Redirect, Res } from '@nestjs/common';
|
||||||
|
import { Response } from 'express';
|
||||||
|
import { ConfigurationService } from '../config/config.service';
|
||||||
|
|
||||||
|
@Controller({
|
||||||
|
path: '/.well-known/',
|
||||||
|
})
|
||||||
|
export class WellKnownController {
|
||||||
|
constructor(private config: ConfigurationService) {}
|
||||||
|
|
||||||
|
@Get('security.txt')
|
||||||
|
securityTXT(@Res({ passthrough: true }) res: Response) {
|
||||||
|
res.set('content-type', 'text/plain');
|
||||||
|
return `# If you would like to report a security issue
|
||||||
|
# you may report it to:
|
||||||
|
Contact: mailto:evert@lunasqu.ee
|
||||||
|
`;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Get('dnt')
|
||||||
|
DNT() {
|
||||||
|
return { tracking: 'N' };
|
||||||
|
}
|
||||||
|
|
||||||
|
@Get('change-password')
|
||||||
|
@Redirect('/account/security')
|
||||||
|
changePassword() {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Get('openid-configuration')
|
||||||
|
openidConfiguration() {
|
||||||
|
const base = this.config.get<string>('app.base_url');
|
||||||
|
return {
|
||||||
|
issuer: this.config.get('jwt.issuer'),
|
||||||
|
authorization_endpoint: `${base}/oauth2/authorize`,
|
||||||
|
token_endpoint: `${base}/oauth2/token`,
|
||||||
|
jwks_uri: `${base}/oauth2/jwks`,
|
||||||
|
userinfo_endpoint: `${base}/api/user`,
|
||||||
|
introspection_endpoint: `${base}/oauth2/introspect`,
|
||||||
|
response_types_supported: ['code', 'id_token'],
|
||||||
|
id_token_signing_alg_values_supported: [this.config.get('jwt.algorithm')],
|
||||||
|
subject_types_supported: ['public'],
|
||||||
|
scopes_supported: ['openid', 'profile', 'picture', 'email'],
|
||||||
|
claims_supported: [
|
||||||
|
'aud',
|
||||||
|
'exp',
|
||||||
|
'iat',
|
||||||
|
'iss',
|
||||||
|
'sub',
|
||||||
|
'name',
|
||||||
|
'preferred_username',
|
||||||
|
'nickname',
|
||||||
|
'profile',
|
||||||
|
'picture',
|
||||||
|
'updated_at',
|
||||||
|
'email',
|
||||||
|
'email_verified',
|
||||||
|
],
|
||||||
|
code_challenge_methods_supported: ['plain', 'S256'],
|
||||||
|
grant_types_supported: ['authorization_code', 'refresh_token'],
|
||||||
|
};
|
||||||
|
}
|
||||||
|
}
|
10
src/modules/well-known/well-known.module.ts
Normal file
10
src/modules/well-known/well-known.module.ts
Normal file
@ -0,0 +1,10 @@
|
|||||||
|
import { Module } from '@nestjs/common';
|
||||||
|
import { ConfigurationModule } from '../config/config.module';
|
||||||
|
import { JWTModule } from '../jwt/jwt.module';
|
||||||
|
import { WellKnownController } from './well-known.controller';
|
||||||
|
|
||||||
|
@Module({
|
||||||
|
imports: [ConfigurationModule, JWTModule],
|
||||||
|
controllers: [WellKnownController],
|
||||||
|
})
|
||||||
|
export class WellKnownModule {}
|
Reference in New Issue
Block a user