Skip to content
This repository has been archived by the owner on Apr 16, 2019. It is now read-only.

Commit

Permalink
app delegation flag. Closes #1
Browse files Browse the repository at this point in the history
  • Loading branch information
hueniverse committed Sep 18, 2015
1 parent 902c304 commit 25f407b
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 3 deletions.
4 changes: 3 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ assumes the reader is familiar with the OAuth 1.0a protocol workflow.
the server issues an application ticket.
2. The application directs the [user](#user) to grant it authorization by providing the user with its
application identifier. The user authenticates with the server, reviews the authorization
[grant](#grant)and its [scope](#scope), and if approved the server returns an [rsvp](#rsvp).
[grant](#grant) and its [scope](#scope), and if approved the server returns an [rsvp](#rsvp).
3. The user returns to the application with the rsvp which the application uses to request a new
user-specific ticket. If valid, the server returns a new ticket.
4. The application uses the user-ticket to access the user's protected resources.
Expand All @@ -43,6 +43,8 @@ the control of a user who grants the application access.
Each application definition includes:
- `id` - a unique application identifier.
- `scope` - the default application [scope](#scope).
- `delegate` - if `true`, the application is allowed to delegate a ticket to another application.
Defaults to `false`.

Applications must be registered with the server prior to using Oz. The method through which
applications register is outside the scope of this protocol. When an application registers, it is
Expand Down
8 changes: 7 additions & 1 deletion lib/endpoints.js
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,12 @@ exports.reissue = function (req, payload, options, callback) {
return callback(Hawk.utils.unauthorized('Invalid application'));
}

if (payload.issueTo &&
!app.delegate) {

return callback(Boom.forbidden('Application has no delegation rights'));
}

// Application ticket

if (!ticket.grant) {
Expand Down Expand Up @@ -118,7 +124,7 @@ exports.reissue = function (req, payload, options, callback) {
}

if (payload.issueTo) {
ticketOptions.issueTo = payload.issueTo; // TODO: Check if the app has permission to delegate or re-delegate
ticketOptions.issueTo = payload.issueTo;
}

if (payload.scope) {
Expand Down
3 changes: 2 additions & 1 deletion test/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,8 @@ describe('Oz', function () {
id: 'social',
scope: ['a', 'b', 'c'],
key: 'werxhqb98rpaxn39848xrunpaw3489ruxnpa98w4rxn',
algorithm: 'sha256'
algorithm: 'sha256',
delegate: true
},
network: {
id: 'network',
Expand Down

0 comments on commit 25f407b

Please sign in to comment.