mirror of
https://github.com/zoriya/Kyoo.git
synced 2025-07-08 02:34:16 -04:00
Fixing authentication guard
This commit is contained in:
parent
6802bc11e6
commit
d3a860fa8f
@ -34,7 +34,7 @@ export function loadConfig(oidcConfigService: OidcConfigService): () => Promise<
|
|||||||
clientId: "kyoo.webapp",
|
clientId: "kyoo.webapp",
|
||||||
responseType: "code",
|
responseType: "code",
|
||||||
triggerAuthorizationResultEvent: false,
|
triggerAuthorizationResultEvent: false,
|
||||||
scope: "openid profile offline_access",
|
scope: "openid profile offline_access kyoo.read kyoo.write kyoo.play kyoo.admin",
|
||||||
silentRenew: true,
|
silentRenew: true,
|
||||||
silentRenewUrl: "/silent.html",
|
silentRenewUrl: "/silent.html",
|
||||||
useRefreshToken: true,
|
useRefreshToken: true,
|
||||||
|
@ -18,11 +18,12 @@ export class AuthService
|
|||||||
{
|
{
|
||||||
if (x == null)
|
if (x == null)
|
||||||
return;
|
return;
|
||||||
|
console.log(x);
|
||||||
this.account = {
|
this.account = {
|
||||||
email: x.email,
|
email: x.email,
|
||||||
username: x.username,
|
username: x.username,
|
||||||
picture: x.picture,
|
picture: x.picture,
|
||||||
permissions: x.permissions.split(",")
|
permissions: x.permissions?.split(",") ?? []
|
||||||
};
|
};
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
@ -7,7 +7,7 @@ import { AuthService } from "../auth.service";
|
|||||||
export class AuthGuard
|
export class AuthGuard
|
||||||
{
|
{
|
||||||
public static guards: any[] = [];
|
public static guards: any[] = [];
|
||||||
public static defaultPermissions: string[];
|
public static defaultPermissions: string[] = undefined;
|
||||||
public static permissionsObservable: Observable<string[]>;
|
public static permissionsObservable: Observable<string[]>;
|
||||||
|
|
||||||
static forPermissions(...permissions: string[]): any
|
static forPermissions(...permissions: string[]): any
|
||||||
|
@ -18,9 +18,12 @@ export class AuthorizerInterceptor implements HttpInterceptor
|
|||||||
|
|
||||||
intercept(request: HttpRequest<any>, next: HttpHandler): Observable<HttpEvent<any>>
|
intercept(request: HttpRequest<any>, next: HttpHandler): Observable<HttpEvent<any>>
|
||||||
{
|
{
|
||||||
|
if (request.url.startsWith("http"))
|
||||||
|
return next.handle(request);
|
||||||
if (this.oidcSecurity === undefined)
|
if (this.oidcSecurity === undefined)
|
||||||
this.oidcSecurity = this.injector.get(OidcSecurityService);
|
this.oidcSecurity = this.injector.get(OidcSecurityService);
|
||||||
const token: string = this.oidcSecurity.getToken();
|
const token: string = this.oidcSecurity.getToken();
|
||||||
|
console.log(request.url, token);
|
||||||
if (token)
|
if (token)
|
||||||
request = request.clone({setHeaders: {Authorization: "Bearer " + token}});
|
request = request.clone({setHeaders: {Authorization: "Bearer " + token}});
|
||||||
return next.handle(request);
|
return next.handle(request);
|
||||||
|
1
static/more.svg
Normal file
1
static/more.svg
Normal 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 |
Loading…
x
Reference in New Issue
Block a user