-
Notifications
You must be signed in to change notification settings - Fork 1.5k
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
feature/auth : added a back link to the strategy name in the token (future use for instance refreshToken) #571
Merged
Merged
Changes from 29 commits
Commits
Show all changes
31 commits
Select commit
Hold shift + click to select a range
cef7a1d
Added password grant_type option
alain-charles 9f0dbab
Added password grant_type option implementation
alain-charles 44d7d2e
Playground sample for oAuth2 password grant-type
alain-charles f57b737
Added route to oAuth2 password grant-type sample
alain-charles ed4628e
Addes angular-jwt for decoding jwt token (used in playground only)
alain-charles d7f01df
Added /api/auth/token endpoint (oAuth2 password grant-type playground)
alain-charles af52e88
Patched code for passing ci
alain-charles 554f7dc
code optimization for passing ci
alain-charles fa0548f
Merge branch 'master' into master
nnixaa b72adae
Changes request by Dmitry (first review)
alain-charles 733efc0
Generalized code in oauth2-strategy
alain-charles 57fab69
Merge remote-tracking branch 'origin/master'
alain-charles c50df3a
Generalized code in oauth2-strategy
alain-charles dda5436
Added unit tests for oAuth-strategy password authentication
alain-charles ef0be25
Merge branch 'master' into master
alain-charles e180dc3
Merge branch 'master' into master
nnixaa 6aa1fdb
Cleaned code according to nnixaa second review
alain-charles 96c7344
Merge branch 'master' of https://github.com/alain-charles/nebular
alain-charles cf82c42
Removed package-lock.json from git repo
alain-charles dcff930
package-lock.json to revert
alain-charles 315662f
reverted package-lock.json
alain-charles 57a0230
Added new grant_type 'PASSWORD' in the block comment for it to be ins…
alain-charles d69d633
Merge remote-tracking branch 'upstream/master'
alain-charles 1be8d91
Add the refreshtoken request management in NbJwtInterceptor and NbAut…
alain-charles 4b67825
Merge branch 'master' of https://github.com/alain-charles/nebular
alain-charles deea3e2
Merge branch 'master' into temp
alain-charles acd0241
The token now contains ownerStrategyName, with is a back link to the …
alain-charles 25250f0
feature/auth:
alain-charles c0fdd31
feature/auth:
alain-charles bd564b3
feature/auth:
alain-charles 44ed61a
Merge branch 'master' into master
nnixaa File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -4,6 +4,8 @@ export abstract class NbAuthToken { | |
abstract getValue(): string; | ||
abstract isValid(): boolean; | ||
abstract getPayload(): string; | ||
// the strategy name used to acquire this token (needed for refreshing token) | ||
abstract getOwnerStrategyName(): string; | ||
abstract toString(): string; | ||
|
||
getName(): string { | ||
|
@@ -17,11 +19,18 @@ export interface NbAuthRefreshableToken { | |
|
||
export interface NbAuthTokenClass { | ||
NAME: string; | ||
new (raw: any): NbAuthToken; | ||
new (raw: any, ownerStrategyName: string): NbAuthToken; | ||
} | ||
|
||
export function nbAuthCreateToken(tokenClass: NbAuthTokenClass, token: any) { | ||
return new tokenClass(token); | ||
// All types of token are not refreshables | ||
export function isNbAuthRefreshableToken(token: any): token is NbAuthRefreshableToken { | ||
return (<NbAuthRefreshableToken>token).getRefreshToken !== undefined ; | ||
} | ||
|
||
export function nbAuthCreateToken(tokenClass: NbAuthTokenClass, | ||
token: any, | ||
ownerStrategyName: string) { | ||
return new tokenClass(token, ownerStrategyName); | ||
} | ||
|
||
/** | ||
|
@@ -31,7 +40,8 @@ export class NbAuthSimpleToken extends NbAuthToken { | |
|
||
static NAME = 'nb:auth:simple:token'; | ||
|
||
constructor(protected readonly token: any) { | ||
constructor(protected readonly token: any, | ||
protected readonly ownerStrategyName: string) { | ||
super(); | ||
} | ||
|
||
|
@@ -43,6 +53,10 @@ export class NbAuthSimpleToken extends NbAuthToken { | |
return this.token; | ||
} | ||
|
||
getOwnerStrategyName(): string { | ||
return this.ownerStrategyName; | ||
} | ||
|
||
getPayload(): string { | ||
return null; | ||
} | ||
|
@@ -142,9 +156,11 @@ export class NbAuthOAuth2Token extends NbAuthSimpleToken { | |
|
||
static NAME = 'nb:auth:oauth2:token'; | ||
|
||
constructor(protected data: { [key: string]: string|number }|string = {}) { | ||
constructor(protected data: { [key: string]: string|number }|string = {}, | ||
protected ownerStrategyName: string) { | ||
// we may get it as string when retrieving from a storage | ||
super(prepareOAuth2Token(data)); | ||
super(prepareOAuth2Token(data), ownerStrategyName); | ||
this.ownerStrategyName = ownerStrategyName; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. why to assign it here again as it will be assigned in There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. right again |
||
} | ||
|
||
/** | ||
|
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
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I guess this is not a part of this PR, isn't it?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
you're right. Part of the next next next :)