Skip to content

Commit

Permalink
finish up module1
Browse files Browse the repository at this point in the history
  • Loading branch information
snychka committed May 18, 2020
1 parent c995cb1 commit 381a07c
Showing 1 changed file with 9 additions and 1 deletion.
10 changes: 9 additions & 1 deletion authorization-server.js
Original file line number Diff line number Diff line change
Expand Up @@ -119,7 +119,7 @@ app.post('/token', (req, res) => {
}

let {clientId, clientSecret} = decodeAuthCredentials(req.headers.authorization);
if(clients[clientId] !== clientSecret) {
if(clients[clientId].clientSecret !== clientSecret) {
res.status(401).end();
return;
}
Expand All @@ -132,6 +132,14 @@ app.post('/token', (req, res) => {
let ac =authorizationCodes[req.body.code];
delete authorizationCodes[req.body.code];

let js= jwt.sign(
{userName: ac.userName, scope: ac.clientReq.scope},
fs.readFileSync('./assets/private_key.pem'),
{algorithm: "RS256"}
);

res.status(200).json({access_token: js, token_type: 'Bearer'}).end();


});

Expand Down

0 comments on commit 381a07c

Please sign in to comment.