Skip to content
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 31 commits into from
Jul 23, 2018

Conversation

alain-charles
Copy link
Contributor

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.

alain-charles and others added 29 commits June 29, 2018 08:33
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.
Copy link
Collaborator

@nnixaa nnixaa left a 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 {
Copy link
Collaborator

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?

Copy link
Contributor Author

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;
Copy link
Collaborator

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?

Copy link
Contributor Author

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');
Copy link
Collaborator

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

Copy link
Contributor Author

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.
@alain-charles
Copy link
Contributor Author

alain-charles commented Jul 20, 2018

@nnixaa it must be ok now.
Preparing the next PR for createdAt and expiresAt of the tokens.

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

@nnixaa nnixaa merged commit 1c89636 into akveo:master Jul 23, 2018
@nnixaa
Copy link
Collaborator

nnixaa commented Jul 23, 2018

Hey @alain-charles, let's probably start with the createdAt property of a token, add it into the base token and then based on that create a new token?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants