Skip to content

Instantly share code, notes, and snippets.

@SpringMT
Created November 25, 2019 22:19
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save SpringMT/2e7aeaa9fa3f99a2360393b0e054dacb to your computer and use it in GitHub Desktop.
Save SpringMT/2e7aeaa9fa3f99a2360393b0e054dacb to your computer and use it in GitHub Desktop.
241,243c241,261
< /*
< * Generate an ID token, if necessary
< */
---
> if (__.contains(code.scope, 'openid') && code.user) {
> var header = { 'typ': 'JWT', 'alg': rsaKey.alg, 'kid': rsaKey.kid };
>
> var ipayload = {
> iss: 'http://localhost:9001/',
> sub: code.user.sub,
> aud: client.client_id,
> iat: Math.floor(Date.now() / 1000),
> exp: Math.floor(Date.now() / 1000) + (5 * 60)
> };
> if (code.request.nonce) {
> ipayload.nonce = code.request.nonce;
> }
>
> var privateKey = jose.KEYUTIL.getKey(rsaKey);
> var id_token = jose.jws.JWS.sign(header.alg, JSON.stringify(header), JSON.stringify(ipayload), privateKey);
>
> console.log('Issuing ID token %s', id_token);
>
> token_response.id_token = id_token;
>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment