generated from amosproj/amos202Xss0Y-projname
-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'main' into 56-decode-token-even-if-it-is-expired
Signed-off-by: prebbe <philip.rebbe@fau.de>
- Loading branch information
Showing
33 changed files
with
623 additions
and
289 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,5 @@ | ||
CLIENT_CREDENTIALS_STRING=client_credentials | ||
CLIENT_ID= | ||
CLIENT_SECRET= | ||
AUDIENCE= | ||
AUDIENCE=oidc-app | ||
ISSUER_STRING= |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
{ | ||
"discovery": { | ||
"parameter": [ | ||
"authorization_endpoint", | ||
"claim_types_supported", | ||
"claims_parameter_supported", | ||
"claims_supported", | ||
"code_challenge_methods_supported", | ||
"device_authorization_endpoint", | ||
"grant_types_supported", | ||
"id_token_signing_alg_values_supported", | ||
"issuer", | ||
"jwks_uri", | ||
"request_parameter_supported", | ||
"request_uri_parameter_supported", | ||
"require_request_uri_registration", | ||
"response_modes_supported", | ||
"response_types_supported", | ||
"revocation_endpoint", | ||
"revocation_endpoint_auth_methods_supported", | ||
"scopes_supported", | ||
"subject_types_supported", | ||
"token_endpoint", | ||
"token_endpoint_auth_methods_supported", | ||
"userinfo_endpoint" | ||
], | ||
"validation_schema": "all.schema.json" | ||
}, | ||
"token": { | ||
"validation_schema": "test.schema.json", | ||
"key_algorithm": "RS256" | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
export class DiscoveryDto { | ||
schema: string; | ||
issuer_url: string | ||
authorization_endpoint_s: string; | ||
claim_types_supported_s: string; | ||
claims_parameter_supported_s: string; | ||
claims_supported_s: string; | ||
code_challenge_methods_supported_s: string; | ||
device_authorization_endpoint_s: string; | ||
grant_types_supported_s: string; | ||
id_token_signing_alg_values_supported_s: string; | ||
issuer_s: string; | ||
jwks_uri_s: string; | ||
request_parameter_supported_s: string; | ||
request_uri_parameter_supported_s: string; | ||
require_request_uri_registration_s: string; | ||
response_modes_supported_s: string; | ||
response_types_supported_s: string; | ||
revocation_endpoint_s: string; | ||
revocation_endpoint_auth_methods_supported_s: string; | ||
scopes_supported_s: string; | ||
subject_types_supported_s: string; | ||
token_endpoint_s: string; | ||
token_endpoint_auth_methods_supported_s: string; | ||
userinfo_endpoint_s: string; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,59 +1,31 @@ | ||
import {HttpException, HttpStatus, Injectable} from '@nestjs/common'; | ||
import {Issuer} from "openid-client"; | ||
import Ajv, {JSONSchemaType} from "ajv" | ||
import {HttpException, HttpStatus, Inject, Injectable} from '@nestjs/common'; | ||
import { join } from 'path'; | ||
import { SettingsService } from '../settings/settings.service'; | ||
import { HelperService } from '../helper/helper.service'; | ||
|
||
@Injectable() | ||
export class DiscoveryService { | ||
@Inject(SettingsService) | ||
private readonly settingsService: SettingsService; | ||
@Inject(HelperService) | ||
private readonly helperService: HelperService; | ||
|
||
async get_issuer(issuer_s) { | ||
if(issuer_s === undefined || issuer_s === ''){ | ||
throw new HttpException( | ||
'There was no issuer string passed to get the issuer', | ||
HttpStatus.BAD_REQUEST, | ||
); | ||
} | ||
const issuer = await Issuer.discover(issuer_s); | ||
return issuer; | ||
async getSchemas(schema_s: string) { | ||
return this.helperService.getSchemasHelper(schema_s, 'discovery'); | ||
} | ||
async validateJson(issuer: object, schema: object) { | ||
const ajv = new Ajv(); | ||
const validate = ajv.compile(schema); | ||
return [validate(issuer), validate.errors]; | ||
} | ||
|
||
myStringify(issuer, required, keys) { | ||
let res = '{\n'; | ||
let first = true; | ||
for (const key in issuer) { | ||
if (keys.includes(key)) { | ||
if (!first) { | ||
res = res + ',\n'; | ||
} | ||
if (required.includes(key)) { | ||
res = res + ` "${key}": ` + '<span style="color:green">' + JSON.stringify(issuer[key]) + '</span>'; | ||
} else { | ||
res = res + ` "${key}": ` + JSON.stringify(issuer[key], null, 2); | ||
} | ||
first = false; | ||
} | ||
} | ||
res = res + '\n}'; | ||
return res; | ||
} | ||
async get_issuer(issuer_s) { return this.helperService.get_issuer(issuer_s) } | ||
|
||
async coloredFilteredValidationWithFileContent(issuer: object, schema: any, keys: any[]) { | ||
const [ valid, errors ] = await this.validateJson(issuer, schema); | ||
if (valid) { | ||
const required = schema.required; | ||
return [1, this.myStringify(issuer, required, keys)]; | ||
} else { | ||
return [0, JSON.stringify(errors, null, 2)]; | ||
} | ||
} | ||
getDefaultCheckboxes() { | ||
let x = {}; | ||
for (const i in this.settingsService.config.discovery.parameter) { | ||
x[this.settingsService.config.discovery.parameter[i]] = 1; | ||
} | ||
return x; | ||
} | ||
|
||
async coloredFilteredValidation(issuer: object, schema_file: string, keys: any[]) { | ||
const schema = require(join('..', '..', 'schema', schema_file)); | ||
return await this.coloredFilteredValidationWithFileContent(issuer, schema, keys); | ||
} | ||
async coloredFilteredValidation(issuer: object, schema_file: string, keys: any[]) { | ||
const schema = require(join('..', '..', 'schema', schema_file)); | ||
return await this.helperService.coloredFilteredValidationWithFileContent(issuer, schema, keys); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
//SDPX-License-Identifier: MIT | ||
//SDPX-FileCopyrightText: 2022 Philip Rebbe <rebbe.philip@fau.de> | ||
|
||
export class ClientCredentialFlowInputDto { | ||
issuerUrl: string; | ||
clientId: string; | ||
clientSecret: string; | ||
|
||
constructor(partial: Partial<ClientCredentialFlowInputDto>) { | ||
Object.assign(this, partial); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
//SDPX-License-Identifier: MIT | ||
//SDPX-FileCopyrightText: 2022 Philip Rebbe <rebbe.philip@fau.de> | ||
|
||
export class ClientCredentialFlowResultDto { | ||
payload: string; | ||
header: string; | ||
success: boolean; | ||
message: string; | ||
|
||
constructor(partial: Partial<ClientCredentialFlowResultDto>) { | ||
Object.assign(this, partial); | ||
} | ||
} |
Oops, something went wrong.