lib/authorization/index.js
function __verify_client_registration_entries(authorize_request) {

    return new Promise(async (resolve, reject) => {
        let error_object = {
            error: "unauthorized_client",
            error_description: ""
        };

        try {
            if (!authorize_request.client_id || !authorize_request.redirect_uri) {
                error_object.error_description = "Incorrect client_id/redirect_uri values";
                return reject(error_object);
            }

            let redirect_url = Url.parse(authorize_request.redirect_uri);

            if (redirect_url.protocol.toLowerCase() !== "https:") {
                error_object.error_description = "Redirect_uri must use the https protocol.";
                return reject(error_object);
            }

            try {
                const client_registry = await client_endpoint
                    .client_registrar_module
                    .get_client_registration(authorize_request.client_id);
                if (!client_registry || (client_registry.redirect_uri_hostname.trim() !== redirect_url.hostname) || (client_registry.redirect_uri_port.trim() !== redirect_url.port)) {
                    error_object.error_description = "Incorrect client_id/redirect_uri values";
                    return reject(error_object);
                } else {
                    return resolve();
                }
            } catch (err) {
                return reject(error_object);
            }
        } catch (err) {
            error_object.error_description = "Incorrect client_id/redirect_uri values";
            return reject(error_object);
        }
    });
}
function __verify_client_registration_entries(authorize_request) {

    return new Promise(async (resolve, reject) => {
        let error_object = {
            error: "unauthorized_client",
            error_description: ""
        };

        try {
            if (!authorize_request.client_id || !authorize_request.redirect_uri) {
                error_object.error_description = "Incorrect client_id/redirect_uri values";
                return reject(error_object);
            }

            let redirect_url = Url.parse(authorize_request.redirect_uri);

            if (redirect_url.protocol.toLowerCase() !== "https:") {
                error_object.error_description = "Redirect_uri must use the https protocol.";
                return reject(error_object);
            }

            try {
                const client_registry = await client_endpoint
                    .client_registrar_module
                    .get_client_registration(authorize_request.client_id);
                if (!client_registry || (client_registry.redirect_uri_hostname.trim() !== redirect_url.hostname) || (client_registry.redirect_uri_port.trim() !== redirect_url.port)) {
                    error_object.error_description = "Incorrect client_id/redirect_uri values";
                    return reject(error_object);
                } else {
                    return resolve();
                }
            } catch (err) {
                return reject(error_object);
            }
        } catch (err) {
            error_object.error_description = "Incorrect client_id/redirect_uri values";
            return reject(error_object);
        }
    });
}
function __verify_client_registration_entries ( authorize_request ) { return new Promise ( async ( resolve , reject ) => { let error_object = { error : "unauthorized_client" , error_description : "" } ; try { if ( ! authorize_request . client_id || ! authorize_request . redirect_uri ) { error_object . error_description = "Incorrect client_id/redirect_uri values" ; return reject ( error_object ) ; } let redirect_url = Url . parse ( authorize_request . redirect_uri ) ; if ( redirect_url . protocol . toLowerCase ( ) !== "https:" ) { error_object . error_description = "Redirect_uri must use the https protocol." ; return reject ( error_object ) ; } try { const client_registry = await client_endpoint . client_registrar_module . get_client_registration ( authorize_request . client_id ) ; if ( ! client_registry || ( client_registry . redirect_uri_hostname . trim ( ) !== redirect_url . hostname ) || ( client_registry . redirect_uri_port . trim ( ) !== redirect_url . port ) ) { error_object . error_description = "Incorrect client_id/redirect_uri values" ; return reject ( error_object ) ; } else { return resolve ( ) ; } } catch ( err ) { return reject ( error_object ) ; } } catch ( err ) { error_object . error_description = "Incorrect client_id/redirect_uri values" ; return reject ( error_object ) ; } } ) ; }
This method verifies that the client ID and the redirect URI in the request
match the respective ones in the client registry. If the client ID and
redirect URI do not match the ones in the client registry, then no redirect
is sent at all, this is necessary to prevent reflected attacks.  In this
case only an error is returned to the user agent without redirects.



@param  {[type]} authorize_request [description]
@return {[type]}                  [description]
This method verifies that the client ID and the redirect URI in the request match the respective ones in the client registry . If the client ID and redirect URI do not match the ones in the client registry then no redirect is sent at all this is necessary to prevent reflected attacks . In this case only an error is returned to the user agent without redirects .