Skip to content

Commit

Permalink
Remove jwt security key from store client side code
Browse files Browse the repository at this point in the history
  • Loading branch information
LuBuss committed May 13, 2019
1 parent f079775 commit 09dc837
Show file tree
Hide file tree
Showing 8 changed files with 25 additions and 24 deletions.
17 changes: 17 additions & 0 deletions config/server.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
// config used by store server side only
module.exports = {
// store UI language
language: process.env.LANGUAGE || 'en',
// used by Store (server side)
ajaxBaseUrl: process.env.AJAX_BASE_URL || 'http://localhost:3001/ajax',
// used by Store (server side)
apiBaseUrl: process.env.API_BASE_URL || 'http://localhost:3001/api/v1',

storeListenPort: process.env.STORE_PORT || 3000,

// key to sign tokens
jwtSecretKey: process.env.JWT_SECRET_KEY || '-',

// key to sign store cookies
cookieSecretKey: process.env.COOKIE_SECRET_KEY || '-'
};
17 changes: 2 additions & 15 deletions config/store.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,21 +2,8 @@
module.exports = {
// store UI language
language: process.env.LANGUAGE || 'en',

// used by Store (server side)
apiBaseUrl: process.env.API_BASE_URL || 'http://localhost:3001/api/v1',

// used by API to service assets
assetsBaseURL: process.env.ASSETS_BASE_URL || 'http://localhost:3001',

// used by Store (server side)
ajaxBaseUrl: process.env.AJAX_BASE_URL || 'http://localhost:3001/ajax',

storeListenPort: process.env.STORE_PORT || 3000,

// key to sign tokens
jwtSecretKey: process.env.JWT_SECRET_KEY || '-',

// key to sign store cookies
cookieSecretKey: process.env.COOKIE_SECRET_KEY || '-'
// used by API to service assets
assetsBaseURL: process.env.ASSETS_BASE_URL || 'http://localhost:3001'
};
2 changes: 1 addition & 1 deletion src/server/auth-header.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import jwt from 'jsonwebtoken';
import serverConfigs from '../../config/store';
import serverConfigs from './settings';

const cert = serverConfigs.jwtSecretKey;
class AuthHeader {
Expand Down
2 changes: 1 addition & 1 deletion src/server/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import responseTime from 'response-time';
import path from 'path';
import cookieParser from 'cookie-parser';
import winston from 'winston';
import settings from '../../config/store';
import settings from './settings';
import logger from './logger';
import robotsRendering from './robotsRendering';
import sitemapRendering from './sitemapRendering';
Expand Down
2 changes: 1 addition & 1 deletion src/server/settings.js
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
import settings from '../../config/store';
import settings from '../../config/server';
export default settings;
3 changes: 1 addition & 2 deletions theme/src/components/account/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ import React from 'react';
import { Redirect } from 'react-router-dom';
import Lscache from 'lscache';
import { themeSettings, text } from '../../lib/settings';
import AuthHeader from '../../../../src/server/auth-header';
import Account from './account';

export default class AccountForm extends React.Component {
Expand All @@ -22,7 +21,7 @@ export default class AccountForm extends React.Component {
first_name: values.first_name,
last_name: values.last_name,
email: values.email,
password: AuthHeader.encodeUserPassword(values.password),
password: values.password,
token: Lscache.get('auth_data'),
shipping_address,
billing_address,
Expand Down
3 changes: 1 addition & 2 deletions theme/src/components/login/index.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
import React from 'react';
import AuthHeader from '../../../../src/server/auth-header';
import { themeSettings, text } from '../../lib/settings';
import Lscache from 'lscache';
import Login from './login';
Expand All @@ -19,7 +18,7 @@ export default class LoginForm extends React.Component {

this.props.loginUser({
email: values.email,
password: AuthHeader.encodeUserPassword(values.password),
password: values.password,
history: this.props.history,
cartLayer: cartLayer
});
Expand Down
3 changes: 1 addition & 2 deletions theme/src/components/register/index.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
import React from 'react';
import AuthHeader from '../../../../src/server/auth-header';
import { Redirect } from 'react-router-dom';
import { themeSettings, text } from '../../lib/settings';
import Register from './register';
Expand All @@ -18,7 +17,7 @@ export default class RegisterForm extends React.Component {
first_name: values.first_name,
last_name: values.last_name,
email: values.email,
password: AuthHeader.encodeUserPassword(values.password),
password: values.password,
history: this.props.history
});
};
Expand Down

0 comments on commit 09dc837

Please sign in to comment.