Skip to content

Commit

Permalink
lint:fix
Browse files Browse the repository at this point in the history
  • Loading branch information
vzakharchenko committed Jun 23, 2020
1 parent faded83 commit bf81d9d
Show file tree
Hide file tree
Showing 22 changed files with 9 additions and 42 deletions.
1 change: 0 additions & 1 deletion __tests__/src/JwksTest.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
jest.mock('node-forge');
jest.mock('rsa-pem-to-jwk');


const forge = require('node-forge');
const rsaPemToJwk = require('rsa-pem-to-jwk');
const { jwksUrlResponse } = require('../../src/Jwks');
Expand Down
1 change: 0 additions & 1 deletion __tests__/src/adapter/adapterTest.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@

jest.mock('../../../src/keycloakAuthorizer');
jest.mock('../../../src/Jwks');
const keycloakAuthorizer = require('../../../src/keycloakAuthorizer');
Expand Down
1 change: 0 additions & 1 deletion __tests__/src/apigateway/apiGatewayTest.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@

jest.mock('../../../src/keycloakAuthorizer');

const keycloakAuthorizer = require('../../../src/keycloakAuthorizer');
Expand Down
1 change: 0 additions & 1 deletion __tests__/src/edge/lambdaEdgeUtilsTest.js
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,6 @@ describe('testing lambdaEdgeUtils', () => {
}
});


test('test validateState invalid token', async () => {
jsonwebtoken.decode.mockImplementation(() => ({
}));
Expand Down
1 change: 0 additions & 1 deletion __tests__/src/edge/routers/CallbackTest.js
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,6 @@ describe('testing callback', () => {
});
});


test('test Success RPT ', async () => {
await callbackHandler({ headers: [] }, {
logger: console,
Expand Down
2 changes: 0 additions & 2 deletions __tests__/src/edge/routers/routesTest.js
Original file line number Diff line number Diff line change
Expand Up @@ -116,7 +116,6 @@ describe('testing routers', () => {
});
});


const routeRefresh = routers.protected[2];
expect(await routeRefresh.isRoute({ uri: '/realm/resource/refresh' })).toEqual(true);
await routeRefresh.handle({}, {}, (error, response) => {
Expand Down Expand Up @@ -168,7 +167,6 @@ describe('testing routers', () => {
});
});


const routeRefresh = routers.protected[2];
expect(await routeRefresh.isRoute({ uri: '/realm/resource/refresh' })).toEqual(true);
await routeRefresh.handle({}, {}, (error, response) => {
Expand Down
3 changes: 0 additions & 3 deletions __tests__/src/edge/routers/utils/redirectAuthServerTest.js
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,6 @@ describe('testing redirectAuthServer', () => {
});
});


test('test checkToken without cookie', async () => {
cookiesUtils.getCookie.mockImplementation(() => null);
const resp = await redirectAuthServer.checkToken((error, response) => {
Expand Down Expand Up @@ -157,7 +156,6 @@ describe('testing redirectAuthServer', () => {
expect(resp).toEqual(null);
});


test('test checkToken redirect error', async () => {
decodeAccessToken.mockImplementation(() => ({ accessToken: 'TOKEN', accessTokenDecode: { email: 'test@test', tenants: { testRealm: { } } } }));
const resp = await redirectAuthServer.checkToken((error, response) => {
Expand Down Expand Up @@ -251,7 +249,6 @@ describe('testing redirectAuthServer', () => {
});
});


test('test redirectToKeycloak2', async () => {
await redirectAuthServer.redirectToKeycloak({ uri: '/manufacturer/test', querystring: 'redirectUri=/' }, {
keycloakJson: () => ({ realm: 'testRealm', resource: 'resource' }),
Expand Down
3 changes: 0 additions & 3 deletions __tests__/src/edge/session/SessionManagerTest.js
Original file line number Diff line number Diff line change
@@ -1,12 +1,10 @@

jest.mock('jsonwebtoken');
jest.mock('../../../../src/clientAuthorization');
const jsonwebtoken = require('jsonwebtoken');

const { SessionManager } = require('../../../../src/edge/storage/SessionManager');
const { clientJWT } = require('../../../../src/clientAuthorization');


const sessionStorage = {
saveSession: async () => {

Expand All @@ -20,7 +18,6 @@ const sessionStorage = {
},
};


describe('testing SessionManager', () => {
beforeEach(() => {
jsonwebtoken.decode.mockImplementation(() => ({
Expand Down
2 changes: 0 additions & 2 deletions __tests__/src/keycloakAuthorizerTest.js
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,6 @@ describe('testing keycloakAuthorizer', () => {
}
});


test('test adapter ', async () => {
const token = await keycloakAuthorizer.adapter('TOKEN', {}, { cache });
expect(token).toEqual({
Expand All @@ -116,7 +115,6 @@ describe('testing keycloakAuthorizer', () => {
});
});


test('test awsAdapter authorizer', async () => {
const token = await keycloakAuthorizer.awsAdapter({ authorizationToken: 'Bearer TOKEN' }, {}, { cache, enforce: { enabled: true } });
expect(token).toEqual({
Expand Down
1 change: 0 additions & 1 deletion __tests__/src/umaConfigurationTest.js
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,6 @@ const token = {
},
};


const keycloakJson = () => ({
realm: 'lambda-authorizer',
'auth-server-url': 'http://localhost:8090/auth',
Expand Down
1 change: 0 additions & 1 deletion __tests__/src/utils/TokenUtilsTest.js
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,6 @@ describe('testing TokenUtils', () => {
expect(t).toEqual(false);
});


test('test tokenIsValid still active', async () => {
lambdaAdapter.mockImplementation(async () => {});
const t = await tokenUtils.getActiveToken('SESSION', { access_token: 'TOKEN' }, {});
Expand Down
2 changes: 0 additions & 2 deletions keycloak-cloudfront-dynamodb/DynamoDbSessionStorage.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
const AWS = require('aws-sdk');


function saveSession(dbSettings) {
return async (sessionId,
exp,
Expand Down Expand Up @@ -37,7 +36,6 @@ function updateSession(dbSettings) {
};
}


function transformResponse(item, tenant) {
const itemData = {
session: item.session.S,
Expand Down
18 changes: 9 additions & 9 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "keycloak-lambda-authorizer",
"version": "0.3.1",
"version": "0.3.2",
"description": "Keycloak adapter for aws Lambda",
"main": "index.js",
"homepage": "https://github.com/vzakharchenko/keycloak-lambda-authorizer",
Expand Down Expand Up @@ -55,25 +55,25 @@
"author": "vzakharchenko",
"license": "Apache-2.0",
"devDependencies": {
"@babel/plugin-transform-runtime": "^7.10.1",
"@babel/plugin-transform-runtime": "^7.10.3",
"@babel/polyfill": "^7.10.1",
"@babel/runtime": "^7.10.2",
"@babel/runtime": "^7.10.3",
"babel-eslint": "^10.1.0",
"coveralls": "^3.1.0",
"eslint": "^7.1.0",
"eslint-config-airbnb": "^18.1.0",
"eslint-plugin-import": "^2.20.2",
"jest": "^26.0.1"
"eslint": "^7.3.1",
"eslint-config-airbnb": "^18.2.0",
"eslint-plugin-import": "^2.21.2",
"jest": "^26.1.0"
},
"dependencies": {
"aws-arn-parser": "^1.0.1",
"axios": "^0.19.2",
"cookie": "^0.4.1",
"copy-webpack-plugin": "^6.0.1",
"copy-webpack-plugin": "^6.0.2",
"get-keycloak-public-key": "^1.0.3",
"jsonwebtoken": "^8.5.1",
"jws": "^4.0.0",
"node-cache": "^5.1.0",
"node-cache": "^5.1.1",
"node-forge": "^0.9.1",
"querystring": "^0.2.0",
"rsa-pem-to-jwk": "^1.1.3",
Expand Down
1 change: 0 additions & 1 deletion src/edge/lambdaEdgeUtils.js
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,6 @@ async function validateState(state, options) {
}
}


async function signState(state, options) {
const timeLocal = new Date().getTime();
const timeSec = Math.floor(timeLocal / 1000);
Expand Down
2 changes: 0 additions & 2 deletions src/edge/router.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@

const yallist = require('yallist');

const routes = yallist.create([]);
Expand All @@ -16,7 +15,6 @@ async function getRoute(request, options) {
return null;
}


function registerRoute(route) {
routes.push(route);
}
Expand Down
2 changes: 0 additions & 2 deletions src/edge/routes/Callback.js
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,6 @@ async function callbackHandler(request, options, callback) {
return;
}


let response;
try {
const keycloakJson = options.keycloakJson(options);
Expand All @@ -81,7 +80,6 @@ async function callbackHandler(request, options, callback) {
const { accessTokenDecode } = accessToken;
const sessionTimeOut = 5 * 60 * 60;


const cookieName = tenantName(keycloakJson);
const cookies = getCookie(request, cookieName);
let sessionJWT;
Expand Down
1 change: 0 additions & 1 deletion src/edge/routes/routes.js
Original file line number Diff line number Diff line change
Expand Up @@ -133,7 +133,6 @@ function addProtected(routePath, keycloakJson, options = {}) {
});
}


module.exports = {
addRoute,
addUnProtected,
Expand Down
1 change: 0 additions & 1 deletion src/edge/storage/SessionManager.js
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,6 @@ function checkSession(sessionOptions) {
};
}


async function createSessionToken(host, timeout, token, options) {
const decodedjwt = decodeAccessToken(token).accessTokenDecode;
const timeLocal = new Date().getTime();
Expand Down
2 changes: 0 additions & 2 deletions src/keycloakAuthorizer.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@ const { getKeycloakUrl } = require('./utils/restCalls');
const { enforce } = require('./umaConfiguration');
const { commonOptions } = require('./utils/optionsUtils');


async function getKeyFromKeycloak(options, kid) {
let publicKey = await options.cache.get('publicKey', kid);
if (!publicKey) {
Expand Down Expand Up @@ -86,7 +85,6 @@ async function adapter(tokenString,
return token;
}


async function awsAdapter(event,
keycloakJson,
options) {
Expand Down
1 change: 0 additions & 1 deletion src/umaConfiguration.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@ const { clientAuthentication } = require('./clientAuthorization');

const { fetchData } = require('./utils/restCalls');


async function getUma2Configuration(options) {
const keycloakJson = options.keycloakJson(options);
const { realm } = keycloakJson;
Expand Down
2 changes: 0 additions & 2 deletions src/utils/CustomPageUtils.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 0 additions & 2 deletions src/utils/optionsUtils.js
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,6 @@ const defaultResource = {
max: -1,
};


function updateEnforcer(enforcer) {
const newEnforcer = { ...defaultEnforcer, ...enforcer };
if (newEnforcer.resource) {
Expand Down Expand Up @@ -70,7 +69,6 @@ function lambdaEdgeOptions(sessionManager) {
return { ...lambdaEdgeRouteOptions(sessionManager.sessionOptions), sessionManager };
}


module.exports = {
commonOptions,
lambdaEdgeOptions,
Expand Down

0 comments on commit bf81d9d

Please sign in to comment.