Open johnfg2610 opened 6 years ago
Yes, this application shows how to use keycloak roles with the annotation: https://github.com/FroMage/redpipe/tree/master/redpipe-example-wiki-keycloak-jooq
Did you follow this example?
http://redpipe.net/#authentication also has info.
Also, my JWT for vertx 3.5.0 does not have the right line-info, so I assume you're running 3.5.1?
I followed http://redpipe.net/#authentication and yes I am running 3.5.1 is there anything else I need to do?
override fun setupRoutes(router: Router) {
//good solution to loading resources from the web root folder
router.route("/webroot/*").handler(StaticHandler.create().setCachingEnabled(true))
super.setupRoutes(router)
}
override fun setupAuthenticationRoutes(): AuthProvider {
val keycloackConfig = AppGlobals.get().config.getJsonObject("keycloack")
val authWeb = KeycloakAuth.create(AppGlobals.get().vertx, keycloackConfig)
val authApi = KeycloakAuth.create(AppGlobals.get().vertx, OAuth2FlowType.PASSWORD, keycloackConfig)
// FIXME: URL
val authHandler = OAuth2AuthHandler.create(authWeb as OAuth2Auth, "http://localhost:9000/callback")
val router = AppGlobals.get().router
// FIXME: crazy!!
val authProvider = AuthProvider.newInstance(authWeb.getDelegate())
router.route().handler(UserSessionHandler.create(authProvider))
authHandler.setupCallback(router.get("/callback"))
val jwtAuth = JWTAuth.create(AppGlobals.get().vertx,
JWTAuthOptions(
JWTOptions(
JsonObject().put("keyStore", AppGlobals.get().config.getJsonObject("keystore")))))
AppGlobals.get().setGlobal(JWTAuth::class.java, jwtAuth)
val jwtAuthHandler = JWTAuthHandler.create(jwtAuth, "/wiki/api/token")
// FIXME: just use different routers
router.route().handler { ctx ->
if (!ctx.request().uri().startsWith("/wiki/api/"))
authHandler.handle(ctx)
else
jwtAuthHandler.handle(ctx)
}
return AuthProvider.newInstance(authApi.delegate)
}
this is all the code from the overriden server instance(its kotlin)
So I tried with vertx 3.5.1 and it works here. This is with keycloack 3.3.0.CR2 and 3.3.0.Final. What version of keycloak did you try?
Also, what does your conf/config.json
look like?
i have keycloak 4.0.0.beta1(il try downgrading shortly it may be that) my config.json
{
"scan": ["io.github.johnfg10"],
"keycloack":{
"realm": "jtube",
"auth-server-url": "http://localhost:8081/auth",
"ssl-required": "external",
"resource": "jtube",
"credentials": {
"secret": "3******f-8e*a-*c1f-a*02-****f3ab78**"
},
"use-resource-role-mappings": true,
"confidential-port": 0,
"policy-enforcer": {}
}
}
sorry it took a few days ive been a little bit busy but ive downgraded to 3.4.3-final that also doesnt work. i have just tested 3.3.0.final and il upload the settings i have on keycloak
So I have the following settings different:
Consent required: off Direct Access Grants Enabled: on Service Accounts Enabled: off Authorization enabled: off Valid redirect URIs: http://localhost:9000/callback/*
The rest are the same.
ive tried with the same settings and am still encountering the same errors
Hey, I have been testing out redpipe the last day or so and have set it up with keycloack is there any way to make it use keycloack roles with the RequiresPermissions annotation? maybe related to this error im receiving:
Thanks, John