示例#1
0
 before(function(done) {
   function issue(client, user, done) {
     if (client.id !== 'c123') { return done(new Error('incorrect client argument')); }
     if (user.id !== 'u123') { return done(new Error('incorrect user argument')); }
     
     return done(null, 'xyz');
   }
   
   chai.oauth2orize.grant(token(issue))
     .txn(function(txn) {
       txn.client = { id: 'c123', name: 'Example' };
       txn.redirectURI = 'http://example.com/auth/callback';
       txn.req = {
         redirectURI: 'http://example.com/auth/callback',
         state: 'f2o2o2'
       };
       txn.user = { id: 'u123', name: 'Bob' };
       txn.res = { allow: false };
     })
     .end(function(res) {
       response = res;
       done();
     })
     .decide();
 });
 before(function(done) {
   chai.oauth2orize.grant(extensions())
     .req(function(req) {
       req.query = {};
     })
     .parse(function(e, o) {
       err = e;
       ext = o;
       done();
     })
     .authorize();
 });
 before(function(done) {
   chai.oauth2orize.grant(extensions())
     .req(function(req) {
       req.query = qs.parse('response_type=id_token&client_id=https%3A%2F%2Fclient.example.org%2Fcb&scope=openid%20profile&state=af0ifjsldkj&nonce=n-0S6_WzA2Mj&registration=%7B%22logo_uri%22%3A%22https%3A%2F%2Fclient.example.org%2Flogo.png%22%7D')
     })
     .parse(function(e, o) {
       err = e;
       ext = o;
       done();
     })
     .authorize();
 });
 before(function(done) {
   chai.oauth2orize.grant(extensions())
     .req(function(req) {
       // http://lists.openid.net/pipermail/openid-specs-mobile-profile/Week-of-Mon-20141124/000070.html
       req.query = qs.parse('response_type=code&client_id=ABCDEFABCDEFABCDEFABCDEF&scope=openid&redirect_uri=https%3A%2F%2Femail.t-online.de%2F%3Fpf%3D%2Fem&claims=%7B%0A++%22id_token%22%3A%0A++%7B%0A+++%22email%22%3A+%7B%22essential%22%3A+true%7D%0A++%7D%0A%7D')
     })
     .parse(function(e, o) {
       err = e;
       ext = o;
       done();
     })
     .authorize();
 });
 before(function(done) {
   chai.oauth2orize.grant(extensions())
     .req(function(req) {
       // http://lists.openid.net/pipermail/openid-specs-mobile-profile/Week-of-Mon-20141124/000070.html
       req.query = {};
       req.query.claims = 'xyz';
     })
     .parse(function(e, o) {
       err = e;
       ext = o;
       done();
     })
     .authorize();
 });
示例#6
0
 before(function(done) {
   chai.oauth2orize.grant(token(issue))
     .req(function(req) {
       req.query = {};
       req.query.redirect_uri = 'http://example.com/auth/callback';
       req.query.state = 'f1o1o1';
     })
     .parse(function(e, o) {
       err = e;
       out = o;
       done();
     })
     .authorize();
 });
示例#7
0
 before(function(done) {
   chai.oauth2orize.grant(token({ scopeSeparator: [' ', ','] }, issue))
     .req(function(req) {
       req.query = {};
       req.query.client_id = 'c123';
       req.query.redirect_uri = 'http://example.com/auth/callback';
       req.query.scope = 'read,write';
       req.query.state = 'f1o1o1';
     })
     .parse(function(e, o) {
       err = e;
       out = o;
       done();
     })
     .authorize();
 });
 before(function(done) {
   chai.oauth2orize.grant(codeToken(issueToken, issueCode))
     .req(function(req) {
       req.query = {};
       req.query.client_id = 'c123';
       req.query.redirect_uri = 'http://example.com/auth/callback';
       req.query.scope = 'read';
       req.query.state = 'f1o1o1';
     })
     .parse(function(e, o) {
       err = e;
       out = o;
       done();
     })
     .authorize();
 });
示例#9
0
 before(function(done) {
   chai.oauth2orize.grant(code(issue))
     .txn(function(txn) {
       txn.client = { id: 'c123', name: 'Example' };
       txn.req = {
         redirectURI: 'http://example.com/auth/callback'
       }
       txn.user = { id: 'u123', name: 'Bob' };
       txn.res = { allow: true };
     })
     .next(function(e) {
       err = e;
       done();
     })
     .decide();
 });
 before(function(done) {
   chai.oauth2orize.grant(codeIdToken(issueCode, issueIDToken))
     .req(function(req) {
       req.query = {};
       req.query.client_id = ['c123', 'c123'];
       req.query.redirect_uri = 'http://example.com/auth/callback';
       req.query.state = 'f1o1o1';
       req.query.nonce = 'n123';
     })
     .parse(function(e, o) {
       err = e;
       out = o;
       done();
     })
     .authorize();
 });
示例#11
0
 before(function(done) {
   chai.oauth2orize.grant(token(issue))
     .txn(function(txn) {
       txn.client = { id: 'c123', name: 'Example' };
       txn.redirectURI = 'http://example.com/auth/callback';
       txn.req = {
         redirectURI: 'http://example.com/auth/callback'
       };
       txn.user = { id: 'u123', name: 'Bob' };
       txn.res = { allow: true, scope: 'foo' };
     })
     .end(function(res) {
       response = res;
       done();
     })
     .decide();
 });
 before(function(done) {
   chai.oauth2orize.grant(codeIdToken(issueCode, issueIDToken))
     .txn(function(txn) {
       txn.client = { id: 'cTHROW', name: 'Example' };
       txn.redirectURI = 'http://www.example.com/auth/callback';
       txn.req = {
         redirectURI: 'http://example.com/auth/callback',
         nonce: 'n-0S6_WzA2Mj'
       };
       txn.user = { id: 'u123', name: 'Bob' };
       txn.res = { allow: true };
     })
     .next(function(e) {
       err = e;
       done();
     })
     .decide();
 });
示例#13
0
 before(function(done) {
   chai.oauth2orize.grant(code(issue))
     .txn(function(txn) {
       txn.client = { id: 'c123', name: 'Example' };
       txn.redirectURI = 'http://www.example.com/auth/callback';
       txn.req = {
         redirectURI: 'http://example.com/auth/callback',
         state: 'f2o2o2'
       }
       txn.user = { id: 'u123', name: 'Bob' };
       txn.res = { allow: false };
     })
     .end(function(res) {
       response = res;
       done();
     })
     .decide();
 });
示例#14
0
 before(function(done) {
   chai.oauth2orize.grant(token({ modes: { foo: fooResponseMode } }, issue))
     .txn(function(txn) {
       txn.client = { id: 'c123', name: 'Example' };
       txn.redirectURI = 'http://example.com/auth/callback';
       txn.req = {
         redirectURI: 'http://example.com/auth/callback',
         state: '1234'
       };
       txn.user = { id: 'u123', name: 'Bob' };
       txn.res = { allow: true };
     })
     .end(function(res) {
       response = res;
       done();
     })
     .error(new AuthorizationError('not authorized', 'unauthorized_client', 'http://example.com/errors/2'));
 });
示例#15
0
 before(function(done) {
   chai.oauth2orize.grant(token({ modes: { foo: fooResponseMode } }, issue))
     .txn(function(txn) {
       txn.client = { id: 'c123', name: 'Example' };
       txn.redirectURI = 'http://example.com/auth/callback';
       txn.req = {
         redirectURI: 'http://example.com/auth/callback',
         state: 's1t2u3'
       };
       txn.user = { id: 'u123', name: 'Bob' };
       txn.res = { allow: true };
     })
     .end(function(res) {
       response = res;
       done();
     })
     .decide();
 });
示例#16
0
 before(function(done) {
   chai.oauth2orize.grant(token(issue))
     .txn(function(txn) {
       txn.client = { id: 'c123', name: 'Example' };
       txn.redirectURI = 'http://example.com/auth/callback';
       txn.req = {
         redirectURI: 'http://example.com/auth/callback',
         state: 'f1o1o1'
       };
       txn.user = { id: 'u123', name: 'Bob' };
       txn.res = { allow: true, scope: 'foo' };
       txn.locals = { service: { jwksURL: 'http://www.example.com/.well-known/jwks' } };
     })
     .end(function(res) {
       response = res;
       done();
     })
     .decide();
 });
 before(function(done) {
   chai.oauth2orize.grant(codeToken(issueToken, issueCode))
     .txn(function(txn) {
       txn.client = { id: 'c123', name: 'Example' };
       txn.redirectURI = 'http://www.example.com/auth/callback';
       txn.req = {
         redirectURI: 'http://example.com/auth/callback',
         nonce: 'n-0S6_WzA2Mj'
       };
       txn.user = { id: 'u123', name: 'Bob' };
       txn.res = { allow: true };
       txn.locals = { foo: 'bar' };
     })
     .end(function(res) {
       response = res;
       done();
     })
     .decide();
 });
示例#18
0
 before(function(done) {
   function issue(client, redirectURI, user, done) {
   }
   
   chai.oauth2orize.grant(token(issue))
     .txn(function(txn) {
       txn.client = { id: 'c123', name: 'Example' };
       txn.redirectURI = 'http://example.com/auth/callback';
       txn.req = {
         redirectURI: 'http://example.com/auth/callback'
       };
       txn.user = { id: 'u123', name: 'Bob' };
       txn.res = { allow: true };
     })
     .end(function(res) {
       response = res;
       done();
     })
     .error(new Error('something went wrong'));
 });
 before(function(done) {
   chai.oauth2orize.grant(extensions())
     .req(function(req) {
       req.query = {};
       req.query.nonce = 'a1b2c3';
       req.query.display = 'touch';
       req.query.prompt = 'none';
       req.query.max_age = '600';
       req.query.ui_locales = 'en-US';
       req.query.claims_locales = 'en';
       req.query.id_token_hint = 'HEADER.PAYLOAD.SIGNATURE';
       req.query.login_hint = '*****@*****.**';
       req.query.acr_values = '0';
     })
     .parse(function(e, o) {
       err = e;
       ext = o;
       done();
     })
     .authorize();
 });
示例#20
0
 before(function(done) {
   function issue(client, user, done) {
     throw new Error('something was thrown');
   }
   
   chai.oauth2orize.grant(token(issue))
     .txn(function(txn) {
       txn.client = { id: 'cTHROW', name: 'Example' };
       txn.redirectURI = 'http://example.com/auth/callback';
       txn.req = {
         redirectURI: 'http://example.com/auth/callback'
       };
       txn.user = { id: 'u123', name: 'Bob' };
       txn.res = { allow: true };
     })
     .next(function(e) {
       err = e;
       done();
     })
     .decide();
 });
示例#21
0
 before(function(done) {
   function issue(client, user, done) {
     return done(null, false);
   }
   
   chai.oauth2orize.grant(token(issue))
     .txn(function(txn) {
       txn.client = { id: 'cUNAUTHZ', name: 'Example' };
       txn.redirectURI = 'http://example.com/auth/callback';
       txn.req = {
         redirectURI: 'http://example.com/auth/callback'
       };
       txn.user = { id: 'u123', name: 'Bob' };
       txn.res = { allow: true };
     })
     .next(function(e) {
       err = e;
       done();
     })
     .decide();
 });
示例#22
0
 before(function(done) {
   function issue(client, user, done) {
     return done(null, 'xyz');
   }
   
   chai.oauth2orize.grant(token(issue))
     .txn(function(txn) {
       txn.client = { id: 'cERROR', name: 'Example' };
       txn.redirectURI = 'http://example.com/auth/callback';
       txn.req = {
         redirectURI: 'http://example.com/auth/callback'
       };
       txn.user = { id: 'u123', name: 'Bob' };
       txn.res = { allow: true };
     })
     .next(function(e) {
       err = e;
       done();
     })
     .decide(function(cb) {
       process.nextTick(function() { cb(new Error('failed to complete transaction')) });
     });
 });