mirror of
https://github.com/andwati/zitadel.git
synced 2026-11-05 13:52:15 +00:00
* get auth policy, fix increment from 0 * seo, accessibility * ngsw rem check for update * organize interceptors * toast i18n part1 * show loginname * use primary color * toast login handler, fix user session type * Update console/src/assets/i18n/de.json Co-authored-by: Florian Forster <[email protected]> * Update console/src/assets/i18n/de.json Co-authored-by: Florian Forster <[email protected]> * Update console/src/assets/i18n/de.json Co-authored-by: Florian Forster <[email protected]> * Update console/src/assets/i18n/en.json Co-authored-by: Florian Forster <[email protected]> * Update console/src/index.html Co-authored-by: Florian Forster <[email protected]> * Update console/src/assets/i18n/en.json Co-authored-by: Florian Forster <[email protected]> * Update console/src/assets/i18n/en.json Co-authored-by: Florian Forster <[email protected]> Co-authored-by: Florian Forster <[email protected]>
31 lines
994 B
TypeScript
31 lines
994 B
TypeScript
import { Injectable } from '@angular/core';
|
|
import { Metadata } from 'grpc-web';
|
|
|
|
import { GrpcHandler } from '../grpc-handler';
|
|
import { StorageService } from '../storage.service';
|
|
import { GrpcInterceptor } from './grpc-interceptor';
|
|
|
|
const authorizationKey = 'Authorization';
|
|
const bearerPrefix = 'Bearer ';
|
|
const accessTokenStorageField = 'access_token';
|
|
|
|
@Injectable({ providedIn: 'root' })
|
|
export class GrpcAuthInterceptor implements GrpcInterceptor {
|
|
constructor(private readonly authStorage: StorageService) { }
|
|
|
|
public async intercept(
|
|
req: unknown,
|
|
metadata: Metadata,
|
|
next: GrpcHandler,
|
|
): Promise<any> {
|
|
if (!metadata[authorizationKey]) {
|
|
const accessToken = this.authStorage.getItem(accessTokenStorageField);
|
|
if (accessToken) {
|
|
metadata[authorizationKey] = bearerPrefix + accessToken;
|
|
}
|
|
}
|
|
|
|
return await next.handle(req, metadata);
|
|
}
|
|
}
|