Bunped version of auth library + refactored some of OAuthApp object to be able to get access to lower objects (Client) if necessary
All checks were successful
Publish to Private NPM Registry / publish (push) Successful in 35s
All checks were successful
Publish to Private NPM Registry / publish (push) Successful in 35s
This commit is contained in:
parent
9a21ec9614
commit
0402b5297b
3 changed files with 17 additions and 10 deletions
|
|
@ -39,7 +39,7 @@
|
||||||
"create-ba-web-app": "node ./bin/create-project.js"
|
"create-ba-web-app": "node ./bin/create-project.js"
|
||||||
},
|
},
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"@BridgemanAccessible/ba-auth": "^1.0.21",
|
"@BridgemanAccessible/ba-auth": "^1.0.22",
|
||||||
"@BridgemanAccessible/ba-logging": "^1.0.1",
|
"@BridgemanAccessible/ba-logging": "^1.0.1",
|
||||||
"express": "^4.19.2",
|
"express": "^4.19.2",
|
||||||
"fs-extra": "^11.2.0",
|
"fs-extra": "^11.2.0",
|
||||||
|
|
|
||||||
|
|
@ -68,6 +68,8 @@ export class OAuthApp extends App {
|
||||||
private auth_default_response_mode?: 'query' | 'fragment' | 'form_post';
|
private auth_default_response_mode?: 'query' | 'fragment' | 'form_post';
|
||||||
private client_secret?: string;
|
private client_secret?: string;
|
||||||
|
|
||||||
|
private client: Client;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Create a new OAuth app
|
* Create a new OAuth app
|
||||||
*
|
*
|
||||||
|
|
@ -132,6 +134,11 @@ export class OAuthApp extends App {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/** Returns the OAuthApp's Client instance (which is useful for managing keys, creating resource request, etc...) */
|
||||||
|
getClient(): Client {
|
||||||
|
return this.client;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Setup the OAuth client
|
* Setup the OAuth client
|
||||||
*
|
*
|
||||||
|
|
@ -160,7 +167,7 @@ export class OAuthApp extends App {
|
||||||
.getRouter()
|
.getRouter()
|
||||||
.addOutsideFrameworkRoute('/.well-known/jwks.json');
|
.addOutsideFrameworkRoute('/.well-known/jwks.json');
|
||||||
|
|
||||||
const client = await Client.setup<BridgemanAccessibleAppClaims>(
|
this.client = await Client.setup<BridgemanAccessibleAppClaims>(
|
||||||
app.getExpressApp(),
|
app.getExpressApp(),
|
||||||
baseAppUrl,
|
baseAppUrl,
|
||||||
this.onAuth,
|
this.onAuth,
|
||||||
|
|
@ -185,7 +192,7 @@ export class OAuthApp extends App {
|
||||||
}
|
}
|
||||||
);
|
);
|
||||||
|
|
||||||
client.getSetupRoutes().forEach((route) => {
|
this.client.getSetupRoutes().forEach((route) => {
|
||||||
logMessage(`Adding outside framework route: ${route}`, LogLevel.DEBUG);
|
logMessage(`Adding outside framework route: ${route}`, LogLevel.DEBUG);
|
||||||
app.getInitializer().getRouter().addOutsideFrameworkRoute(route);
|
app.getInitializer().getRouter().addOutsideFrameworkRoute(route);
|
||||||
});
|
});
|
||||||
|
|
@ -200,7 +207,7 @@ export class OAuthApp extends App {
|
||||||
*
|
*
|
||||||
* @param app The Express app object (that is now listening)
|
* @param app The Express app object (that is now listening)
|
||||||
*/
|
*/
|
||||||
async onStart(app: App, callback?: (app: App) => void | Promise<void>) {
|
private async onStart(app: App, callback?: (app: OAuthApp) => void | Promise<void>) {
|
||||||
try {
|
try {
|
||||||
// Setup the OAuth client.
|
// Setup the OAuth client.
|
||||||
// This is done here because we need the client to be serving/listening for requests for the auth library stuff to work
|
// This is done here because we need the client to be serving/listening for requests for the auth library stuff to work
|
||||||
|
|
@ -208,7 +215,7 @@ export class OAuthApp extends App {
|
||||||
await this.setupOAuthClient(app);
|
await this.setupOAuthClient(app);
|
||||||
|
|
||||||
if(typeof callback !== 'undefined') {
|
if(typeof callback !== 'undefined') {
|
||||||
await callback.bind(this)(app);
|
await callback(this);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
catch(err) {
|
catch(err) {
|
||||||
|
|
@ -228,7 +235,7 @@ export class OAuthApp extends App {
|
||||||
* And doesn't have to worry about the OAuth details to make this work.
|
* And doesn't have to worry about the OAuth details to make this work.
|
||||||
* Though it does provide tweaking the OAuth details via options provided to the constructor.
|
* Though it does provide tweaking the OAuth details via options provided to the constructor.
|
||||||
*/
|
*/
|
||||||
async run<T extends Initializer>(initializer?: T, callback?: (app: App) => void | Promise<void>) {
|
async run<T extends Initializer>(initializer?: T, callback?: (app: OAuthApp) => void | Promise<void>) {
|
||||||
await super.run(initializer, async (app: App) => this.onStart(app, callback));
|
await super.run(initializer, async (app: App) => this.onStart(app, callback));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -2,10 +2,10 @@
|
||||||
# yarn lockfile v1
|
# yarn lockfile v1
|
||||||
|
|
||||||
|
|
||||||
"@BridgemanAccessible/ba-auth@^1.0.21":
|
"@BridgemanAccessible/ba-auth@^1.0.22":
|
||||||
version "1.0.21"
|
version "1.0.22"
|
||||||
resolved "https://npm.pkg.bridgemanaccessible.ca/@BridgemanAccessible/ba-auth/-/ba-auth-1.0.21.tgz#288b72f5f40b634ca34ace34400857e0fe62cb20"
|
resolved "https://npm.pkg.bridgemanaccessible.ca/@BridgemanAccessible/ba-auth/-/ba-auth-1.0.22.tgz#3232029d562023f4d4a745accd9c0bce4e99a1fe"
|
||||||
integrity sha512-3KkRj1SwYUot64/CoLGOojPLORTTXhqBBJIMVS4bpXOj695TXOluoNAv2dH0n61cfKCbBxbVnwt6h1AQq7cvfw==
|
integrity sha512-GI9Bx+zSPpj7mB6X5dzYw24/KkFA9vCniUGe5soiayhkZXSNucEKMuLjPA9VZAKfDsf1I3ygMLAyjrW+Rm0wlQ==
|
||||||
dependencies:
|
dependencies:
|
||||||
"@BridgemanAccessible/ba-logging" "^1.0.1"
|
"@BridgemanAccessible/ba-logging" "^1.0.1"
|
||||||
"@azure/identity" "^4.0.1"
|
"@azure/identity" "^4.0.1"
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue