[RAINCATCH-1276] Update documentation and example to include JWT strategy #141
Conversation
@JameelB We will need to review existing passport docs to include that as well. |
cloud/passportauth/README.md
Outdated
@@ -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. |
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.
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) { |
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.
💯
Changes Unknown when pulling 016acdb on JameelB:RAINCATCH-1276 into ** on feedhenry-raincatcher:master**. |
1 similar comment
Changes Unknown when pulling 016acdb on JameelB:RAINCATCH-1276 into ** on feedhenry-raincatcher:master**. |
cloud/passportauth/example/index.ts
Outdated
const secret = 'demo_secret'; | ||
tokenAuthService.init(tokenRouter, undefined, secret); | ||
|
||
tokenRouter.get('/token-login', (req: express.Request, res: express.Response) => { |
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.
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.
Changes Unknown when pulling 1d25177 on JameelB:RAINCATCH-1276 into ** on feedhenry-raincatcher:master**. |
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
Additional Notes
Related JIRA - https://issues.jboss.org/browse/RAINCATCH-1276