How to Configure Multitenancy in Keycloak with Spring API Gateway Integration

This page summarizes the projects mentioned and recommended in the original post on

Our great sponsors
  • SonarQube - Static code analysis for 29 languages.
  • InfluxDB - Access the most powerful time series database as a service
  • SaaSHub - Software Alternatives and Reviews
  • ct-keycloak-iam

    This project extends the Keycloak authentication server to cover complicated enterprise use cases such as multi-tenancy, custom storage, n-level resellers by extending Keycloak through its SPIs such as storage, authentication, and identity provider.

    For this exercise, we will use a custom Keycloak server from This project downloads a specific version of the Keycloak server and builds customizations such as theme, provider, realm, and more.

  • frank_jwt

    JSON Web Token implementation in Rust.

    @GetMapping("/user-info") public String userInfo() { return getUserInfo(); } @SuppressWarnings("unchecked") private String getUserInfo() { KeycloakAuthenticationToken authentication = (KeycloakAuthenticationToken) SecurityContextHolder.getContext() .getAuthentication(); final Principal principal = (Principal) authentication.getPrincipal(); String tokenInfo = null; if (principal instanceof KeycloakPrincipal) { KeycloakPrincipal kPrincipal = (KeycloakPrincipal) principal; KeycloakSecurityContext ksc = kPrincipal.getKeycloakSecurityContext(); IDToken token = ksc.getIdToken(); AccessToken accessToken = kPrincipal.getKeycloakSecurityContext().getToken(); tokenInfo = accessToken.getSubject(); // this value is the one use to call another service as bearer token // Authorization : Bearer kcs.getTokenString() // use this link to read the token return String.format("Hello %s %s [subject=%s]", accessToken.getGivenName(), accessToken.getFamilyName(), tokenInfo); } return "Hello World"; }

  • SonarQube

    Static code analysis for 29 languages.. Your projects are multi-language. So is SonarQube analysis. Find Bugs, Vulnerabilities, Security Hotspots, and Code Smells so you can release quality code every time. Get started analyzing your projects today for free.

  • (sponsors only)

  • httpbin

    HTTP Request & Response Service, written in Python + Flask.

    @Bean public RouteLocator gatewayRouter(RouteLocatorBuilder builder, TokenRelayGatewayFilterFactory filterFactory) {   return builder.routes()     .route(p -> p.path("/test")         .uri(""))     .route("users", p -> p.path("/users/**")         .filters(f -> f.filter(filterFactory.apply()))         .uri("http://localhost:8001"))     .build(); }

NOTE: The number of mentions on this list indicates mentions on common posts plus user suggested alternatives. Hence, a higher number means a more popular project.

Suggest a related project

Related posts