This repository has been archived by the owner on Apr 3, 2019. It is now read-only.
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(openid): add initial OpenID Connect support
Requesting authorization with the scope `openid` will result in an `id_token` property being returned along with the `access_token`. Closes #362
- Loading branch information
1 parent
996935b
commit 93f8758
Showing
8 changed files
with
245 additions
and
8 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
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,39 @@ | ||
/* 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/. */ | ||
|
||
const config = require('../config'); | ||
|
||
const KEYS = (function() { | ||
var priv = config.get('openid.key'); | ||
|
||
function pub(key) { | ||
// Hey, this is important. Listen up. | ||
// | ||
// This function pulls out only the **PUBLIC** pieces of this key. | ||
// For RSA, that's the `e` and `n` values. | ||
// | ||
// BE CAREFUL IF YOU REFACTOR THIS. Thanks. | ||
return { | ||
kty: key.kty, | ||
alg: 'RS256', | ||
kid: key.kid, | ||
use: 'sig', | ||
n: key.n, | ||
e: key.e | ||
}; | ||
} | ||
|
||
var keys = [pub(priv)]; | ||
var old = config.get('openid.oldKey'); | ||
if (Object.keys(old).length) { | ||
keys.push(pub(old)); | ||
} | ||
return { keys: keys }; | ||
})(); | ||
|
||
module.exports = { | ||
handler: function jwks(req, reply) { | ||
reply(KEYS); | ||
} | ||
}; |
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