[keycloak-dev] Add custom REST paths? New SPI?
Pedro Igor Silva
psilva at redhat.com
Mon Dec 7 10:03:04 EST 2015
I've done something at this regard, where you can use a SPI in order to plug additional APIs for:
* Realm Admin RESTFul API (eg.: used by admin console)
* Realm RESFTFul API (eg.: to plug additional endpoints for realms)
The two Provider interfaces are very simple and just provide a single method:
Object getResource(String pathName);
Where pathName is the path that must be resolved to your custom JAX-RS resource.
The factories are also very simple and allows you to build those resources for the current Realm and KeycloakSession. Eg.:
RealmResourceProvider create(RealmModel realm, KeycloakSession keycloakSession);
Do you need something other than that ?
Regards.
Pedro Igor
----- Original Message -----
From: "Erik Mulder" <erik.mulder at docdatapayments.com>
To: keycloak-dev at lists.jboss.org
Sent: Monday, December 7, 2015 12:46:39 PM
Subject: [keycloak-dev] Add custom REST paths? New SPI?
As some of you might know, our team is busy adding data to the keycloak
system to incorporate some custom authorization information in the
access token.
So far we've successfully extended the JPA entities, Liquibase table
definitions and added a custom mapper to put that data in the access
token. All of this without custom modifications to the original keycloak
sources. This is working great, thanks for the support so far!
I know I've promised some PR's for this and they will come, but first
we'd like to get everything fully working, so we know it's a well
functioning whole.
The last piece of the puzzle is extending the REST services to include
CRUD actions for our custom resources. I've been looking into the way
RESTEasy/JAX-RS works and it seems to me that in the current
implementation there is no way to add extra paths. As I see it now, the
KeycloakApplication class will register some singletons in it's
constructor and that's that. No way to extend or to 'interfere' there.
So my question is: is there any 'official' way to add extra REST paths
to Keycloak?
If not, is it an idea to add this as a new SPI? The current code for
adding root paths in the KeycloakApplication constructor lists:
singletons.add(new ServerVersionResource());
singletons.add(new RealmsResource());
singletons.add(new AdminRoot());
So just plain contructor calls. That seems like an easy target for
'SPI-ing' :-).
Or just leave the current ones 'hardcoded' and add an SPI for custom
extensions.
Your thoughts on this please.
As before, I'm happy to implement this myself, but I'd like to discuss
it first, so a future PR will be honored.
_______________________________________________
keycloak-dev mailing list
keycloak-dev at lists.jboss.org
https://lists.jboss.org/mailman/listinfo/keycloak-dev
More information about the keycloak-dev
mailing list