-
Notifications
You must be signed in to change notification settings - Fork 72
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix(authentication-service): submission of encrypted password in auth…
…entication service. (#1593) * fix(authentication-service): submission of encrypted password in authentication service api submission of encrypted password in authentication service api GH-1592 * fix(authentication-service): submission of encrypted password in authentication service submission of encrypted password in authentication service GH-1592
- Loading branch information
1 parent
8492407
commit 3dcee5c
Showing
9 changed files
with
1,398 additions
and
282 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
1,561 changes: 1,306 additions & 255 deletions
1,561
services/authentication-service/package-lock.json
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
21 changes: 21 additions & 0 deletions
21
services/authentication-service/src/providers/password-decryption.provider.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
import {Provider} from '@loopback/core'; | ||
import {HttpErrors} from '@loopback/rest'; | ||
import {AuthErrorKeys} from 'loopback4-authentication'; | ||
import forge from 'node-forge'; | ||
import {PasswordDecryptionFn} from './types'; | ||
export class PasswordDecryptionProvider | ||
implements Provider<PasswordDecryptionFn> | ||
{ | ||
value(): PasswordDecryptionFn { | ||
return async (password: string) => { | ||
if (!process.env.PRIVATE_DECRYPTION_KEY) { | ||
throw new HttpErrors.Unauthorized(AuthErrorKeys.InvalidCredentials); | ||
} | ||
const privateKey = forge.pki.privateKeyFromPem( | ||
process.env.PRIVATE_DECRYPTION_KEY, | ||
); | ||
const decryptedPassword = privateKey.decrypt(password); | ||
return decryptedPassword; | ||
}; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters