-
Notifications
You must be signed in to change notification settings - Fork 1.1k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Signed-off-by: jannyHou <[email protected]>
- Loading branch information
Showing
8 changed files
with
66 additions
and
62 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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -54,7 +54,7 @@ describe('jwt authentication', () => { | |
it(`user login and token granted successfully`, async () => { | ||
const credentials = {email: '[email protected]', password: 'opensesame'}; | ||
const res = await client | ||
.post('/users/refresh/login') | ||
.post('/users/refresh-token') | ||
.send(credentials) | ||
.expect(200); | ||
refreshToken = res.body.refreshToken; | ||
|
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
17 changes: 9 additions & 8 deletions
17
extensions/authentication-jwt/src/services/refreshtoken.service.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
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,45 @@ | ||
// Copyright IBM Corp. 2020. All Rights Reserved. | ||
// Node module: @loopback/authentication-jwt | ||
// This file is licensed under the MIT License. | ||
// License text available at https://opensource.org/licenses/MIT | ||
|
||
import {UserProfile} from '@loopback/security'; | ||
|
||
export type RefreshGrant = { | ||
refreshToken: string; | ||
}; | ||
|
||
export const RefreshGrantSchema = { | ||
type: 'object', | ||
required: ['refreshToken'], | ||
properties: { | ||
refreshToken: { | ||
type: 'string', | ||
}, | ||
}, | ||
}; | ||
export const RefreshGrantRequestBody = { | ||
description: 'Reissuing Acess Token', | ||
required: true, | ||
content: { | ||
'application/json': {schema: RefreshGrantSchema}, | ||
}, | ||
}; | ||
|
||
export type TokenObject = { | ||
accessToken: string; | ||
expiresIn?: string | undefined; | ||
refreshToken?: string | undefined; | ||
}; | ||
|
||
export interface RefreshTokenService { | ||
/** | ||
* Generate Token and return the Token Object | ||
*/ | ||
generateToken(userProfile: UserProfile, token: string): Promise<TokenObject>; | ||
/** | ||
* Verifies the validity of a token string and returns a new Token | ||
* | ||
*/ | ||
refreshToken(refreshToken: string): Promise<TokenObject>; | ||
} |
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