From 7a2c406461b8898c42fd3eacc217ba3249ad3ef3 Mon Sep 17 00:00:00 2001 From: Daniel Gerhardt <code@dgerhardt.net> Date: Sun, 4 Aug 2019 19:11:04 +0200 Subject: [PATCH] Implement RFC 6750 instead of custom header for JWT RFC 6750: https://tools.ietf.org/html/rfc6750 Refs arsnova/arsnova-backend!144. --- src/app/interceptors/authentication.interceptor.ts | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src/app/interceptors/authentication.interceptor.ts b/src/app/interceptors/authentication.interceptor.ts index 8fddfefae..19a65bb06 100644 --- a/src/app/interceptors/authentication.interceptor.ts +++ b/src/app/interceptors/authentication.interceptor.ts @@ -14,7 +14,8 @@ import { NotificationService } from '../services/util/notification.service'; import { Router } from '@angular/router'; import { Observable } from 'rxjs'; -const AUTH_HEADER_KEY = 'Arsnova-Auth-Token'; +const AUTH_HEADER_KEY = 'Authorization'; +const AUTH_SCHEME = 'Bearer'; @Injectable() export class AuthenticationInterceptor implements HttpInterceptor { @@ -28,7 +29,7 @@ export class AuthenticationInterceptor implements HttpInterceptor { if (this.authenticationService.isLoggedIn()) { const token = this.authenticationService.getToken(); const cloned = req.clone({ - headers: req.headers.set(AUTH_HEADER_KEY, token) + headers: req.headers.set(AUTH_HEADER_KEY, `${AUTH_SCHEME} ${token}`) }); return next.handle(cloned).pipe(tap((event: HttpEvent<any>) => { -- GitLab