Skip to content

Commit

Permalink
fixed cloudfront example
Browse files Browse the repository at this point in the history
  • Loading branch information
vzakharchenko committed May 21, 2020
1 parent 37b16a0 commit 6b411ef
Show file tree
Hide file tree
Showing 5 changed files with 6 additions and 6 deletions.
4 changes: 2 additions & 2 deletions __tests__/src/clientAuthorizationTest.js
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ describe('testing clientAuthorization', () => {
if (data === 'grant_type=client_credentials&client_id=lambda-jwks&client_assertion_type=urn:ietf:params:oauth:client-assertion-type:jwt-bearer&client_assertion=jwsSignature') {
return JSON.stringify({ access_token: 'access_token_jws' });
}
if (data === 'refresh_token=refresh_token&client_assertion_type=urn:ietf:params:oauth:client-assertion-type:jwt-bearer&client_id=lambda&client_secret=772decbe-0151-4b08-8171-bec6d097293b') {
if (data === 'refresh_token=refresh_token&grant_type=refresh_token&client_assertion_type=urn:ietf:params:oauth:client-assertion-type:jwt-bearer&client_id=lambda&client_secret=772decbe-0151-4b08-8171-bec6d097293b') {
return JSON.stringify({ access_token: 'access_token_refresh' });
}
throw new Error(`unexpected token data: ${data}`);
Expand All @@ -72,7 +72,7 @@ describe('testing clientAuthorization', () => {
if (data === 'code=code&grant_type=authorization_code&client_assertion_type=urn:ietf:params:oauth:client-assertion-type:jwt-bearer&client_id=lambda&client_secret=772decbe-0151-4b08-8171-bec6d097293b&redirect_uri=host%2Flambda-authorizer%2Flambda%2Fcallback') {
return JSON.stringify({ access_token: 'access_token_code' });
}
if (data === 'refresh_token=refresh_token&client_assertion_type=urn:ietf:params:oauth:client-assertion-type:jwt-bearer&client_id=lambda&client_secret=772decbe-0151-4b08-8171-bec6d097293b') {
if (data === 'refresh_token=refresh_token&grant_type=refresh_token&client_assertion_type=urn:ietf:params:oauth:client-assertion-type:jwt-bearer&client_id=lambda&client_secret=772decbe-0151-4b08-8171-bec6d097293b') {
return JSON.stringify({ access_token: 'access_token_refresh' });
}
throw new Error(`unexpected token data: ${data}`);
Expand Down
2 changes: 1 addition & 1 deletion __tests__/src/edge/routers/LogoutTest.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ describe('testing logout', () => {
});

test('test tenantLogout', async () => {
const ret = await tenantLogout({}, { keycloakJson: { realm: 'name', resource: 'resource' } });
const ret = await tenantLogout({}, { keycloakJson: () => ({ realm: 'name', resource: 'resource' }) });
expect(ret).toEqual({
body: 'Redirect to logout page',
headers: {
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "keycloak-lambda-authorizer",
"version": "0.2.7",
"version": "0.2.8",
"description": "Keycloak adapter for aws Lambda",
"main": "index.js",
"homepage": "https://github.com/vzakharchenko/keycloak-lambda-authorizer",
Expand Down
2 changes: 1 addition & 1 deletion src/clientAuthorization.js
Original file line number Diff line number Diff line change
Expand Up @@ -127,7 +127,7 @@ async function clientAuthentication(uma2Config, options) {
const authorization = await clientIdAuthorization(options);
let data = `grant_type=client_credentials&${authorization}`;
if (token && !isExpired(options, JSON.parse(token).decodedRefreshToken)) {
data = `refresh_token=${JSON.parse(token).refresh_token}&client_assertion_type=urn:ietf:params:oauth:client-assertion-type:jwt-bearer&${authorization}`;
data = `refresh_token=${JSON.parse(token).refresh_token}&grant_type=refresh_token&client_assertion_type=urn:ietf:params:oauth:client-assertion-type:jwt-bearer&${authorization}`;
}
const res = await sendData(`${uma2Config.token_endpoint}`, 'POST', data);
token = JSON.parse(res);
Expand Down
2 changes: 1 addition & 1 deletion src/edge/lambdaEdgeUtils.js
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ async function signState(state, options) {
n: tenantName(options.keycloakJson),
exp: timeSec + 600,
};
const jwtToken = await clientJWT(payload, options.sessionManager.sessionOptions);
const jwtToken = await clientJWT(payload, options);
return jwtToken;
}

Expand Down

0 comments on commit 6b411ef

Please sign in to comment.