Expose auth repos in context; create routes commands
All checks were successful
continuous-integration/drone/push Build is passing
All checks were successful
continuous-integration/drone/push Build is passing
This commit is contained in:
@@ -24,6 +24,10 @@ export class Authentication extends Unit {
|
||||
this.middleware.registerNamespace('@auth', this.getMiddlewareResolver())
|
||||
}
|
||||
|
||||
/**
|
||||
* Create the canonical namespace resolver for auth middleware.
|
||||
* @protected
|
||||
*/
|
||||
protected getMiddlewareResolver(): CanonicalResolver<StaticClass<Middleware, Instantiable<Middleware>>> {
|
||||
return (key: string) => {
|
||||
return ({
|
||||
|
||||
@@ -19,7 +19,7 @@ export abstract class SecurityContext {
|
||||
|
||||
constructor(
|
||||
/** The repository from which to draw users. */
|
||||
protected readonly repository: AuthenticatableRepository,
|
||||
public readonly repository: AuthenticatableRepository,
|
||||
|
||||
/** The name of this context. */
|
||||
public readonly name: string,
|
||||
|
||||
@@ -14,7 +14,7 @@ export class SessionSecurityContext extends SecurityContext {
|
||||
|
||||
constructor(
|
||||
/** The repository from which to draw users. */
|
||||
protected readonly repository: AuthenticatableRepository,
|
||||
public readonly repository: AuthenticatableRepository,
|
||||
) {
|
||||
super(repository, 'session')
|
||||
}
|
||||
|
||||
@@ -6,7 +6,7 @@ import {AuthenticatableRepository} from '../types'
|
||||
import {SessionSecurityContext} from '../contexts/SessionSecurityContext'
|
||||
import {SecurityContext} from '../SecurityContext'
|
||||
import {ORMUserRepository} from '../orm/ORMUserRepository'
|
||||
import {AuthConfig} from '../config'
|
||||
import {AuthConfig, AuthenticatableRepositories} from '../config'
|
||||
|
||||
/**
|
||||
* Injects a SessionSecurityContext into the request and attempts to
|
||||
@@ -29,6 +29,7 @@ export class SessionAuthMiddleware extends Middleware {
|
||||
*/
|
||||
protected getRepository(): AuthenticatableRepository {
|
||||
const config: AuthConfig | undefined = this.config.get('auth')
|
||||
return this.make<AuthenticatableRepository>(config?.repositories?.session ?? ORMUserRepository)
|
||||
const repo: typeof AuthenticatableRepository = AuthenticatableRepositories[config?.repositories?.session ?? 'orm']
|
||||
return this.make<AuthenticatableRepository>(repo ?? ORMUserRepository)
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user