mirror of
https://github.com/andwati/zitadel.git
synced 2026-11-14 09:55:12 +00:00
feat(console): grpc web interceptors, cleanup services (#631)
* managementservice, authservice, change all refs * refactor grpc auth * fix references * interceptor logic * new interceptor * appinitializers, environment loader, interceptors * remove circular dep * init authconfig in grpc service * authconfig * lint * update mgmt service * fix references * update clientid, fix interceptor * rm unused authconfig * todo auth interceptor
This commit is contained in:
@@ -0,0 +1,26 @@
|
||||
import { Injectable } from '@angular/core';
|
||||
import { Request, UnaryInterceptor, UnaryResponse } from 'grpc-web';
|
||||
import { Org } from 'src/app/proto/generated/auth_pb';
|
||||
|
||||
import { StorageService } from '../storage.service';
|
||||
|
||||
|
||||
const orgKey = 'x-zitadel-orgid';
|
||||
@Injectable({ providedIn: 'root' })
|
||||
export class OrgInterceptor<TReq = unknown, TResp = unknown> implements UnaryInterceptor<TReq, TResp> {
|
||||
constructor(private readonly storageService: StorageService) { }
|
||||
|
||||
public intercept(request: Request<TReq, TResp>, invoker: any): Promise<UnaryResponse<TReq, TResp>> {
|
||||
const metadata = request.getMetadata();
|
||||
|
||||
const org: Org.AsObject | null = (this.storageService.getItem('organization'));
|
||||
|
||||
if (org) {
|
||||
metadata[orgKey] = `${org.id}`;
|
||||
}
|
||||
|
||||
return invoker(request).then((response: any) => {
|
||||
return response;
|
||||
});
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user