I'm using TenantConfigResolver
to set the tenantId dynamically
@ApplicationScoped
public class PartitionTenantResolver implements TenantConfigResolver {
@Override
public Uni<OidcTenantConfig> resolve(RoutingContext routingContext, OidcRequestContext<OidcTenantConfig> requestContext) {
String dataPartitionId = routingContext.request().getHeader(DATA_PARTITION_ID);
String keycloakUrl = ConfigProvider.getConfig().getValue("openid.provider.base-url", String.class);
String clientId = ConfigProvider.getConfig().getValue("openid.provider.client-id", String.class);
String secret = ConfigProvider.getConfig().getValue("openid.provider.secret", String.class);
if (StringUtils.isNotEmpty(dataPartitionId)) {
OidcTenantConfig config = new OidcTenantConfig();
config.setAuthServerUrl(keycloakUrl + "/realms/" + dataPartitionId);
config.setTenantId(dataPartitionId);
config.setClientId(clientId);
config.getCredentials().setSecret(secret);
config.setApplicationType(OidcTenantConfig.ApplicationType.SERVICE);
return Uni.createFrom().item(config);
}
return Uni.createFrom().nullItem();
}
}
This is work when using httpc request. How can I use the same strategy to extract tenantId from grpc call metadata in case of grpc service call?
I'm using TenantConfigResolver
to set the tenantId dynamically
@ApplicationScoped
public class PartitionTenantResolver implements TenantConfigResolver {
@Override
public Uni<OidcTenantConfig> resolve(RoutingContext routingContext, OidcRequestContext<OidcTenantConfig> requestContext) {
String dataPartitionId = routingContext.request().getHeader(DATA_PARTITION_ID);
String keycloakUrl = ConfigProvider.getConfig().getValue("openid.provider.base-url", String.class);
String clientId = ConfigProvider.getConfig().getValue("openid.provider.client-id", String.class);
String secret = ConfigProvider.getConfig().getValue("openid.provider.secret", String.class);
if (StringUtils.isNotEmpty(dataPartitionId)) {
OidcTenantConfig config = new OidcTenantConfig();
config.setAuthServerUrl(keycloakUrl + "/realms/" + dataPartitionId);
config.setTenantId(dataPartitionId);
config.setClientId(clientId);
config.getCredentials().setSecret(secret);
config.setApplicationType(OidcTenantConfig.ApplicationType.SERVICE);
return Uni.createFrom().item(config);
}
return Uni.createFrom().nullItem();
}
}
This is work when using httpc request. How can I use the same strategy to extract tenantId from grpc call metadata in case of grpc service call?
Share Improve this question asked Feb 6 at 9:26 Bd GhnBd Ghn 31 bronze badge1 Answer
Reset to default 0When you set quarkus.grpc.server.use-separate-server=false
, Quarkus supports multiple authentication mechanisms as documented here https://quarkus.io/guides/grpc-service-implementation#overview-of-supported-authentication-mechanisms. In regards to your TenantConfigResolver
bean, gRPC is build on top of HTTP/2, therefore you don't need to (almost) change anything on your resolver. It should work out of the box. gRPC metadata are implemented using HTTP/2 headers, so try inspecting your headers.