Add ability to get provider by name from auth service

This commit is contained in:
Garrett Mills 2022-04-09 20:08:50 -05:00
parent 5616b3cc1f
commit 36647a013d
2 changed files with 10 additions and 1 deletions

View File

@ -1,6 +1,6 @@
{ {
"name": "@extollo/lib", "name": "@extollo/lib",
"version": "0.9.32", "version": "0.9.33",
"description": "The framework library that lifts up your code.", "description": "The framework library that lifts up your code.",
"main": "lib/index.js", "main": "lib/index.js",
"types": "lib/index.d.ts", "types": "lib/index.d.ts",

View File

@ -27,6 +27,15 @@ export class Authentication extends Unit {
protected providers: {[name: string]: LoginProvider<LoginProviderConfig>} = {} protected providers: {[name: string]: LoginProvider<LoginProviderConfig>} = {}
getProvider(name: string): LoginProvider<LoginProviderConfig> {
const provider = this.providers[name]
if ( !provider ) {
throw new ErrorWithContext('Invalid auth provider name: ' + name, { name })
}
return provider
}
async up(): Promise<void> { async up(): Promise<void> {
this.middleware.registerNamespace('@auth', this.getMiddlewareResolver()) this.middleware.registerNamespace('@auth', this.getMiddlewareResolver())