added stackIdExtractor for cloud mode

Co-Authored-By: Gabriel MABILLE <gamab@users.noreply.github.com>
This commit is contained in:
Claudiu Dragalina-Paraipan 2024-09-03 10:39:11 +03:00
parent 84866a8a51
commit bb5ee88d4f

View File

@ -86,7 +86,7 @@ func NewResourceStoreClientCloud(conn *grpc.ClientConn, cfg *setting.Cfg) (Resou
opts := []authnlib.GrpcClientInterceptorOption{
authnlib.WithIDTokenExtractorOption(idTokenExtractor),
authnlib.WithMetadataExtractorOption(orgIdExtractor),
authnlib.WithMetadataExtractorOption(stackIdExtractor(cfg.StackID)),
}
if cfg.Env == setting.Dev {
@ -137,3 +137,9 @@ func orgIdExtractor(ctx context.Context) (key string, values []string, err error
return authzlib.DefaultStackIDMetadataKey, []string{fmt.Sprintf("%d", requester.GetOrgID())}, nil
}
func stackIdExtractor(stackID string) func(ctx context.Context) (key string, values []string, err error) {
return func(ctx context.Context) (key string, values []string, err error) {
return authzlib.DefaultStackIDMetadataKey, []string{stackID}, nil
}
}