Initial working google auth
This commit is contained in:
parent
fb52d49f74
commit
00a40f6bba
1058 changed files with 114441 additions and 0 deletions
13
auth-service/node_modules/passport-oauth2/lib/state/null.js
generated
vendored
Normal file
13
auth-service/node_modules/passport-oauth2/lib/state/null.js
generated
vendored
Normal file
|
|
@ -0,0 +1,13 @@
|
|||
function NullStore(options) {
|
||||
}
|
||||
|
||||
NullStore.prototype.store = function(req, cb) {
|
||||
cb();
|
||||
}
|
||||
|
||||
NullStore.prototype.verify = function(req, providedState, cb) {
|
||||
cb(null, true);
|
||||
}
|
||||
|
||||
|
||||
module.exports = NullStore;
|
||||
89
auth-service/node_modules/passport-oauth2/lib/state/pkcesession.js
generated
vendored
Normal file
89
auth-service/node_modules/passport-oauth2/lib/state/pkcesession.js
generated
vendored
Normal file
|
|
@ -0,0 +1,89 @@
|
|||
var uid = require('uid2');
|
||||
|
||||
/**
|
||||
* Creates an instance of `SessionStore`.
|
||||
*
|
||||
* This is the state store implementation for the OAuth2Strategy used when
|
||||
* the `state` option is enabled. It generates a random state and stores it in
|
||||
* `req.session` and verifies it when the service provider redirects the user
|
||||
* back to the application.
|
||||
*
|
||||
* This state store requires session support. If no session exists, an error
|
||||
* will be thrown.
|
||||
*
|
||||
* Options:
|
||||
*
|
||||
* - `key` The key in the session under which to store the state
|
||||
*
|
||||
* @constructor
|
||||
* @param {Object} options
|
||||
* @api public
|
||||
*/
|
||||
function PKCESessionStore(options) {
|
||||
if (!options.key) { throw new TypeError('Session-based state store requires a session key'); }
|
||||
this._key = options.key;
|
||||
}
|
||||
|
||||
/**
|
||||
* Store request state.
|
||||
*
|
||||
* This implementation simply generates a random string and stores the value in
|
||||
* the session, where it will be used for verification when the user is
|
||||
* redirected back to the application.
|
||||
*
|
||||
* @param {Object} req
|
||||
* @param {Function} callback
|
||||
* @api protected
|
||||
*/
|
||||
PKCESessionStore.prototype.store = function(req, verifier, state, meta, callback) {
|
||||
if (!req.session) { return callback(new Error('OAuth 2.0 authentication requires session support when using state. Did you forget to use express-session middleware?')); }
|
||||
|
||||
var key = this._key;
|
||||
var sstate = {
|
||||
handle: uid(24),
|
||||
code_verifier: verifier
|
||||
};
|
||||
if (state) { sstate.state = state; }
|
||||
if (!req.session[key]) { req.session[key] = {}; }
|
||||
req.session[key].state = sstate;
|
||||
callback(null, sstate.handle);
|
||||
};
|
||||
|
||||
/**
|
||||
* Verify request state.
|
||||
*
|
||||
* This implementation simply compares the state parameter in the request to the
|
||||
* value generated earlier and stored in the session.
|
||||
*
|
||||
* @param {Object} req
|
||||
* @param {String} providedState
|
||||
* @param {Function} callback
|
||||
* @api protected
|
||||
*/
|
||||
PKCESessionStore.prototype.verify = function(req, providedState, callback) {
|
||||
if (!req.session) { return callback(new Error('OAuth 2.0 authentication requires session support when using state. Did you forget to use express-session middleware?')); }
|
||||
|
||||
var key = this._key;
|
||||
if (!req.session[key]) {
|
||||
return callback(null, false, { message: 'Unable to verify authorization request state.' });
|
||||
}
|
||||
|
||||
var state = req.session[key].state;
|
||||
if (!state) {
|
||||
return callback(null, false, { message: 'Unable to verify authorization request state.' });
|
||||
}
|
||||
|
||||
delete req.session[key].state;
|
||||
if (Object.keys(req.session[key]).length === 0) {
|
||||
delete req.session[key];
|
||||
}
|
||||
|
||||
if (state.handle !== providedState) {
|
||||
return callback(null, false, { message: 'Invalid authorization request state.' });
|
||||
}
|
||||
|
||||
return callback(null, state.code_verifier, state.state);
|
||||
};
|
||||
|
||||
// Expose constructor.
|
||||
module.exports = PKCESessionStore;
|
||||
85
auth-service/node_modules/passport-oauth2/lib/state/session.js
generated
vendored
Normal file
85
auth-service/node_modules/passport-oauth2/lib/state/session.js
generated
vendored
Normal file
|
|
@ -0,0 +1,85 @@
|
|||
var uid = require('uid2');
|
||||
|
||||
/**
|
||||
* Creates an instance of `SessionStore`.
|
||||
*
|
||||
* This is the state store implementation for the OAuth2Strategy used when
|
||||
* the `state` option is enabled. It generates a random state and stores it in
|
||||
* `req.session` and verifies it when the service provider redirects the user
|
||||
* back to the application.
|
||||
*
|
||||
* This state store requires session support. If no session exists, an error
|
||||
* will be thrown.
|
||||
*
|
||||
* Options:
|
||||
*
|
||||
* - `key` The key in the session under which to store the state
|
||||
*
|
||||
* @constructor
|
||||
* @param {Object} options
|
||||
* @api public
|
||||
*/
|
||||
function SessionStore(options) {
|
||||
if (!options.key) { throw new TypeError('Session-based state store requires a session key'); }
|
||||
this._key = options.key;
|
||||
}
|
||||
|
||||
/**
|
||||
* Store request state.
|
||||
*
|
||||
* This implementation simply generates a random string and stores the value in
|
||||
* the session, where it will be used for verification when the user is
|
||||
* redirected back to the application.
|
||||
*
|
||||
* @param {Object} req
|
||||
* @param {Function} callback
|
||||
* @api protected
|
||||
*/
|
||||
SessionStore.prototype.store = function(req, callback) {
|
||||
if (!req.session) { return callback(new Error('OAuth 2.0 authentication requires session support when using state. Did you forget to use express-session middleware?')); }
|
||||
|
||||
var key = this._key;
|
||||
var state = uid(24);
|
||||
if (!req.session[key]) { req.session[key] = {}; }
|
||||
req.session[key].state = state;
|
||||
callback(null, state);
|
||||
};
|
||||
|
||||
/**
|
||||
* Verify request state.
|
||||
*
|
||||
* This implementation simply compares the state parameter in the request to the
|
||||
* value generated earlier and stored in the session.
|
||||
*
|
||||
* @param {Object} req
|
||||
* @param {String} providedState
|
||||
* @param {Function} callback
|
||||
* @api protected
|
||||
*/
|
||||
SessionStore.prototype.verify = function(req, providedState, callback) {
|
||||
if (!req.session) { return callback(new Error('OAuth 2.0 authentication requires session support when using state. Did you forget to use express-session middleware?')); }
|
||||
|
||||
var key = this._key;
|
||||
if (!req.session[key]) {
|
||||
return callback(null, false, { message: 'Unable to verify authorization request state.' });
|
||||
}
|
||||
|
||||
var state = req.session[key].state;
|
||||
if (!state) {
|
||||
return callback(null, false, { message: 'Unable to verify authorization request state.' });
|
||||
}
|
||||
|
||||
delete req.session[key].state;
|
||||
if (Object.keys(req.session[key]).length === 0) {
|
||||
delete req.session[key];
|
||||
}
|
||||
|
||||
if (state !== providedState) {
|
||||
return callback(null, false, { message: 'Invalid authorization request state.' });
|
||||
}
|
||||
|
||||
return callback(null, true);
|
||||
};
|
||||
|
||||
// Expose constructor.
|
||||
module.exports = SessionStore;
|
||||
88
auth-service/node_modules/passport-oauth2/lib/state/store.js
generated
vendored
Normal file
88
auth-service/node_modules/passport-oauth2/lib/state/store.js
generated
vendored
Normal file
|
|
@ -0,0 +1,88 @@
|
|||
var uid = require('uid2');
|
||||
|
||||
/**
|
||||
* Creates an instance of `SessionStore`.
|
||||
*
|
||||
* This is the state store implementation for the OAuth2Strategy used when
|
||||
* the `state` option is enabled. It generates a random state and stores it in
|
||||
* `req.session` and verifies it when the service provider redirects the user
|
||||
* back to the application.
|
||||
*
|
||||
* This state store requires session support. If no session exists, an error
|
||||
* will be thrown.
|
||||
*
|
||||
* Options:
|
||||
*
|
||||
* - `key` The key in the session under which to store the state
|
||||
*
|
||||
* @constructor
|
||||
* @param {Object} options
|
||||
* @api public
|
||||
*/
|
||||
function SessionStore(options) {
|
||||
if (!options.key) { throw new TypeError('Session-based state store requires a session key'); }
|
||||
this._key = options.key;
|
||||
}
|
||||
|
||||
/**
|
||||
* Store request state.
|
||||
*
|
||||
* This implementation simply generates a random string and stores the value in
|
||||
* the session, where it will be used for verification when the user is
|
||||
* redirected back to the application.
|
||||
*
|
||||
* @param {Object} req
|
||||
* @param {Function} callback
|
||||
* @api protected
|
||||
*/
|
||||
SessionStore.prototype.store = function(req, state, meta, callback) {
|
||||
if (!req.session) { return callback(new Error('OAuth 2.0 authentication requires session support when using state. Did you forget to use express-session middleware?')); }
|
||||
|
||||
var key = this._key;
|
||||
var sstate = {
|
||||
handle: uid(24)
|
||||
};
|
||||
if (state) { sstate.state = state; }
|
||||
if (!req.session[key]) { req.session[key] = {}; }
|
||||
req.session[key].state = sstate;
|
||||
callback(null, sstate.handle);
|
||||
};
|
||||
|
||||
/**
|
||||
* Verify request state.
|
||||
*
|
||||
* This implementation simply compares the state parameter in the request to the
|
||||
* value generated earlier and stored in the session.
|
||||
*
|
||||
* @param {Object} req
|
||||
* @param {String} providedState
|
||||
* @param {Function} callback
|
||||
* @api protected
|
||||
*/
|
||||
SessionStore.prototype.verify = function(req, providedState, callback) {
|
||||
if (!req.session) { return callback(new Error('OAuth 2.0 authentication requires session support when using state. Did you forget to use express-session middleware?')); }
|
||||
|
||||
var key = this._key;
|
||||
if (!req.session[key]) {
|
||||
return callback(null, false, { message: 'Unable to verify authorization request state.' });
|
||||
}
|
||||
|
||||
var state = req.session[key].state;
|
||||
if (!state) {
|
||||
return callback(null, false, { message: 'Unable to verify authorization request state.' });
|
||||
}
|
||||
|
||||
delete req.session[key].state;
|
||||
if (Object.keys(req.session[key]).length === 0) {
|
||||
delete req.session[key];
|
||||
}
|
||||
|
||||
if (state.handle !== providedState) {
|
||||
return callback(null, false, { message: 'Invalid authorization request state.' });
|
||||
}
|
||||
|
||||
return callback(null, true, state.state);
|
||||
};
|
||||
|
||||
// Expose constructor.
|
||||
module.exports = SessionStore;
|
||||
Loading…
Add table
Add a link
Reference in a new issue