[keycloak-user] Keycloak, SpringBoot, and Swagger-UI

Ali Ahmadzadeh Asl ahmadzadehasl at outlook.com
Tue May 21 08:53:06 EDT 2019


Hi Dears

I have a Spring Boot project which uses Swagger-UI library for describing and testing REST services. Everything was ok until I added Keycloak library and settings to my project. The Keycloak settings are:

keycloak.realm=my-realm
keycloak.resource=my-app
keycloak.ssl-required=external
keycloak.enable-basic-auth=true
keycloak.autodetect-bearer-only=true
keycloak.use-resource-role-mappings=true
keycloak.principal-attribute=preferred_username
keycloak.auth-server-url=http://localhost:8080/auth
keycloak.credentials.secret=f3776b88-2600-44fa-83ec-67cb72fa0000
keycloak.policy-enforcer-config.on-deny-redirect-to=/access-denied

keycloak.securityConstraints[0].authRoles[0] = USER
keycloak.securityConstraints[0].securityCollections[0].name = default
keycloak.securityConstraints[0].securityCollections[0].patterns[0] = /*

Now, when a logged in user wants to see Swagger-UI page using a URL like http://127.0.0.1:6060/swagger-ui.html, a message containing bellow text and a text box shown:

"Unable to infer base url. This is common when using dynamic servlet registration or when the API is behind an API Gateway. The base url is the root of where all the swagger resources are served. For e.g. if the api is available at http://example.org/api/v2/api-docs then the base url is http://example.org/api/. Please enter the location manually: "

But the JSON of services' definitions is accessible from http://127.0.0.1:6060/v2/api-docs address.

Can anybody help me to solve this problem? What is the reason for this matter? How can I resolve?

Thanks
-------------- next part --------------
A non-text attachment was scrubbed...
Name: SwaggerUIPNG.PNG
Type: image/png
Size: 10729 bytes
Desc: SwaggerUIPNG.PNG
Url : http://lists.jboss.org/pipermail/keycloak-user/attachments/20190521/45acca45/attachment-0001.png 


More information about the keycloak-user mailing list