Skip to content

GitLab

  • Menu
    • Projects Groups Snippets
      Help
Projects Groups Snippets
    • Loading...
  • Help
    • Help
    • Support
    • Community forum
    • Submit feedback
    • Contribute to GitLab
  • Sign in
  • L login-with-cryptobadge-express-oauth2
  • Project information
    • Project information
    • Activity
    • Labels
    • Planning hierarchy
    • Members
  • Repository
    • Repository
    • Files
    • Commits
    • Branches
    • Tags
    • Contributors
    • Graph
    • Compare
  • Issues 0
    • Issues 0
    • List
    • Boards
    • Service Desk
    • Milestones
  • Jira
    • Jira
  • Merge requests 0
    • Merge requests 0
  • CI/CD
    • CI/CD
    • Pipelines
    • Jobs
    • Schedules
  • Deployments
    • Deployments
    • Environments
    • Releases
  • Monitor
    • Monitor
    • Incidents
  • Packages & Registries
    • Packages & Registries
    • Container Registry
  • Analytics
    • Analytics
    • Value stream
    • CI/CD
    • Repository
  • Wiki
    • Wiki
  • Snippets
    • Snippets
  • Activity
  • Graph
  • Create a new issue
  • Jobs
  • Commits
  • Issue Boards
Collapse sidebar
  • bombkyu
  • login-with-cryptobadge-express-oauth2
  • Merge requests
  • !3

Merged
Created 6 years ago by bombkyu@bombkyuMaintainer

clean up client project & return authorized scope data

  • Overview 0
  • Commits 1
  • Changes 7
  • Donghwan Kim @donghwan merged 6 years ago

    merged

  • Donghwan Kim @donghwan mentioned in commit 8f40deb8 6 years ago

    mentioned in commit 8f40deb8

  • You're only seeing other activity in the feed. To add a comment, switch to one of the following options.
Please register or sign in to reply
Compare
  • master (base)

and
  • latest version
    15fdf085
    1 commit, 6 years ago

7 files
+ 76
- 231

    Preferences

    File browser
    Compare changes
cli‎ent‎
passport‎-example‎
profi‎le.js‎ +0 -17
strat‎egy.js‎ +0 -126
READ‎ME.md‎ +0 -2
example-oauth2o‎rize-consumer.js‎ +6 -8
oauth-consum‎er-config.js‎ +4 -4
serv‎er.js‎ +49 -67
ser‎ver‎
inde‎x.js‎ +17 -7
client/passport-example/profile.js deleted 100644 → 0
+ 0
- 17
  • View file @ c098a57c

'use strict';
module.exports.parse = function (json) {
var profile = {}
;
profile.id = json.currentUserId;
/*
profile.id = json.identity.id;
profile.displayName = json.identity.first_name + ' ' + json.identity.last_name;
profile.name = { familyName: json.identity.last_name,
givenName: json.identity.first_name };
profile.emails = [{ value: json.identity.email_address }];
*/
return profile;
};
client/passport-example/strategy.js deleted 100644 → 0
+ 0
- 126
  • View file @ c098a57c

'use strict';
/**
* Module dependencies.
*/
var util = require('util')
, OAuth2Strategy = require('passport-oauth').OAuth2Strategy
, InternalOAuthError = require('passport-oauth').InternalOAuthError
, parse = require('./profile').parse
// XXX note that this should have its own config,
// but for simplicity I'm using the main one, one directory up
, pConf = require('../oauth-config').provider
;
/**
* `Strategy` constructor.
*
* The example-oauth2orize authentication strategy authenticates requests by delegating to
* example-oauth2orize using the OAuth 2.0 protocol.
*
* Applications must supply a `verify` callback which accepts an `accessToken`,
* `refreshToken` and service-specific `profile`, and then calls the `done`
* callback supplying a `user`, which should be set to `false` if the
* credentials are not valid. If an exception occured, `err` should be set.
*
* Options:
* - `clientID` your example-oauth2orize application's client id
* - `clientSecret` your example-oauth2orize application's client secret
* - `callbackURL` URL to which example-oauth2orize will redirect the user after granting authorization
*
* Examples:
*
* passport.use(new ExampleStrategy({
* clientID: '123-456-789',
* clientSecret: 'shhh-its-a-secret'
* callbackURL: 'https://www.example.net/auth/example-oauth2orize/callback'
* },
* function (accessToken, refreshToken, profile, done) {
* User.findOrCreate(..., function (err, user) {
* done(err, user);
* });
* }
* ));
*
* @param {Object} options
* @param {Function} verify
* @api public
*/
function Strategy(options, verify) {
var me = this
;
console.log('options', options);
options = options || {};
options.authorizationURL =
options.authorizationURL ||
options.authorizationUrl ||
(pConf.protocol + '://' + pConf.host + '/dialog/authorize')
;
options.tokenURL =
options.tokenURL ||
options.tokenUrl ||
(pConf.protocol + '://' + pConf.host + '/oauth2/token')
;
OAuth2Strategy.call(me, options, verify);
// must be called after prototype is modified
me.name = 'exampleauth';
}
/**
* Inherit from `OAuth2Strategy`.
*/
util.inherits(Strategy, OAuth2Strategy);
/**
* Retrieve user profile from example-oauth2orize.
*
* This function constructs a normalized profile, with the following properties:
*
* - `provider` always set to `example-oauth2orize`
* - `id`
* - `username`
* - `displayName`
*
* @param {String} accessToken
* @param {Function} done
* @api protected
*/
Strategy.prototype.userProfile = function (accessToken, done) {
var me = this
;
me._oauth2.get(
pConf.protocol + '://' + pConf.host + pConf.profileUrl
, accessToken
, function (err, body/*, res*/) {
var json
, profile
;
if (err) { return done(new InternalOAuthError('failed to fetch user profile', err)); }
if ('string' === typeof body) {
try { json = JSON.parse(body); }
catch(e) { done(e); return; }
} else if ('object' === typeof body) {
json = body;
}
profile = parse(json);
profile.provider = me.name;
profile._raw = body;
profile._json = json;
done(null, profile);
}
);
};
/**
* Expose `Strategy`.
*/
module.exports.Strategy = Strategy.Strategy = Strategy;
client/README.md deleted 100644 → 0
+ 0
- 2
  • View file @ c098a57c

# Moved
### [example-oauth2orize-consumer](https://git.daplie.com/coolaj86/example-oauth2orize-consumer) is now at [git.daplie.com/coolaj86/example-oauth2orize-consumer](https://git.daplie.com/coolaj86/example-oauth2orize-consumer)
client/example-oauth2orize-consumer.js
+ 6
- 8
  • View file @ 15fdf085

  • Edit in single-file editor

  • Edit in Web IDE


@@ -3,11 +3,10 @@
/**
* Module dependencies.
*/
var util = require('util')
, OAuth2Strategy = require('passport-oauth').OAuth2Strategy
, InternalOAuthError = require('passport-oauth').InternalOAuthError
, pConf = require('./provider-config')
;
var util = require('util');
var OAuth2Strategy = require('passport-oauth').OAuth2Strategy;
var InternalOAuthError = require('passport-oauth').InternalOAuthError;
var pConf = require('./provider-config');
/**
* `Strategy` constructor.
@@ -77,9 +76,8 @@ Strategy.prototype.userProfile = function(accessToken, done) {
if (err) { return done(new InternalOAuthError('failed to fetch user profile', err)); }
try {
var json = JSON.parse(body)
, profile = { provider: 'example-oauth2orize' }
;
var json = JSON.parse(body);
var profile = { provider: 'example-oauth2orize' };
console.log(json);
/*
client/oauth-consumer-config.js
+ 4
- 4
  • View file @ 15fdf085

  • Edit in single-file editor

  • Edit in Web IDE

module.exports = {
name: 'Example Consumer App'
, icon: 'http://example.com/icon_64.png'
, clientId: '1'
, clientSecret: 'secret'
name: 'Example Consumer App',
icon: 'http://example.com/icon_64.png',
clientId: '1',
clientSecret: 'secret'
};
0 Assignees
None
Assign to
0 Reviewers
None
Request review from
Milestone
No milestone
None
None
Time tracking
No estimate or time spent
Labels
0
None
0
None
    Assign labels
  • Manage project labels

Lock merge request
Unlocked
2
2 participants
Donghwan Kim
bombkyu
Reference: bombkyu/login-with-cryptobadge-express-oauth2!3
Source branch: clean-up&scope-checking

Menu

Projects Groups Snippets
Help