Skip to content

Commit

Permalink
fix(jwt-auth-header): Initializing whitelisted domain for JWT in the …
Browse files Browse the repository at this point in the history
…proper way

Co-authored-by: Anil Kodi <[email protected]>
  • Loading branch information
mariol3 and AnilKumarKodi committed Jun 27, 2019
1 parent dff7ea5 commit db57012
Showing 1 changed file with 9 additions and 6 deletions.
15 changes: 9 additions & 6 deletions src/app/app.module.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,11 @@ export function getToken() {
return localStorage.getItem('access_token');
}

export function apiDomain() {
return new URL(environment.serviceUrl).hostname + ':' + new URL(environment.serviceUrl).port;
export function jwtOptionsFactory() {
return {
tokenGetter: getToken,
whitelistedDomains: [new URL(environment.serviceUrl).hostname + ':' + new URL(environment.serviceUrl).port]
}
}

@NgModule({
Expand All @@ -37,13 +40,13 @@ export function apiDomain() {
VoteModule,
LoginModule,
JwtModule.forRoot({
config: {
tokenGetter: getToken,
whitelistedDomains: [apiDomain()]
jwtOptionsProvider: {
provide: JWT_OPTIONS,
useFactory: jwtOptionsFactory
}
})
],
providers: [HttpErrorHandler, EventsService],
bootstrap: [AppComponent]
})
export class AppModule {}
export class AppModule { }

0 comments on commit db57012

Please sign in to comment.