Our great sponsors
-
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 https://github.com/czetsuyatech/ct-keycloak-iam. This project downloads a specific version of the Keycloak server and builds customizations such as theme, provider, realm, and more.
-
@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 https://jwt.io 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.
-
https://github.com/czetsuyatech/ct-multi-tenant-keycloak-spring (sponsors only)
-
@Bean public RouteLocator gatewayRouter(RouteLocatorBuilder builder, TokenRelayGatewayFilterFactory filterFactory) { return builder.routes() .route(p -> p.path("/test") .uri("http://httpbin.org")) .route("users", p -> p.path("/users/**") .filters(f -> f.filter(filterFactory.apply())) .uri("http://localhost:8001")) .build(); }