invalidOAuthRequest () { if (!this.params.client_id) return this.error('invalid_request', 'Required parameter "client_id" is missing'); if (!this.params.response_type) return this.error('invalid_request', 'Required parameter "response_type" is missing'); if (!this.params.scope) return this.error('invalid_scope', 'Parameter "scope" is invalid'); if (!this.params.redirect_uri) return this.error('invalid_request', 'Required parameter "redirect_uri" is missing'); var uri = url.parse(this.params.redirect_uri); if (!uri.protocol || !uri.hostname) return this.error('invalid_request', 'Parameter "redirect_uri" must be a valid URL'); if (this.params.response_type !== 'token') { return this.error('unsupported_response_type', 'Response type "' + this.params.response_type + '" is not supported'); } return false; }
redirect (args) { const hash = qs.stringify(args); if (this.params.redirect_uri) { this.response.writeHead(302, { Location: this.params.redirect_uri + '#' + hash }); this.response.end(); } else { this.response.writeHead(400, { 'Content-Type': 'text/plain' }); this.response.end(hash); } }
showForm (username) { if (this.redirectToSSL()) return; if (this.invalidUser(username)) return; if (this.invalidOAuthRequest()) return; this.renderHTML(200, 'auth.html', { title: 'Authorize', client_host: url.parse(this.params.redirect_uri).host, client_id: this.params.client_id, redirect_uri: this.params.redirect_uri, response_type: this.params.response_type, scope: this.params.scope || '', state: this.params.state || '', permissions: this.parseScope(this.params.scope || ''), username: username, access_strings: accessStrings }); }
} catch (error) { params.title = 'Authorize'; params.client_host = url.parse(params.redirect_uri).host; params.error = error.message; params.permissions = permissions;
t.equals(parsedUrl.code_challenge.length, 43, 'initial url: code challenge') t.equals(parsedUrl.code_challenge_method, 'S256', 'initial url: client id') t.equals(parsedUrl.redirect_uri, 'https://platform.nodesource.io/pkce', 'initial url: redirect uri') callback() },