-
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
Conversation
Now : If existing, NbAuthResult contains backend error description other Changes requested by Dmitry (first review)
Now : If existing, NbAuthResult contains backend error description other Changes requested by Dmitry (first review) +tslint missing trailing comma arghhh
…strategy used to create the token (future use)
The token now contains ownerStrategyName, with is a back link to the strategy used to create the token (future use). BREAKING CHANGE : NbAuthCreateToken (token.ts) now takes a third parameter, which is the ownerStrategyName Tokens are created by strategies that are called from services, so it is *potentially* a breaking change.
The token now contains ownerStrategyName, with is a back link to the strategy used to create the token (future use). updated unit tests files and oauth2-password-login.component (breaking change below) BREAKING CHANGE : NbAuthCreateToken (token.ts) now takes a third parameter, which is the ownerStrategyName Tokens are created by strategies that are called from services, so it is *potentially* a breaking change.
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.
a couple of comments, otherwise looks great!
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 { |
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 :)
// 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 comment
The reason will be displayed to describe this comment to others. Learn more.
why to assign it here again as it will be assigned in super
?
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.
right again
@@ -26,7 +26,7 @@ describe('password-auth-strategy', () => { | |||
}, | |||
}; | |||
|
|||
const successToken = nbAuthCreateToken(NbAuthSimpleToken, 'token'); | |||
const successToken = nbAuthCreateToken(NbAuthSimpleToken, 'token', 'strategy'); |
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.
let's move name of the strategy strategy
to a variable
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.
done ...
removed useless code and cleaned one unit test file BREAKING CHANGE : NbAuthCreateToken (token.ts) now takes a third parameter, which is the ownerStrategyName Tokens are created by strategies that are called from services, so it is *potentially* a breaking change.
@nnixaa it must be ok now. Please let me know if you agree with creating a NbAuthOAuth2JWTToken so that we have something symetric in token.ts and we can use in priority the payload 'iat' for createdAt and directly 'exp' for returning expiresAt. best regards Alain |
Hey @alain-charles, let's probably start with the |
The token now contains ownerStrategyName, which is a back link to the strategy
used to create the token (future use).
BREAKING CHANGE :
NbAuthCreateToken (token.ts) now takes a third parameter, which is the ownerStrategyName
Tokens are created by strategies that are called from services, so it is potentially a breaking change.