diff --git a/src/controller/authorization.ts b/src/controller/authorization.ts index 4f5c224..7129f99 100644 --- a/src/controller/authorization.ts +++ b/src/controller/authorization.ts @@ -100,9 +100,11 @@ export const authorization = wrap(async (req, res) => { } // TODO: multiple redirect URI - if (!oauth2.model.client.getRedirectUri(client)) { + if (!(await oauth2.model.client.hasRedirectUri(client))) { throw new UnsupportedResponseType('The client has not set a redirect uri'); - } else if (!oauth2.model.client.checkRedirectUri(client, redirectUri)) { + } else if ( + !(await oauth2.model.client.checkRedirectUri(client, redirectUri)) + ) { throw new InvalidRequest('Wrong RedirectUri provided'); } req.oauth2.logger.debug('redirect_uri check passed'); diff --git a/src/model/model.ts b/src/model/model.ts index e7c60ea..81511ab 100644 --- a/src/model/model.ts +++ b/src/model/model.ts @@ -19,7 +19,7 @@ export interface OAuth2AccessToken { user_id: string | number; client_id: string | number; scope: string; - expires_at: number; + expires_at: Date; } /** @@ -27,7 +27,7 @@ export interface OAuth2AccessToken { */ export interface OAuth2Code { code: string; - expires_at: number; + expires_at: Date; user_id: string | number; client_id: string | number; scope: string; @@ -140,12 +140,15 @@ export interface OAuth2ClientAdapter { /** * Get the redirect uri of a client */ - getRedirectUri: (client: OAuth2Client) => string; + hasRedirectUri: (client: OAuth2Client) => Promise; /** * Check the redirect uri against a client */ - checkRedirectUri: (client: OAuth2Client, redirectUri: string) => boolean; + checkRedirectUri: ( + client: OAuth2Client, + redirectUri: string + ) => Promise; /** * Transform the scope into a string array of scopes