Reputation: 127
I try to add springdoc-openapi-ui
and camel-springdoc-starter
. Works not so bad.
For now i've trouble with the context path '/camel'
and with the missing securitySchemes
.
Does anyone have an idea how to do this
How do i get such a configuration?
{
"openapi": "3.0.1",
"info": {
"title": "some title",
"version": "0.8.15-SNAPSHOT"
},
"servers": [
{
"url": "http://localhost"
}
],
"security": [
{
"Keycloak": []
}
],
"components": {
"schemas": {
...
},
"securitySchemes": {
"Keycloak": {
"type": "oauth2",
"name": "Keycloak",
"flows": {
"password": {
"tokenUrl": "http://localhost:8080/auth/realms/sample-app/protocol/openid-connect/token",
"scopes": {
"email": "",
"profile": ""
}
}
}
}
}
}
}
Using something like this:
@Override
public void configure() {
restConfiguration()
.component("servlet")
.apiProperty("api.title", "RDF-Pub Server")
.apiProperty("api.version", appVersion)
.apiProperty("api.components.securitySchemes.Keycloak.type", "oauth2")
.apiProperty("api.components.securitySchemes.Keycloak.name", "Keycloak")
.apiProperty("api.components.securitySchemes.Keycloak.flows.password.tokenUrl", "http://localhost:8080/auth/realms/example-app/protocol/openid-connect/token")
.apiProperty("api.components.securitySchemes.Keycloak.flows.password.scopes.email", "")
.apiProperty("api.components.securitySchemes.Keycloak.flows.password.scopes.profile", "");
}
Upvotes: 0
Views: 859
Reputation: 127
found that way:
private void routeCollection() {
rest()
.securityDefinitions()
.oauth2("local_keycloak", "Using a local keycloak instance")
.password("http://localhost:8080/auth/realms/sample-app/protocol/openid-connect/token")
.withScope("email", "accessing the email address")
.withScope("profile", "accessing the profile")
.end()
.end()
.get("/{owner}/{collection}")
.route()
.routeId("readCollection")
.process("processorA")
.process("processorB")
.endRest();
}
I extracted the stuff in a method:
private RestDefinition oauth2Rest() {
return rest()
.securityDefinitions()
.oauth2("local_keycloak", "Using a local keycloak instance")
.password("http://localhost:8080/auth/realms/sample-app/protocol/openid-connect/token")
.withScope("email", "accessing the email address")
.withScope("profile", "accessing the profile")
.end()
.end();
}
and called it once in the configuration:
@Override
public void configure() {
oauth2Rest();
// it tells Camel how to configure the REST service
restConfiguration()
...
Result:
Upvotes: 0