You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
23 lines
702 B
23 lines
702 B
import {ClientRepository, OAuth2Client, isOAuth2Client} from '../types'
|
|
import {Awaitable, ErrorWithContext, Maybe} from '../../../util'
|
|
import {Inject, Injectable} from '../../../di'
|
|
import {Config} from '../../../service/Config'
|
|
|
|
@Injectable()
|
|
export class ConfigClientRepository extends ClientRepository {
|
|
@Inject()
|
|
protected readonly config!: Config
|
|
|
|
find(id: string): Awaitable<Maybe<OAuth2Client>> {
|
|
const client = this.config.get(`oauth2.clients.${id}`)
|
|
if ( !isOAuth2Client(client) ) {
|
|
throw new ErrorWithContext('Invalid OAuth2 client configuration', {
|
|
id,
|
|
client,
|
|
})
|
|
}
|
|
|
|
return client
|
|
}
|
|
}
|