This repository has been archived by the owner on Apr 3, 2019. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 108
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #2983 from mozilla/oauth-grant-with-session-token
feat(oauth): Add /oauth/token route, optionally authed via sessionToken
- Loading branch information
Showing
18 changed files
with
981 additions
and
10 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
/* This Source Code Form is subject to the terms of the Mozilla Public | ||
* License, v. 2.0. If a copy of the MPL was not distributed with this | ||
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */ | ||
|
||
'use strict'; | ||
|
||
const Joi = require('joi'); | ||
const validators = require('../routes/validators'); | ||
|
||
module.exports = (config) => { | ||
return { | ||
path: '/v1/token', | ||
method: 'POST', | ||
validate: { | ||
payload: Joi.object({ | ||
grant_type: Joi.string().valid('authorization_code').default('authorization_code'), | ||
client_id: validators.clientId.required(), | ||
client_secret: validators.clientSecret.optional(), | ||
code: validators.authorizationCode.required(), | ||
code_verifier: validators.pkceCodeVerifier.optional(), | ||
redirect_uri: validators.url().optional(), | ||
// Note: the max allowed TTL is currently configured in oauth-server config, | ||
// making it hard to know what limit to set here. | ||
ttl: Joi.number().positive().optional(), | ||
}).xor('client_secret', 'code_verifier'), | ||
response: Joi.object({ | ||
access_token: validators.accessToken.required(), | ||
refresh_token: validators.refreshToken.optional(), | ||
id_token: validators.assertion.optional(), | ||
scope: validators.scope.required(), | ||
token_type: Joi.string().valid('bearer').required(), | ||
expires_in: Joi.number().required(), | ||
auth_at: Joi.number().required(), | ||
keys_jwe: validators.jwe.optional() | ||
}) | ||
} | ||
}; | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
/* This Source Code Form is subject to the terms of the Mozilla Public | ||
* License, v. 2.0. If a copy of the MPL was not distributed with this | ||
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */ | ||
|
||
'use strict'; | ||
|
||
const Joi = require('joi'); | ||
const validators = require('../routes/validators'); | ||
|
||
module.exports = (config) => { | ||
return { | ||
path: '/v1/token', | ||
method: 'POST', | ||
validate: { | ||
payload: Joi.object({ | ||
grant_type: Joi.string().valid('fxa-credentials').default('fxa-credentials'), | ||
client_id: validators.clientId.required(), | ||
assertion: validators.assertion.required(), | ||
scope: validators.scope.optional(), | ||
access_type: Joi.string().valid('online', 'offline').default('online'), | ||
// Note: the max allowed TTL is currently configured in oauth-server config, | ||
// making it hard to know what limit to set here. | ||
ttl: Joi.number().positive().optional(), | ||
}), | ||
response: Joi.object({ | ||
access_token: validators.accessToken.required(), | ||
refresh_token: validators.refreshToken.optional(), | ||
id_token: validators.assertion.optional(), | ||
scope: validators.scope.required(), | ||
auth_at: Joi.number().required(), | ||
token_type: Joi.string().valid('bearer').required(), | ||
expires_in: Joi.number().required() | ||
}) | ||
} | ||
}; | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
/* This Source Code Form is subject to the terms of the Mozilla Public | ||
* License, v. 2.0. If a copy of the MPL was not distributed with this | ||
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */ | ||
|
||
'use strict'; | ||
|
||
const Joi = require('joi'); | ||
const validators = require('../routes/validators'); | ||
|
||
module.exports = (config) => { | ||
return { | ||
path: '/v1/token', | ||
method: 'POST', | ||
validate: { | ||
payload: Joi.object({ | ||
grant_type: Joi.string().valid('refresh_token').required(), | ||
client_id: validators.clientId.required(), | ||
client_secret: validators.clientSecret.optional(), | ||
refresh_token: validators.refreshToken.required(), | ||
scope: validators.scope.optional(), | ||
// Note: the max allowed TTL is currently configured in oauth-server config, | ||
// making it hard to know what limit to set here. | ||
ttl: Joi.number().positive().optional(), | ||
}), | ||
response: Joi.object({ | ||
access_token: validators.accessToken.required(), | ||
scope: validators.scope.required(), | ||
token_type: Joi.string().valid('bearer').required(), | ||
expires_in: Joi.number().required() | ||
}) | ||
} | ||
}; | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.