-
Notifications
You must be signed in to change notification settings - Fork 4
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Auth rework #953
base: dev
Are you sure you want to change the base?
Auth rework #953
Conversation
Yadhap/user roles
* Remove existing manual login/logout code for fresh start * save progress * introduce new login introduce login/register, basic layout component. Able to be accessed by /login and /register respectively. Will need to rework login and load order and such later * Max characters applied * update look and feel * Further css adjustments * give new-password so autocomplete doesn't happen * added autoComplete off in login page aswell --------- Co-authored-by: yadhap Dahal <yadhap.dahal@lexisnexisrisk.com>
…tiy functions. Modified RoleTypes, UserRoles model, added migration file and model for refresh_token
…ue for registrationStatus
…ch as read, update, delete
Added registration and login routes, middlewares, controlles and util…
* Remove existing manual login/logout code for fresh start * save progress * introduce new login introduce login/register, basic layout component. Able to be accessed by /login and /register respectively. Will need to rework login and load order and such later * Max characters applied * update look and feel * Further css adjustments * give new-password so autocomplete doesn't happen * added autoComplete off in login page aswell * add forgot password, password complexity validator, reset password --------- Co-authored-by: yadhap Dahal <yadhap.dahal@lexisnexisrisk.com>
Yadhap/user related actions
* Remove existing manual login/logout code for fresh start * save progress * introduce new login introduce login/register, basic layout component. Able to be accessed by /login and /register respectively. Will need to rework login and load order and such later * Max characters applied * update look and feel * Further css adjustments * give new-password so autocomplete doesn't happen * added autoComplete off in login page aswell * add forgot password, password complexity validator, reset password * remove i18n and language switcher * adjust footer * add comment * home css and structure adjustments * rename css class --------- Co-authored-by: yadhap Dahal <yadhap.dahal@lexisnexisrisk.com>
…ock data with a dedicated test database for more accurate unit tests. Implemented end-to-end route tests for authentication and user routes.
Refactored testing environment to mirror production setup.
* create my account page * Adjust look and feel Change password replaces logout in top left, one form for displaying and editing information.
* create my account page * Initial Framework Still need to add Modals and functionality, but waiting on wiring basic flow first so we can have real data to test with. * save
additional auth routes and session mgmt routes
…password and new password, added utility function that makes call to the server to update the password, added the new component to the browser router
… and adhere to the DRY principle
…function to use the new getAUser utility function
…ing password could be used
…registration-flow Yadhap/add verification to registration flow
…reated-users Merged authReworkBranch
…ner-admin-created-users Yadhap/password rest for owner admin created users
…not throw error if these items are undefined
Merged with authRework
* bug fixes for application creation/deletion/switching for left nav and application screens * remove console logs * remove unused functions from application screen * Save Progress * fixes * Update Backend.js * Fix Header for stability * save progress * Update to control reader disabled * Update to allow user to logout no matter what * Allow user to update their own account and create allowed resource list
…gistered-user Yadhap/verify email self registered user
* bug fixes for application creation/deletion/switching for left nav and application screens * remove console logs * remove unused functions from application screen * Save Progress * fixes * Update Backend.js * Fix Header for stability * save progress * Update to control reader disabled * Update to allow user to logout no matter what * Allow user to update their own account and create allowed resource list * Handle login invalid values * 403 fallback page * save * fix spelling error * fix spelling * Patch to not show owner/admin no route access and also fix authController to return user roles and applications on verify email login * Add more conditionals
* Model and Migration * Routes, Controllers, Middleware for instance settings
* bug fixes for application creation/deletion/switching for left nav and application screens * remove console logs * remove unused functions from application screen * Save Progress * fixes * Update Backend.js * Fix Header for stability * save progress * Update to control reader disabled * Update to allow user to logout no matter what * Allow user to update their own account and create allowed resource list * Handle login invalid values * 403 fallback page * save * save * Model and Migration * Routes, Controllers, Middleware for instance settings * save * save progresss * save * finish * Update error message * Changed Steps on Start up Wizard to horizontal --------- Co-authored-by: yadhap Dahal <yadhap.dahal@lexisnexisrisk.com>
* bug fixes for application creation/deletion/switching for left nav and application screens * remove console logs * remove unused functions from application screen * Save Progress * fixes * Update Backend.js * Fix Header for stability * save progress * Update to control reader disabled * Update to allow user to logout no matter what * Allow user to update their own account and create allowed resource list * Handle login invalid values * 403 fallback page * save * save * Model and Migration * Routes, Controllers, Middleware for instance settings * save * save progresss * save * finish * request access route * Only Owners or Admins should see tours * Finish notification * remove extra /
…es in front end so the front end gets right kind of code from Azure before sending to backend
Added login/register with azure option in the back end and made chang…
* Oauth2 front end * wire front and backend azure login * Show/hide traditional * small bug fix to prevent multiple logins from being fired * Fixed login loop that occured when MS login failed. Also fixed issue where the roles and applications for newly created azure user was coming back undefined --------- Co-authored-by: yadhap Dahal <yadhap.dahal@lexisnexisrisk.com>
* Remove unused packages * Bug Fixes for left nav, constraints, and consumers
* Remove unused packages * Bug Fixes for left nav, constraints, and consumers * updates * Users Page and various docs updates * adjustments
* Fix user registration to not show success unless error message is shown and remove duplicate create basic user route * Set width of all components to 40rem for login for consistency * hide change password method for microsoft accounts
//add application to user object in local storage so user has immediate access to it | ||
const { user_app_id, id, title, description } = responseData; | ||
user.applications.push({ id: user_app_id, application: { id, title, description } }); | ||
await localStorage.setItem('user', JSON.stringify(user)); |
Check failure
Code scanning / CodeQL
Clear text storage of sensitive information High
a call to resetTempPassword
//remove it from users applications | ||
const user = JSON.parse(localStorage.getItem('user')); | ||
user.applications = user.applications.filter((app) => app.application.id !== app_id); | ||
localStorage.setItem('user', JSON.stringify(user)); |
Check failure
Code scanning / CodeQL
Clear text storage of sensitive information High
a call to resetTempPassword
Show autofix suggestion
Hide autofix suggestion
Copilot Autofix AI about 14 hours ago
To fix the problem, we need to ensure that any sensitive information stored in local storage is encrypted. We can use the crypto-js
library to encrypt and decrypt the data. The encryption key should be securely managed and not hardcoded in the code.
- Install the
crypto-js
library. - Import the necessary functions from
crypto-js
. - Encrypt the
user
object before storing it in local storage. - Decrypt the
user
object when retrieving it from local storage.
-
Copy modified line R10 -
Copy modified line R75 -
Copy modified line R77
@@ -9,3 +9,3 @@ | ||
import AddApplication from './AddApplication'; | ||
|
||
import CryptoJS from 'crypto-js'; | ||
import Text from '../../common/Text'; | ||
@@ -74,5 +74,5 @@ | ||
//remove it from users applications | ||
const user = JSON.parse(localStorage.getItem('user')); | ||
const user = JSON.parse(CryptoJS.AES.decrypt(localStorage.getItem('user'), 'encryption_key').toString(CryptoJS.enc.Utf8)); | ||
user.applications = user.applications.filter((app) => app.application.id !== app_id); | ||
localStorage.setItem('user', JSON.stringify(user)); | ||
localStorage.setItem('user', CryptoJS.AES.encrypt(JSON.stringify(user), 'encryption_key').toString()); | ||
|
-
Copy modified line R5 -
Copy modified line R39
@@ -4,3 +4,3 @@ | ||
import passwordComplexityValidator from '../common/passwordComplexityValidator'; | ||
|
||
import CryptoJS from 'crypto-js'; | ||
function ResetTempPassword() { | ||
@@ -38,3 +38,3 @@ | ||
// Save user token to local storage | ||
localStorage.setItem('user', JSON.stringify(result.data)); | ||
localStorage.setItem('user', CryptoJS.AES.encrypt(JSON.stringify(result.data), 'encryption_key').toString()); | ||
window.location.href = '/'; |
-
Copy modified lines R31-R32
@@ -30,3 +30,4 @@ | ||
"socket.io-client": "^4.1.3", | ||
"validator": "^13.11.0" | ||
"validator": "^13.11.0", | ||
"crypto-js": "^4.2.0" | ||
}, |
Package | Version | Security advisories |
crypto-js (npm) | 4.2.0 | None |
const oldUser = JSON.parse(localStorage.getItem('user')); | ||
const newUser = { ...oldUser, firstName: response.data.firstName, lastName: response.data.lastName }; | ||
|
||
localStorage.setItem('user', JSON.stringify(newUser)); |
Check failure
Code scanning / CodeQL
Clear text storage of sensitive information High
a call to resetTempPassword
Show autofix suggestion
Hide autofix suggestion
Copilot Autofix AI about 14 hours ago
To fix the problem, we need to ensure that any sensitive information stored in localStorage
is encrypted. We can use the crypto-js
library to encrypt and decrypt the data before storing and retrieving it from localStorage
.
- Install the
crypto-js
library. - Import the necessary functions from
crypto-js
. - Encrypt the user data before storing it in
localStorage
. - Decrypt the user data when retrieving it from
localStorage
.
-
Copy modified line R2 -
Copy modified lines R46-R47 -
Copy modified lines R50-R51
@@ -1,2 +1,3 @@ | ||
import React, { useState, useEffect } from 'react'; | ||
import CryptoJS from 'crypto-js'; | ||
import { Card, Form, Row, Col, Input, Button, Spin, message } from 'antd'; | ||
@@ -44,6 +45,8 @@ | ||
|
||
const oldUser = JSON.parse(localStorage.getItem('user')); | ||
const encryptedOldUser = localStorage.getItem('user'); | ||
const oldUser = encryptedOldUser ? JSON.parse(CryptoJS.AES.decrypt(encryptedOldUser, 'secret-key').toString(CryptoJS.enc.Utf8)) : {}; | ||
const newUser = { ...oldUser, firstName: response.data.firstName, lastName: response.data.lastName }; | ||
|
||
localStorage.setItem('user', JSON.stringify(newUser)); | ||
const encryptedNewUser = CryptoJS.AES.encrypt(JSON.stringify(newUser), 'secret-key').toString(); | ||
localStorage.setItem('user', encryptedNewUser); | ||
window.dispatchEvent(new Event('userStorage')); |
-
Copy modified line R2 -
Copy modified lines R40-R41
@@ -1,2 +1,3 @@ | ||
import React, { useState, useEffect } from 'react'; | ||
import CryptoJS from 'crypto-js'; | ||
import { Form, Input, Button, Spin, message, Popover } from 'antd'; | ||
@@ -38,3 +39,4 @@ | ||
// Save user token to local storage | ||
localStorage.setItem('user', JSON.stringify(result.data)); | ||
const encryptedUser = CryptoJS.AES.encrypt(JSON.stringify(result.data), 'secret-key').toString(); | ||
localStorage.setItem('user', encryptedUser); | ||
window.location.href = '/'; |
-
Copy modified lines R31-R32
@@ -30,3 +30,4 @@ | ||
"socket.io-client": "^4.1.3", | ||
"validator": "^13.11.0" | ||
"validator": "^13.11.0", | ||
"crypto-js": "^4.2.0" | ||
}, |
Package | Version | Security advisories |
crypto-js (npm) | 4.2.0 | None |
if (!user) return; | ||
if (user?.token !== token) { | ||
user.token = token; | ||
await localStorage.setItem('user', JSON.stringify(user)); |
Check failure
Code scanning / CodeQL
Clear text storage of sensitive information High
a call to resetTempPassword
Copilot Autofix AI about 14 hours ago
Copilot could not generate an autofix suggestion
Copilot could not generate an autofix suggestion for this alert. Try pushing a new commit or if the problem persists contact support.
const result = await resetTempPassword(values); | ||
|
||
// Save user token to local storage | ||
localStorage.setItem('user', JSON.stringify(result.data)); |
Check failure
Code scanning / CodeQL
Clear text storage of sensitive information High
a call to resetTempPassword
Show autofix suggestion
Hide autofix suggestion
Copilot Autofix AI about 14 hours ago
To fix the problem, we need to ensure that any sensitive information stored in local storage is encrypted. We can use the crypto-js
library to encrypt the data before storing it and decrypt it when needed. This will protect the data from being easily accessed in plain text.
- Install the
crypto-js
library. - Import the necessary functions from
crypto-js
. - Encrypt the data before storing it in local storage.
- Decrypt the data when retrieving it from local storage.
-
Copy modified line R5 -
Copy modified lines R40-R41
@@ -4,2 +4,3 @@ | ||
import passwordComplexityValidator from '../common/passwordComplexityValidator'; | ||
import CryptoJS from 'crypto-js'; | ||
|
||
@@ -38,3 +39,4 @@ | ||
// Save user token to local storage | ||
localStorage.setItem('user', JSON.stringify(result.data)); | ||
const encryptedData = CryptoJS.AES.encrypt(JSON.stringify(result.data), 'secret-key').toString(); | ||
localStorage.setItem('user', encryptedData); | ||
window.location.href = '/'; |
-
Copy modified lines R31-R32
@@ -30,3 +30,4 @@ | ||
"socket.io-client": "^4.1.3", | ||
"validator": "^13.11.0" | ||
"validator": "^13.11.0", | ||
"crypto-js": "^4.2.0" | ||
}, |
Package | Version | Security advisories |
crypto-js (npm) | 4.2.0 | None |
Description
Please include a summary of the change and which issue is fixed. Please also include relevant motivation and context. List any dependencies that are required for this change.
Fixes # (issue)
Type of change
Developer Checklist:
Reviewer Checklist