-
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.
feat(authentication-service): implement 2-factor-authentication (#686)
* feat(authentication-service): implement 2-factor-authentication implemented otp strategy using loopback4-authentication package * feat(authentication-service): implement 2-factor-authentication gh-453 * fix(authentication-service): update error keys * fix(authentication-service): update version in package.json * fix(authentication-service): minor name fix * feat(authentication-service): implement otp and google authenticator strategies * feat(authentication-service): implement 2-factor-authentication Co-authored-by: akshatdubeysf <77672713+akshatdubeysf@users.noreply.github.com>
- Loading branch information
1 parent
b7689be
commit ea571ac
Showing
24 changed files
with
543 additions
and
10 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
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
33 changes: 33 additions & 0 deletions
33
services/authentication-service/src/models/otp-cache.model.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,33 @@ | ||
import {Entity, model, property} from '@loopback/repository'; | ||
|
||
@model() | ||
export class OtpCache extends Entity { | ||
@property({ | ||
type: 'string', | ||
}) | ||
otp?: string; | ||
|
||
@property({ | ||
type: 'string', | ||
}) | ||
userId?: string; | ||
|
||
@property({ | ||
type: 'string', | ||
}) | ||
otpSecret?: string; | ||
|
||
@property({ | ||
type: 'string', | ||
}) | ||
clientId: string; | ||
|
||
@property({ | ||
type: 'string', | ||
}) | ||
clientSecret: string; | ||
|
||
constructor(data?: Partial<OtpCache>) { | ||
super(data); | ||
} | ||
} |
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
25 changes: 25 additions & 0 deletions
25
services/authentication-service/src/modules/auth/models/otp-login-request.dto.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,25 @@ | ||
import {Model, model, property} from '@loopback/repository'; | ||
import {ModelPropertyDescriptionString} from './model-property-description.enum'; | ||
|
||
@model({ | ||
description: 'This is the signature for OTP login request.', | ||
}) | ||
export class OtpLoginRequest extends Model { | ||
@property({ | ||
type: 'string', | ||
description: ModelPropertyDescriptionString.reqStrPropDesc, | ||
required: true, | ||
}) | ||
key: string; | ||
|
||
@property({ | ||
type: 'string', | ||
description: ModelPropertyDescriptionString.reqStrPropDesc, | ||
required: true, | ||
}) | ||
otp: string; | ||
|
||
constructor(data?: Partial<OtpLoginRequest>) { | ||
super(data); | ||
} | ||
} |
34 changes: 34 additions & 0 deletions
34
services/authentication-service/src/modules/auth/models/otp-send-request.dto.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,34 @@ | ||
import {Model, model, property} from '@loopback/repository'; | ||
import {ModelPropertyDescriptionString} from './model-property-description.enum'; | ||
|
||
@model({ | ||
description: 'This is the signature for OTP login request.', | ||
}) | ||
export class OtpSendRequest extends Model { | ||
@property({ | ||
type: 'string', | ||
description: ModelPropertyDescriptionString.reqStrPropDesc, | ||
required: true, | ||
}) | ||
// eslint-disable-next-line @typescript-eslint/naming-convention | ||
client_id: string; | ||
|
||
@property({ | ||
type: 'string', | ||
description: ModelPropertyDescriptionString.reqStrPropDesc, | ||
required: true, | ||
}) | ||
// eslint-disable-next-line @typescript-eslint/naming-convention | ||
client_secret: string; | ||
|
||
@property({ | ||
type: 'string', | ||
description: ModelPropertyDescriptionString.reqStrPropDesc, | ||
required: true, | ||
}) | ||
key: string; | ||
|
||
constructor(data?: Partial<OtpSendRequest>) { | ||
super(data); | ||
} | ||
} |
Oops, something went wrong.