how can we have auth middleware to authorized each an every request #7170
Replies: 5 comments
|
Hey @shendkardevesh. Also some of the strategies let you specify header fields to get credentials from on each request. For example: import { Strategy as JWTStrategy, ExtractJwt } from 'passport-jwt';
export class HttpAuthStrategyProvider implements Provider<Strategy | undefined> {
constructor(
@inject(RestBindings.Http.REQUEST) private request: Request,
// ... DEDUCTED
) {
this.verifyBasic = this.verifyBasic.bind(this);
}
value(): ValueOrPromise<Strategy | undefined> {
if (!this.metadata) {
return undefined;
}
const name = this.metadata.strategy;
if (name === 'JWTStrategy') {
return new JWTStrategy({
secretOrKey: this.configuration.secrets.jwtSecret,
jwtFromRequest: ExtractJwt.fromHeader('SOME_HEADER_NAME') // Here extract from headers
}, this.verifyCallback);
} else {
return Promise.reject(`Strategy ${name} is not defined`);
}
}
// .... DEDUCTED
} |
|
Thanks @osmanmesutozcan , i was trying to achieve the above JWTStrategy stuff few days back and was stuck. |
|
Discussion with @raymondfeng @jannyHou @emonddr: A few pointers:
|
|
This issue has been marked stale because it has not seen activity within six months. If you believe this to be in error, please contact one of the code owners, listed in the |
|
This issue has been marked stale because it has not seen activity within six months. If you believe this to be in error, please contact one of the code owners, listed in the |
Uh oh!
There was an error while loading. Please reload this page.
in current example of authentication verify function username and password is pass as an arguments but for every request it wou't be the case and how can we access header data in auth-strategy.provider.
All reactions