Skip to content
This repository has been archived by the owner on Apr 17, 2023. It is now read-only.

[RAINCATCH-1276] Update documentation and example to include JWT strategy #141

Merged
merged 2 commits into from Oct 2, 2017

Conversation

JameelB
Copy link
Contributor

@JameelB JameelB commented Oct 2, 2017

Motivation

There is no documentation that covers token based authentication in PassportJS module. Our example does not cover this either. We need to provide information on how we use token based authentication.

Description

Update the documentation and the example to provide information on token based authentication and the JWT Strategy.

Progress

  • Update documentation
  • Update README file

Additional Notes

Related JIRA - https://issues.jboss.org/browse/RAINCATCH-1276

@wtrocki
Copy link
Member

wtrocki commented Oct 2, 2017

@JameelB We will need to review existing passport docs to include that as well.

@@ -19,19 +18,42 @@ const authService: PassportAuth = new PassportAuth(userRepo, userService);
authService.init(router, sessionOptions);
or
authService.init(router, undefined, secret);

...
```
In order to use cookie-based authentication, specify the sessionOptions.
- For more information about the available express session options, see [express-session](https://github.com/expressjs/session).

Without the sessionOptions, Passport will use token-based authentication using Passport's JWT strategy by default.
Copy link
Member

@wtrocki wtrocki Oct 2, 2017

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

When sessionOptions argument will not be passed/skipped/undefined

@@ -31,8 +31,12 @@ export class SampleUserService implements UserService {
return user.password === password;
}

public hasResourceRole(user: any, role: string) {
return user.roles.indexOf(role) > -1;
public hasResourceRole(user: any, role: string|undefined) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💯

@coveralls
Copy link

Coverage Status

Changes Unknown when pulling 016acdb on JameelB:RAINCATCH-1276 into ** on feedhenry-raincatcher:master**.

1 similar comment
@coveralls
Copy link

Coverage Status

Changes Unknown when pulling 016acdb on JameelB:RAINCATCH-1276 into ** on feedhenry-raincatcher:master**.

const secret = 'demo_secret';
tokenAuthService.init(tokenRouter, undefined, secret);

tokenRouter.get('/token-login', (req: express.Request, res: express.Response) => {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Missing comments. There are two ways for that.
You can have two servers one for cookie one for token.
Or just mention that this endpoints are going to work with JWT etc.

wtrocki
wtrocki previously approved these changes Oct 2, 2017
@coveralls
Copy link

coveralls commented Oct 2, 2017

Coverage Status

Changes Unknown when pulling 1d25177 on JameelB:RAINCATCH-1276 into ** on feedhenry-raincatcher:master**.

@JameelB JameelB merged commit 151cbc0 into feedhenry-raincatcher:master Oct 2, 2017
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants