Fixing authentication guard

This commit is contained in:
Zoe Roux 2021-05-09 02:38:38 +02:00
parent 6802bc11e6
commit d3a860fa8f
5 changed files with 8 additions and 3 deletions

View File

@ -34,7 +34,7 @@ export function loadConfig(oidcConfigService: OidcConfigService): () => Promise<
clientId: "kyoo.webapp",
responseType: "code",
triggerAuthorizationResultEvent: false,
scope: "openid profile offline_access",
scope: "openid profile offline_access kyoo.read kyoo.write kyoo.play kyoo.admin",
silentRenew: true,
silentRenewUrl: "/silent.html",
useRefreshToken: true,

View File

@ -18,11 +18,12 @@ export class AuthService
{
if (x == null)
return;
console.log(x);
this.account = {
email: x.email,
username: x.username,
picture: x.picture,
permissions: x.permissions.split(",")
permissions: x.permissions?.split(",") ?? []
};
});
}

View File

@ -7,7 +7,7 @@ import { AuthService } from "../auth.service";
export class AuthGuard
{
public static guards: any[] = [];
public static defaultPermissions: string[];
public static defaultPermissions: string[] = undefined;
public static permissionsObservable: Observable<string[]>;
static forPermissions(...permissions: string[]): any

View File

@ -18,9 +18,12 @@ export class AuthorizerInterceptor implements HttpInterceptor
intercept(request: HttpRequest<any>, next: HttpHandler): Observable<HttpEvent<any>>
{
if (request.url.startsWith("http"))
return next.handle(request);
if (this.oidcSecurity === undefined)
this.oidcSecurity = this.injector.get(OidcSecurityService);
const token: string = this.oidcSecurity.getToken();
console.log(request.url, token);
if (token)
request = request.clone({setHeaders: {Authorization: "Bearer " + token}});
return next.handle(request);

1
static/more.svg Normal file
View File

@ -0,0 +1 @@
<svg xmlns="http://www.w3.org/2000/svg" height="24" viewBox="0 0 24 24" width="24"><path d="M0 0h24v24H0z" fill="none"/><path d="M12 8c1.1 0 2-.9 2-2s-.9-2-2-2-2 .9-2 2 .9 2 2 2zm0 2c-1.1 0-2 .9-2 2s.9 2 2 2 2-.9 2-2-.9-2-2-2zm0 6c-1.1 0-2 .9-2 2s.9 2 2 2 2-.9 2-2-.9-2-2-2z" fill="#ffffff"/></svg>

After

Width:  |  Height:  |  Size: 298 B