[keycloak-user] Custom REST endpoint not associated with a specific REALM

Łukasz Dywicki luke at code-house.org
Tue Jun 4 05:15:12 EDT 2019


Hey Michalel,
Based on my earlier experiences I can tell you that
RealmResourceProvider SPI which you used does not distinguish realm
resources and realms they will be actually pulled in.
Its worth to remember that when RealmResourceProvider returns a null
instead of valid resource object HTTP request will end up with 404 code.

You need to combine both KeycloakContext [1] and configuration mechanism
[2] to achieve final result.
First will let you obtain current realm via getRealm method while second
will bring flexibility through init(Scope) method call.

For example if your config parameter is called LIID:
  @Override
  public void init(Scope config) {
     config.get("LIID", "some-fallback-value");
  }

This is all pseudo code, but I'm sure you will be able to find your way.

[1]:
https://github.com/keycloak/keycloak/blob/6.0.1/server-spi/src/main/java/org/keycloak/models/KeycloakContext.java
[2]:
https://github.com/keycloak/keycloak-documentation/blob/6.0.1/server_installation/topics/config-subsystem/configure-spi-providers.adoc


Cheers,
Łukasz
--
Code-House http://code-house.org


On 30.05.2019 19:45, Michael Dailous wrote:
> Hi,
> 
> We are looking to implement a REST endpoint that will be used to query the REALM information associated with a specified user. The REST endpoint will be publicly available and used as part of the Authentication process, identifying which Keycloak REALM should be used during the client authentication process. We've created REST endpoints that are available through a REALM, such as "/auth/realms/master/admin-extensions/...". Those specific REALMs are accessed post authentication. For this REST endpoint, we're looking to access it generically pre authentication.
> Is it possible to create a custom REST endpoint that's not associated with a specific REALM?
> 
> Thanks,
> Michael
> _______________________________________________
> keycloak-user mailing list
> keycloak-user at lists.jboss.org
> https://lists.jboss.org/mailman/listinfo/keycloak-user
> 


More information about the keycloak-user mailing list