redirect uri promise checks
This commit is contained in:
parent
8f5146d68f
commit
e6d03cdc40
@ -100,9 +100,11 @@ export const authorization = wrap(async (req, res) => {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// TODO: multiple redirect URI
|
// 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');
|
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');
|
throw new InvalidRequest('Wrong RedirectUri provided');
|
||||||
}
|
}
|
||||||
req.oauth2.logger.debug('redirect_uri check passed');
|
req.oauth2.logger.debug('redirect_uri check passed');
|
||||||
|
@ -19,7 +19,7 @@ export interface OAuth2AccessToken {
|
|||||||
user_id: string | number;
|
user_id: string | number;
|
||||||
client_id: string | number;
|
client_id: string | number;
|
||||||
scope: string;
|
scope: string;
|
||||||
expires_at: number;
|
expires_at: Date;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -27,7 +27,7 @@ export interface OAuth2AccessToken {
|
|||||||
*/
|
*/
|
||||||
export interface OAuth2Code {
|
export interface OAuth2Code {
|
||||||
code: string;
|
code: string;
|
||||||
expires_at: number;
|
expires_at: Date;
|
||||||
user_id: string | number;
|
user_id: string | number;
|
||||||
client_id: string | number;
|
client_id: string | number;
|
||||||
scope: string;
|
scope: string;
|
||||||
@ -140,12 +140,15 @@ export interface OAuth2ClientAdapter {
|
|||||||
/**
|
/**
|
||||||
* Get the redirect uri of a client
|
* Get the redirect uri of a client
|
||||||
*/
|
*/
|
||||||
getRedirectUri: (client: OAuth2Client) => string;
|
hasRedirectUri: (client: OAuth2Client) => Promise<boolean>;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Check the redirect uri against a client
|
* Check the redirect uri against a client
|
||||||
*/
|
*/
|
||||||
checkRedirectUri: (client: OAuth2Client, redirectUri: string) => boolean;
|
checkRedirectUri: (
|
||||||
|
client: OAuth2Client,
|
||||||
|
redirectUri: string
|
||||||
|
) => Promise<boolean>;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Transform the scope into a string array of scopes
|
* Transform the scope into a string array of scopes
|
||||||
|
Reference in New Issue
Block a user