Repository navigation
Description
I want to add Oauth2 / openIdConnect support for the update server.
I followed the docs and included Keycloak but I came to a few issues.
Here is my Docker setup:
hawkbit:
image: "hawkbit/hawkbit-update-server:latest-mysql"
environment:
- 'SPRING_DATASOURCE_URL=jdbc:mysql://mysql:3306/hawkbit'
- 'SPRING_RABBITMQ_HOST=rabbitmq'
- 'SPRING_RABBITMQ_USERNAME=guest'
- 'SPRING_RABBITMQ_PASSWORD=guest'
- 'SPRING_DATASOURCE_USERNAME=root'
- spring.security.oauth2.client.registration.oidc.client-id=hawkbit-client
- spring.security.oauth2.client.registration.oidc.client-secret=
- spring.security.oauth2.client.provider.oidc.issuer-uri=http://service-keycloak:8080/auth/realms/master
- spring.security.oauth2.client.provider.oidc.authorization-uri=http://localhost:8080/auth/realms/master/protocol/openid-connect/auth
- spring.security.oauth2.client.provider.oidc.token-uri=http://service-keycloak:8080/auth/realms/master/protocol/openid-connect/token
- spring.security.oauth2.client.provider.oidc.user-info-uri=http://service-keycloak:8080/auth/realms/master/protocol/openid-connect/userinfo
- spring.security.oauth2.client.provider.oidc.jwk-set-uri=http://service-keycloak:8080/auth/realms/master/protocol/openid-connect/certs
- LOGGING_LEVEL_ROOT=DEBUG
restart: always
ports:
- "8081:8080"
labels:
NAME: "hawkbit"
Hawkbit does not provide Oauth for the Management API but the Management UI
Here on the bottom uf the page you mention:

which seems that Oauth is not supported for the management API but the Management UI.
In my case, it seems to be vice versa. I do not get a 401 on a request with oauth but a 403 which indicates that die Management API supports the flow.
When I use the Management UI, all my oauth users are ignored and only the standard admin admin user works. Is there something else to configure to make oauth available for the managament ui?
Hawkbit always returns 403:
When I use postman to read all targets, I always get a 403. I created a user and gave it pretty much every role available.
Here are the roles of my user from the jwt I use. I added pretty much every role possible. My goal was to read all targets. In addition, in the code base you use as Role constants: READ_TARGET while in the documentation you name it READ_TARGETS.
See here in the delivered permissions section and here
"realm_access": {
"roles": [
"READ_REPOSITORY",
"ALL",
"ROLE_READ_TARGETS",
"READ_TARGET",
"READ_TARGET_SECURITY_TOKEN",
"TENANT_CONFIGURATION",
"ROLE_ALL",
"READ_TARGETS",
"CREATE_TARGETS",
"ROLE_READ_TARGET",
"offline_access",
"uma_authorization",
"read_targets"
]
},
"resource_access": {
"account": {
"roles": [
"manage-account",
"manage-account-links",
"view-profile"
]
}
And here is my Stacktrace when I request
http://localhost:8081/rest/v1/targets with the previous mentioned user:
2021-01-13 05:36:52.579 DEBUG 1 --- [tp1234905692-17] org.eclipse.jetty.server.HttpChannel : HttpChannelOverHttp@4852bbe0{r=1,c=false,c=false/false,a=IDLE,uri=//localhost:8081/rest/v1/targets,age=3} onContentComplete
2021-01-13 05:36:52.580 DEBUG 1 --- [tp1234905692-17] org.eclipse.jetty.server.HttpChannel : HttpChannelOverHttp@4852bbe0{r=1,c=false,c=false/false,a=IDLE,uri=//localhost:8081/rest/v1/targets,age=4} onRequestComplete
2021-01-13 05:36:52.580 DEBUG 1 --- [tp1234905692-17] org.eclipse.jetty.server.HttpInput : HttpInputOverHTTP@d0e4f7b[c=0,q=0,[0]=null,s=STREAM] addContent EOF
2021-01-13 05:36:52.580 DEBUG 1 --- [tp1234905692-17] org.eclipse.jetty.server.HttpConnection : HttpConnection@5ca2a1f5::SocketChannelEndPoint@2476489{/10.0.2.2:55638<->/172.21.0.3:8080,OPEN,fill=-,flush=-,to=74/30000}{io=0/0,kio=0,kro=1}->HttpConnection@5ca2a1f5[p=HttpParser{s=END,0 of -1},g=HttpGenerator@1f29c3a{s=START}]=>HttpChannelOverHttp@4852bbe0{r=1,c=false,c=false/false,a=IDLE,uri=//localhost:8081/rest/v1/targets,age=4} parsed true HttpParser{s=END,0 of -1}
2021-01-13 05:36:52.581 DEBUG 1 --- [tp1234905692-17] org.eclipse.jetty.server.HttpConnection : releaseRequestBuffer HttpConnection@5ca2a1f5::SocketChannelEndPoint@2476489{/10.0.2.2:55638<->/172.21.0.3:8080,OPEN,fill=-,flush=-,to=75/30000}{io=0/0,kio=0,kro=1}->HttpConnection@5ca2a1f5[p=HttpParser{s=END,0 of -1},g=HttpGenerator@1f29c3a{s=START}]=>HttpChannelOverHttp@4852bbe0{r=1,c=false,c=false/false,a=IDLE,uri=//localhost:8081/rest/v1/targets,age=5}
2021-01-13 05:36:52.581 DEBUG 1 --- [tp1234905692-17] org.eclipse.jetty.server.HttpChannel : HttpChannelOverHttp@4852bbe0{r=1,c=false,c=false/false,a=IDLE,uri=//localhost:8081/rest/v1/targets,age=5} handle //localhost:8081/rest/v1/targets
2021-01-13 05:36:52.581 DEBUG 1 --- [tp1234905692-17] o.eclipse.jetty.server.HttpChannelState : handling HttpChannelState@284e6894{s=IDLE a=NOT_ASYNC i=true r=IDLE w=false}
2021-01-13 05:36:52.583 DEBUG 1 --- [tp1234905692-17] org.eclipse.jetty.server.HttpChannel : HttpChannelOverHttp@4852bbe0{r=1,c=false,c=false/false,a=DISPATCHED,uri=//localhost:8081/rest/v1/targets,age=7} action DISPATCH
2021-01-13 05:36:52.584 DEBUG 1 --- [tp1234905692-17] org.eclipse.jetty.server.Server : REQUEST GET /rest/v1/targets on HttpChannelOverHttp@4852bbe0{r=1,c=false,c=false/false,a=DISPATCHED,uri=//localhost:8081/rest/v1/targets,age=8}
2021-01-13 05:36:52.584 DEBUG 1 --- [tp1234905692-17] o.e.jetty.server.handler.ContextHandler : scope null||/rest/v1/targets @ o.s.b.w.e.j.JettyEmbeddedWebAppContext@69adf72c{application,/,[file:///tmp/jetty-docbase.1627448964568552835.8080/],AVAILABLE}
2021-01-13 05:36:52.585 DEBUG 1 --- [tp1234905692-17] o.e.jetty.server.handler.ContextHandler : context=||/rest/v1/targets @ o.s.b.w.e.j.JettyEmbeddedWebAppContext@69adf72c{application,/,[file:///tmp/jetty-docbase.1627448964568552835.8080/],AVAILABLE}
2021-01-13 05:36:52.585 DEBUG 1 --- [tp1234905692-17] org.eclipse.jetty.server.session : SessionHandler.doScope
2021-01-13 05:36:52.585 DEBUG 1 --- [tp1234905692-17] org.eclipse.jetty.server.session : sessionHandler=org.eclipse.jetty.server.session.SessionHandler127356954==dftMaxIdleSec=1800 session=null
2021-01-13 05:36:52.587 DEBUG 1 --- [tp1234905692-17] o.eclipse.jetty.servlet.ServletHandler : servlet |/rest/v1/targets|null -> dispatcherServlet@7ef5559e==org.springframework.web.servlet.DispatcherServlet,jsp=null,order=-1,inst=true,async=true
2021-01-13 05:36:52.600 DEBUG 1 --- [tp1234905692-17] o.eclipse.jetty.servlet.ServletHandler : chain=characterEncodingFilter@59696551==org.springframework.boot.web.servlet.filter.OrderedCharacterEncodingFilter,inst=true,async=true->hiddenHttpMethodFilter@5a08efdc==org.springframework.boot.web.servlet.filter.OrderedHiddenHttpMethodFilter,inst=true,async=true->formContentFilter@5c5d6175==org.springframework.boot.web.servlet.filter.OrderedFormContentFilter,inst=true,async=true->dosDDiFilter@43f1bb92==org.eclipse.hawkbit.security.DosFilter,inst=true,async=true->dosDDiDlFilter@79e66b2f==org.eclipse.hawkbit.security.DosFilter,inst=true,async=true->dosMgmtFilter@17273273==org.eclipse.hawkbit.security.DosFilter,inst=true,async=true->requestContextFilter@26350ea2==org.springframework.boot.web.servlet.filter.OrderedRequestContextFilter,inst=true,async=true->springSecurityFilterChain@6d6bbd35==org.springframework.boot.web.servlet.DelegatingFilterProxyRegistrationBean$1,inst=true,async=true->excludePathAwareShallowETagFilter@1e9469b8==org.eclipse.hawkbit.rest.filter.ExcludePathAwareShallowETagFilter,inst=true,async=true->userAuthenticationFilter@57272109==org.eclipse.hawkbit.autoconfigure.security.SecurityManagedConfiguration$UserAuthenticationFilterBasicAuth,inst=true,async=true->filterHttpResponse@7544ac86==org.eclipse.hawkbit.rest.util.FilterHttpResponse,inst=true,async=true->httpResponseFilter@5f69e2b==org.vaadin.spring.http.HttpResponseFilter,inst=true,async=true->oidcBearerTokenAuthenticationFilter@648d0e6d==org.eclipse.hawkbit.autoconfigure.security.OidcBearerTokenAuthenticationFilter,inst=true,async=true->Jetty_WebSocketUpgradeFilter@885e7ff==org.eclipse.jetty.websocket.server.WebSocketUpgradeFilter,inst=true,async=true->dispatcherServlet@7ef5559e==org.springframework.web.servlet.DispatcherServlet,jsp=null,order=-1,inst=true,async=true
2021-01-13 05:36:52.603 DEBUG 1 --- [tp1234905692-17] o.eclipse.jetty.servlet.ServletHandler : call filter characterEncodingFilter@59696551==org.springframework.boot.web.servlet.filter.OrderedCharacterEncodingFilter,inst=true,async=true
2021-01-13 05:36:52.608 DEBUG 1 --- [tp1234905692-17] o.eclipse.jetty.servlet.ServletHandler : call filter hiddenHttpMethodFilter@5a08efdc==org.springframework.boot.web.servlet.filter.OrderedHiddenHttpMethodFilter,inst=true,async=true
2021-01-13 05:36:52.609 DEBUG 1 --- [tp1234905692-17] o.eclipse.jetty.servlet.ServletHandler : call filter formContentFilter@5c5d6175==org.springframework.boot.web.servlet.filter.OrderedFormContentFilter,inst=true,async=true
2021-01-13 05:36:52.609 DEBUG 1 --- [tp1234905692-17] o.eclipse.jetty.servlet.ServletHandler : call filter dosDDiFilter@43f1bb92==org.eclipse.hawkbit.security.DosFilter,inst=true,async=true
2021-01-13 05:36:52.610 DEBUG 1 --- [tp1234905692-17] o.eclipse.jetty.servlet.ServletHandler : call filter dosDDiDlFilter@79e66b2f==org.eclipse.hawkbit.security.DosFilter,inst=true,async=true
2021-01-13 05:36:52.610 DEBUG 1 --- [tp1234905692-17] o.eclipse.jetty.servlet.ServletHandler : call filter dosMgmtFilter@17273273==org.eclipse.hawkbit.security.DosFilter,inst=true,async=true
2021-01-13 05:36:52.612 DEBUG 1 --- [tp1234905692-17] o.eclipse.jetty.servlet.ServletHandler : call filter requestContextFilter@26350ea2==org.springframework.boot.web.servlet.filter.OrderedRequestContextFilter,inst=true,async=true
2021-01-13 05:36:52.613 DEBUG 1 --- [tp1234905692-17] o.eclipse.jetty.servlet.ServletHandler : call filter springSecurityFilterChain@6d6bbd35==org.springframework.boot.web.servlet.DelegatingFilterProxyRegistrationBean$1,inst=true,async=true
2021-01-13 05:36:52.615 DEBUG 1 --- [tp1234905692-17] o.s.s.w.u.matcher.AntPathRequestMatcher : Checking match of request : '/rest/v1/targets'; against '/documentation/**'
2021-01-13 05:36:52.616 DEBUG 1 --- [tp1234905692-17] o.s.s.w.u.matcher.AntPathRequestMatcher : Checking match of request : '/rest/v1/targets'; against '/VAADIN/**'
2021-01-13 05:36:52.616 DEBUG 1 --- [tp1234905692-17] o.s.s.w.u.matcher.AntPathRequestMatcher : Checking match of request : '/rest/v1/targets'; against '/*.*'
2021-01-13 05:36:52.616 DEBUG 1 --- [tp1234905692-17] o.s.s.w.u.matcher.AntPathRequestMatcher : Checking match of request : '/rest/v1/targets'; against '/docs/**'
2021-01-13 05:36:52.616 DEBUG 1 --- [tp1234905692-17] o.s.s.web.util.matcher.OrRequestMatcher : Trying to match using Ant [pattern='/{tenant}/controller/v1/{controllerId}']
2021-01-13 05:36:52.616 DEBUG 1 --- [tp1234905692-17] o.s.s.w.u.matcher.AntPathRequestMatcher : Checking match of request : '/rest/v1/targets'; against '/{tenant}/controller/v1/{controllerId}'
2021-01-13 05:36:52.616 DEBUG 1 --- [tp1234905692-17] o.s.s.web.util.matcher.OrRequestMatcher : Trying to match using Ant [pattern='/{tenant}/controller/v1/{controllerId}/deploymentBase/**']
2021-01-13 05:36:52.616 DEBUG 1 --- [tp1234905692-17] o.s.s.w.u.matcher.AntPathRequestMatcher : Checking match of request : '/rest/v1/targets'; against '/{tenant}/controller/v1/{controllerId}/deploymentBase/**'
2021-01-13 05:36:52.616 DEBUG 1 --- [tp1234905692-17] o.s.s.web.util.matcher.OrRequestMatcher : Trying to match using Ant [pattern='/{tenant}/controller/v1/{controllerId}/cancelAction/**']
2021-01-13 05:36:52.616 DEBUG 1 --- [tp1234905692-17] o.s.s.w.u.matcher.AntPathRequestMatcher : Checking match of request : '/rest/v1/targets'; against '/{tenant}/controller/v1/{controllerId}/cancelAction/**'
2021-01-13 05:36:52.617 DEBUG 1 --- [tp1234905692-17] o.s.s.web.util.matcher.OrRequestMatcher : Trying to match using Ant [pattern='/{tenant}/controller/v1/{controllerId}/configData']
2021-01-13 05:36:52.617 DEBUG 1 --- [tp1234905692-17] o.s.s.w.u.matcher.AntPathRequestMatcher : Checking match of request : '/rest/v1/targets'; against '/{tenant}/controller/v1/{controllerId}/configData'
2021-01-13 05:36:52.617 DEBUG 1 --- [tp1234905692-17] o.s.s.web.util.matcher.OrRequestMatcher : Trying to match using Ant [pattern='/{tenant}/controller/v1/{controllerId}/softwaremodules/{softwareModuleId}/artifacts']
2021-01-13 05:36:52.618 DEBUG 1 --- [tp1234905692-17] o.s.s.w.u.matcher.AntPathRequestMatcher : Checking match of request : '/rest/v1/targets'; against '/{tenant}/controller/v1/{controllerId}/softwaremodules/{softwareModuleId}/artifacts'
2021-01-13 05:36:52.618 DEBUG 1 --- [tp1234905692-17] o.s.s.web.util.matcher.OrRequestMatcher : No matches found
2021-01-13 05:36:52.618 DEBUG 1 --- [tp1234905692-17] o.s.s.web.util.matcher.OrRequestMatcher : Trying to match using Ant [pattern='/{tenant}/controller/v1/{controllerId}/softwaremodules/{softwareModuleId}/artifacts/*']
2021-01-13 05:36:52.618 DEBUG 1 --- [tp1234905692-17] o.s.s.w.u.matcher.AntPathRequestMatcher : Checking match of request : '/rest/v1/targets'; against '/{tenant}/controller/v1/{controllerId}/softwaremodules/{softwareModuleId}/artifacts/*'
2021-01-13 05:36:52.618 DEBUG 1 --- [tp1234905692-17] o.s.s.web.util.matcher.OrRequestMatcher : No matches found
2021-01-13 05:36:52.618 DEBUG 1 --- [tp1234905692-17] o.s.s.w.u.matcher.RegexRequestMatcher : Checking match of request : '/rest/v1/targets'; against '.*\/downloadId\/.*'
2021-01-13 05:36:52.618 DEBUG 1 --- [tp1234905692-17] o.s.s.w.u.matcher.RegexRequestMatcher : Checking match of request : '/rest/v1/targets'; against '\/rest.*|\/system/admin.*'
2021-01-13 05:36:52.619 DEBUG 1 --- [tp1234905692-17] o.s.security.web.FilterChainProxy : /rest/v1/targets at position 1 of 12 in additional filter chain; firing Filter: 'WebAsyncManagerIntegrationFilter'
2021-01-13 05:36:52.621 DEBUG 1 --- [tp1234905692-17] o.s.security.web.FilterChainProxy : /rest/v1/targets at position 2 of 12 in additional filter chain; firing Filter: 'SecurityContextPersistenceFilter'
2021-01-13 05:36:52.622 DEBUG 1 --- [tp1234905692-17] o.s.security.web.FilterChainProxy : /rest/v1/targets at position 3 of 12 in additional filter chain; firing Filter: 'HeaderWriterFilter'
2021-01-13 05:36:52.627 DEBUG 1 --- [tp1234905692-17] o.s.security.web.FilterChainProxy : /rest/v1/targets at position 4 of 12 in additional filter chain; firing Filter: 'LogoutFilter'
2021-01-13 05:36:52.628 DEBUG 1 --- [tp1234905692-17] o.s.s.web.util.matcher.OrRequestMatcher : Trying to match using Ant [pattern='/logout', GET]
2021-01-13 05:36:52.628 DEBUG 1 --- [tp1234905692-17] o.s.s.w.u.matcher.AntPathRequestMatcher : Checking match of request : '/rest/v1/targets'; against '/logout'
2021-01-13 05:36:52.629 DEBUG 1 --- [tp1234905692-17] o.s.s.web.util.matcher.OrRequestMatcher : Trying to match using Ant [pattern='/logout', POST]
2021-01-13 05:36:52.629 DEBUG 1 --- [tp1234905692-17] o.s.s.w.u.matcher.AntPathRequestMatcher : Request 'GET /rest/v1/targets' doesn't match 'POST /logout'
2021-01-13 05:36:52.629 DEBUG 1 --- [tp1234905692-17] o.s.s.web.util.matcher.OrRequestMatcher : Trying to match using Ant [pattern='/logout', PUT]
2021-01-13 05:36:52.629 DEBUG 1 --- [tp1234905692-17] o.s.s.w.u.matcher.AntPathRequestMatcher : Request 'GET /rest/v1/targets' doesn't match 'PUT /logout'
2021-01-13 05:36:52.629 DEBUG 1 --- [tp1234905692-17] o.s.s.web.util.matcher.OrRequestMatcher : Trying to match using Ant [pattern='/logout', DELETE]
2021-01-13 05:36:52.629 DEBUG 1 --- [tp1234905692-17] o.s.s.w.u.matcher.AntPathRequestMatcher : Request 'GET /rest/v1/targets' doesn't match 'DELETE /logout'
2021-01-13 05:36:52.629 DEBUG 1 --- [tp1234905692-17] o.s.s.web.util.matcher.OrRequestMatcher : No matches found
2021-01-13 05:36:52.629 DEBUG 1 --- [tp1234905692-17] o.s.security.web.FilterChainProxy : /rest/v1/targets at position 5 of 12 in additional filter chain; firing Filter: 'BearerTokenAuthenticationFilter'
2021-01-13 05:36:52.631 DEBUG 1 --- [tp1234905692-17] o.s.s.authentication.ProviderManager : Authentication attempt using org.springframework.security.oauth2.server.resource.authentication.JwtAuthenticationProvider
2021-01-13 05:36:52.702 DEBUG 1 --- [tp1234905692-17] o.s.web.client.RestTemplate : HTTP GET http://service-keycloak:8080/auth/realms/master/protocol/openid-connect/certs
2021-01-13 05:36:52.704 DEBUG 1 --- [tp1234905692-17] o.s.web.client.RestTemplate : Accept=[text/plain, application/json, application/cbor, application/*+json, */*]
2021-01-13 05:36:52.709 DEBUG 1 --- [executor-pool-1] o.e.h.r.jpa.rollout.RolloutScheduler : rollout schedule checker has been triggered.
2021-01-13 05:36:52.710 DEBUG 1 --- [executor-pool-1] o.e.h.security.SystemSecurityContext : entering system code execution
2021-01-13 05:36:52.711 DEBUG 1 --- [executor-pool-1] s.a.i.a.AspectJMethodSecurityInterceptor : Secure object: ReflectiveMethodInvocation: public void org.eclipse.hawkbit.repository.jpa.JpaSystemManagement.forEachTenant(java.util.function.Consumer); target is of class [org.eclipse.hawkbit.repository.jpa.JpaSystemManagement]; Attributes: [[authorize: 'hasAuthority('ROLE_SYSTEM_CODE')', filter: 'null', filterTarget: 'null']]
2021-01-13 05:36:52.711 DEBUG 1 --- [executor-pool-1] s.a.i.a.AspectJMethodSecurityInterceptor : Previously Authenticated: org.eclipse.hawkbit.security.SystemSecurityContext$SystemCodeAuthentication@507f3f4a
2021-01-13 05:36:52.712 DEBUG 1 --- [executor-pool-1] o.s.s.access.vote.AffirmativeBased : Voter: org.springframework.security.access.prepost.PreInvocationAuthorizationAdviceVoter@1824bd8, returned: 1
2021-01-13 05:36:52.712 DEBUG 1 --- [executor-pool-1] s.a.i.a.AspectJMethodSecurityInterceptor : Authorization successful
2021-01-13 05:36:52.712 DEBUG 1 --- [executor-pool-1] s.a.i.a.AspectJMethodSecurityInterceptor : RunAsManager did not change Authentication object
2021-01-13 05:36:52.713 DEBUG 1 --- [executor-pool-1] h.r.j.c.MultiTenantJpaTransactionManager : Creating new transaction with name [org.springframework.data.jpa.repository.support.SimpleJpaRepository.findAll]: PROPAGATION_REQUIRED,ISOLATION_DEFAULT,readOnly
2021-01-13 05:36:52.714 DEBUG 1 --- [executor-pool-1] h.r.j.c.MultiTenantJpaTransactionManager : Opened new EntityManager [org.eclipse.persistence.internal.jpa.EntityManagerImpl@6cfda9a1] for JPA transaction
2021-01-13 05:36:52.714 DEBUG 1 --- [executor-pool-1] h.r.j.c.MultiTenantJpaTransactionManager : Exposing JPA transaction as JDBC [org.springframework.orm.jpa.vendor.EclipseLinkJpaDialect$EclipseLinkConnectionHandle@707743ff]
2021-01-13 05:36:52.716 DEBUG 1 --- [executor-pool-1] h.r.j.c.MultiTenantJpaTransactionManager : Initiating transaction commit
2021-01-13 05:36:52.716 DEBUG 1 --- [executor-pool-1] h.r.j.c.MultiTenantJpaTransactionManager : Committing JPA transaction on EntityManager [org.eclipse.persistence.internal.jpa.EntityManagerImpl@6cfda9a1]
2021-01-13 05:36:52.717 DEBUG 1 --- [executor-pool-1] h.r.j.c.MultiTenantJpaTransactionManager : Closing JPA EntityManager [org.eclipse.persistence.internal.jpa.EntityManagerImpl@6cfda9a1] after transaction
2021-01-13 05:36:52.718 DEBUG 1 --- [executor-pool-1] h.r.j.c.MultiTenantJpaTransactionManager : Resuming suspended transaction after completion of inner transaction
2021-01-13 05:36:52.718 DEBUG 1 --- [executor-pool-2] o.e.h.r.j.a.AutoAssignScheduler : auto assign schedule checker has been triggered.
2021-01-13 05:36:52.718 DEBUG 1 --- [executor-pool-2] o.e.h.security.SystemSecurityContext : entering system code execution
2021-01-13 05:36:52.719 DEBUG 1 --- [executor-pool-2] s.a.i.a.AspectJMethodSecurityInterceptor : Secure object: ReflectiveMethodInvocation: public void org.eclipse.hawkbit.repository.jpa.JpaSystemManagement.forEachTenant(java.util.function.Consumer); target is of class [org.eclipse.hawkbit.repository.jpa.JpaSystemManagement]; Attributes: [[authorize: 'hasAuthority('ROLE_SYSTEM_CODE')', filter: 'null', filterTarget: 'null']]
2021-01-13 05:36:52.720 DEBUG 1 --- [executor-pool-2] s.a.i.a.AspectJMethodSecurityInterceptor : Previously Authenticated: org.eclipse.hawkbit.security.SystemSecurityContext$SystemCodeAuthentication@43ff049f
2021-01-13 05:36:52.721 DEBUG 1 --- [executor-pool-2] o.s.s.access.vote.AffirmativeBased : Voter: org.springframework.security.access.prepost.PreInvocationAuthorizationAdviceVoter@1824bd8, returned: 1
2021-01-13 05:36:52.721 DEBUG 1 --- [executor-pool-2] s.a.i.a.AspectJMethodSecurityInterceptor : Authorization successful
2021-01-13 05:36:52.721 DEBUG 1 --- [executor-pool-2] s.a.i.a.AspectJMethodSecurityInterceptor : RunAsManager did not change Authentication object
2021-01-13 05:36:52.721 DEBUG 1 --- [executor-pool-2] h.r.j.c.MultiTenantJpaTransactionManager : Creating new transaction with name [org.springframework.data.jpa.repository.support.SimpleJpaRepository.findAll]: PROPAGATION_REQUIRED,ISOLATION_DEFAULT,readOnly
2021-01-13 05:36:52.721 DEBUG 1 --- [executor-pool-2] h.r.j.c.MultiTenantJpaTransactionManager : Opened new EntityManager [org.eclipse.persistence.internal.jpa.EntityManagerImpl@7a79bbaa] for JPA transaction
2021-01-13 05:36:52.721 DEBUG 1 --- [executor-pool-2] h.r.j.c.MultiTenantJpaTransactionManager : Exposing JPA transaction as JDBC [org.springframework.orm.jpa.vendor.EclipseLinkJpaDialect$EclipseLinkConnectionHandle@6b8ae961]
2021-01-13 05:36:52.724 DEBUG 1 --- [executor-pool-2] h.r.j.c.MultiTenantJpaTransactionManager : Initiating transaction commit
2021-01-13 05:36:52.724 DEBUG 1 --- [executor-pool-2] h.r.j.c.MultiTenantJpaTransactionManager : Committing JPA transaction on EntityManager [org.eclipse.persistence.internal.jpa.EntityManagerImpl@7a79bbaa]
2021-01-13 05:36:52.725 DEBUG 1 --- [executor-pool-2] h.r.j.c.MultiTenantJpaTransactionManager : Closing JPA EntityManager [org.eclipse.persistence.internal.jpa.EntityManagerImpl@7a79bbaa] after transaction
2021-01-13 05:36:52.726 DEBUG 1 --- [executor-pool-2] h.r.j.c.MultiTenantJpaTransactionManager : Resuming suspended transaction after completion of inner transaction
2021-01-13 05:36:52.726 DEBUG 1 --- [executor-pool-1] o.e.h.security.SystemSecurityContext : leaving system code execution
2021-01-13 05:36:52.727 DEBUG 1 --- [executor-pool-2] o.e.h.security.SystemSecurityContext : leaving system code execution
2021-01-13 05:36:52.737 DEBUG 1 --- [tp1234905692-17] s.n.www.protocol.http.HttpURLConnection : sun.net.www.MessageHeader@7c8d21835 pairs: {GET /auth/realms/master/protocol/openid-connect/certs HTTP/1.1: null}{Accept: application/json;charset=UTF-8}{User-Agent: Java/1.8.0_212}{Host: service-keycloak:8080}{Connection: keep-alive}
2021-01-13 05:36:52.805 DEBUG 1 --- [tp1234905692-17] s.n.www.protocol.http.HttpURLConnection : sun.net.www.MessageHeader@2220536e10 pairs: {null: HTTP/1.1 200 OK}{Cache-Control: no-cache}{X-XSS-Protection: 1; mode=block}{X-Frame-Options: SAMEORIGIN}{Date: Wed, 13 Jan 2021 05:36:52 GMT}{Connection: keep-alive}{Strict-Transport-Security: max-age=31536000; includeSubDomains}{X-Content-Type-Options: nosniff}{Content-Type: application/json}{Content-Length: 1462}
2021-01-13 05:36:52.805 DEBUG 1 --- [tp1234905692-17] o.s.web.client.RestTemplate : Response 200 OK
2021-01-13 05:36:52.806 DEBUG 1 --- [tp1234905692-17] o.s.web.client.RestTemplate : Reading to [java.lang.String] as "application/json"
2021-01-13 05:36:52.913 DEBUG 1 --- [tp1234905692-17] o.s.security.web.FilterChainProxy : /rest/v1/targets at position 6 of 12 in additional filter chain; firing Filter: 'OidcBearerTokenAuthenticationFilter'
2021-01-13 05:36:52.915 DEBUG 1 --- [tp1234905692-17] o.s.s.w.header.writers.HstsHeaderWriter : Not injecting HSTS header since it did not match the requestMatcher org.springframework.security.web.header.writers.HstsHeaderWriter$SecureRequestMatcher@7329bfe9
2021-01-13 05:36:52.917 DEBUG 1 --- [tp1234905692-17] o.e.jetty.servlet.ErrorPageErrorHandler : getErrorPage(GET /rest/v1/targets) => error_page=/error (from global default)
2021-01-13 05:36:52.919 DEBUG 1 --- [tp1234905692-17] o.e.jetty.server.handler.ErrorHandler : error page dispatch /error->Dispatcher@0x2b982f51{null,/error}
2021-01-13 05:36:52.920 DEBUG 1 --- [tp1234905692-17] o.e.jetty.server.handler.ContextHandler : scope /||/error @ o.s.b.w.e.j.JettyEmbeddedWebAppContext@69adf72c{application,/,[file:///tmp/jetty-docbase.1627448964568552835.8080/],AVAILABLE}
2021-01-13 05:36:52.921 DEBUG 1 --- [tp1234905692-17] o.e.jetty.server.handler.ContextHandler : context=||/error @ o.s.b.w.e.j.JettyEmbeddedWebAppContext@69adf72c{application,/,[file:///tmp/jetty-docbase.1627448964568552835.8080/],AVAILABLE}
2021-01-13 05:36:52.921 DEBUG 1 --- [tp1234905692-17] org.eclipse.jetty.server.session : SessionHandler.doScope
2021-01-13 05:36:52.921 DEBUG 1 --- [tp1234905692-17] org.eclipse.jetty.server.session : sessionHandler=org.eclipse.jetty.server.session.SessionHandler127356954==dftMaxIdleSec=1800 session=null
2021-01-13 05:36:52.921 DEBUG 1 --- [tp1234905692-17] o.eclipse.jetty.servlet.ServletHandler : servlet |/error|null -> dispatcherServlet@7ef5559e==org.springframework.web.servlet.DispatcherServlet,jsp=null,order=-1,inst=true,async=true
2021-01-13 05:36:52.921 DEBUG 1 --- [tp1234905692-17] o.eclipse.jetty.servlet.ServletHandler : chain=springSecurityFilterChain@6d6bbd35==org.springframework.boot.web.servlet.DelegatingFilterProxyRegistrationBean$1,inst=true,async=true->dispatcherServlet@7ef5559e==org.springframework.web.servlet.DispatcherServlet,jsp=null,order=-1,inst=true,async=true
2021-01-13 05:36:52.921 DEBUG 1 --- [tp1234905692-17] o.eclipse.jetty.servlet.ServletHandler : call filter springSecurityFilterChain@6d6bbd35==org.springframework.boot.web.servlet.DelegatingFilterProxyRegistrationBean$1,inst=true,async=true
2021-01-13 05:36:52.921 DEBUG 1 --- [tp1234905692-17] o.s.s.w.u.matcher.AntPathRequestMatcher : Checking match of request : '/error'; against '/documentation/**'
2021-01-13 05:36:52.921 DEBUG 1 --- [tp1234905692-17] o.s.s.w.u.matcher.AntPathRequestMatcher : Checking match of request : '/error'; against '/VAADIN/**'
2021-01-13 05:36:52.921 DEBUG 1 --- [tp1234905692-17] o.s.s.w.u.matcher.AntPathRequestMatcher : Checking match of request : '/error'; against '/*.*'
2021-01-13 05:36:52.921 DEBUG 1 --- [tp1234905692-17] o.s.s.w.u.matcher.AntPathRequestMatcher : Checking match of request : '/error'; against '/docs/**'
2021-01-13 05:36:52.921 DEBUG 1 --- [tp1234905692-17] o.s.s.web.util.matcher.OrRequestMatcher : Trying to match using Ant [pattern='/{tenant}/controller/v1/{controllerId}']
2021-01-13 05:36:52.922 DEBUG 1 --- [tp1234905692-17] o.s.s.w.u.matcher.AntPathRequestMatcher : Checking match of request : '/error'; against '/{tenant}/controller/v1/{controllerId}'
2021-01-13 05:36:52.922 DEBUG 1 --- [tp1234905692-17] o.s.s.web.util.matcher.OrRequestMatcher : Trying to match using Ant [pattern='/{tenant}/controller/v1/{controllerId}/deploymentBase/**']
2021-01-13 05:36:52.922 DEBUG 1 --- [tp1234905692-17] o.s.s.w.u.matcher.AntPathRequestMatcher : Checking match of request : '/error'; against '/{tenant}/controller/v1/{controllerId}/deploymentBase/**'
2021-01-13 05:36:52.922 DEBUG 1 --- [tp1234905692-17] o.s.s.web.util.matcher.OrRequestMatcher : Trying to match using Ant [pattern='/{tenant}/controller/v1/{controllerId}/cancelAction/**']
2021-01-13 05:36:52.922 DEBUG 1 --- [tp1234905692-17] o.s.s.w.u.matcher.AntPathRequestMatcher : Checking match of request : '/error'; against '/{tenant}/controller/v1/{controllerId}/cancelAction/**'
2021-01-13 05:36:52.922 DEBUG 1 --- [tp1234905692-17] o.s.s.web.util.matcher.OrRequestMatcher : Trying to match using Ant [pattern='/{tenant}/controller/v1/{controllerId}/configData']
2021-01-13 05:36:52.922 DEBUG 1 --- [tp1234905692-17] o.s.s.w.u.matcher.AntPathRequestMatcher : Checking match of request : '/error'; against '/{tenant}/controller/v1/{controllerId}/configData'
2021-01-13 05:36:52.922 DEBUG 1 --- [tp1234905692-17] o.s.s.web.util.matcher.OrRequestMatcher : Trying to match using Ant [pattern='/{tenant}/controller/v1/{controllerId}/softwaremodules/{softwareModuleId}/artifacts']
2021-01-13 05:36:52.922 DEBUG 1 --- [tp1234905692-17] o.s.s.w.u.matcher.AntPathRequestMatcher : Checking match of request : '/error'; against '/{tenant}/controller/v1/{controllerId}/softwaremodules/{softwareModuleId}/artifacts'
2021-01-13 05:36:52.922 DEBUG 1 --- [tp1234905692-17] o.s.s.web.util.matcher.OrRequestMatcher : No matches found
2021-01-13 05:36:52.922 DEBUG 1 --- [tp1234905692-17] o.s.s.web.util.matcher.OrRequestMatcher : Trying to match using Ant [pattern='/{tenant}/controller/v1/{controllerId}/softwaremodules/{softwareModuleId}/artifacts/*']
2021-01-13 05:36:52.922 DEBUG 1 --- [tp1234905692-17] o.s.s.w.u.matcher.AntPathRequestMatcher : Checking match of request : '/error'; against '/{tenant}/controller/v1/{controllerId}/softwaremodules/{softwareModuleId}/artifacts/*'
2021-01-13 05:36:52.922 DEBUG 1 --- [tp1234905692-17] o.s.s.web.util.matcher.OrRequestMatcher : No matches found
2021-01-13 05:36:52.922 DEBUG 1 --- [tp1234905692-17] o.s.s.w.u.matcher.RegexRequestMatcher : Checking match of request : '/error'; against '.*\/downloadId\/.*'
2021-01-13 05:36:52.922 DEBUG 1 --- [tp1234905692-17] o.s.s.w.u.matcher.RegexRequestMatcher : Checking match of request : '/error'; against '\/rest.*|\/system/admin.*'
2021-01-13 05:36:52.922 DEBUG 1 --- [tp1234905692-17] o.s.s.w.u.matcher.RegexRequestMatcher : Checking match of request : '/error'; against '(?!.*HEARTBEAT)^.*\/(UI|oauth2).*$'
2021-01-13 05:36:52.923 DEBUG 1 --- [tp1234905692-17] o.s.security.web.FilterChainProxy : /error has no matching filters
2021-01-13 05:36:52.924 DEBUG 1 --- [tp1234905692-17] o.eclipse.jetty.servlet.ServletHandler : call servlet dispatcherServlet@7ef5559e==org.springframework.web.servlet.DispatcherServlet,jsp=null,order=-1,inst=true,async=true
2021-01-13 05:36:52.935 DEBUG 1 --- [tp1234905692-17] o.s.web.servlet.DispatcherServlet : "ERROR" dispatch for GET "/error", parameters={}
2021-01-13 05:36:52.959 DEBUG 1 --- [tp1234905692-17] s.w.s.m.m.a.RequestMappingHandlerMapping : Mapped to public org.springframework.http.ResponseEntity<java.util.Map<java.lang.String, java.lang.Object>> org.springframework.boot.autoconfigure.web.servlet.error.BasicErrorController.error(javax.servlet.http.HttpServletRequest)
2021-01-13 05:36:52.961 DEBUG 1 --- [tp1234905692-17] o.j.s.OpenEntityManagerInViewInterceptor : Opening JPA EntityManager in OpenEntityManagerInViewInterceptor
2021-01-13 05:36:53.045 DEBUG 1 --- [tp1234905692-17] o.s.w.s.m.m.a.HttpEntityMethodProcessor : Using 'application/json', given [*/*] and supported [application/json, application/*+json, application/json, application/*+json, application/cbor]
2021-01-13 05:36:53.046 DEBUG 1 --- [tp1234905692-17] o.s.w.s.m.m.a.HttpEntityMethodProcessor : Writing [{timestamp=Wed Jan 13 05:36:53 GMT 2021, status=403, error=Forbidden, message=Forbidden, path=/rest/ (truncated)...]
2021-01-13 05:36:53.119 DEBUG 1 --- [tp1234905692-17] org.eclipse.jetty.server.HttpChannel : sendResponse info=null content=DirectByteBuffer@46210bf3[p=0,l=125,c=32768,r=125]={<<<{"timestamp":"202...st/v1/targets"}>>>\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00...\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00} complete=false committing=true callback=Blocker@65f61aeb{null}
2021-01-13 05:36:53.119 DEBUG 1 --- [tp1234905692-17] org.eclipse.jetty.server.HttpChannel : COMMIT for /error on HttpChannelOverHttp@4852bbe0{r=1,c=true,c=false/false,a=DISPATCHED,uri=//localhost:8081/error,age=543}
403 null HTTP/1.1
Date: Wed, 13 Jan 2021 05:36:52 GMT
X-Content-Type-Options: nosniff
X-XSS-Protection: 1; mode=block
Pragma: no-cache
X-Frame-Options: DENY
Content-Type: application/json;charset=utf-8
It seems that there is a pretty big lack in the documentation about Oauth integration. Does anyboy have the same problem or can provide a solution?
UPDATE:
I got oauth working with the Management API. The error was that I used realm Roles and not client roles.
The Problem with the Management Ui is still there. I can not login with the same user I use for the Management API.
Can you tell me the flow that is used in that case? I thought that I should be able to use the Management UI aswell.
Here are the logs:
2021-01-15 09:18:09.607 DEBUG 1 --- [tp1234905692-18] o.s.s.w.u.matcher.AntPathRequestMatcher : Checking match of request : '/UI/UIDL/'; against '/login/oauth2/code/*'
2021-01-15 09:18:09.607 DEBUG 1 --- [tp1234905692-18] o.s.s.w.util.matcher.AndRequestMatcher : Did not match
2021-01-15 09:18:09.607 DEBUG 1 --- [tp1234905692-18] o.s.security.web.FilterChainProxy : /UI/UIDL/?v-uiId=0 at position 8 of 16 in additional filter chain; firing Filter: 'DefaultLoginPageGeneratingFilter'
2021-01-15 09:18:09.607 DEBUG 1 --- [tp1234905692-18] o.s.security.web.FilterChainProxy : /UI/UIDL/?v-uiId=0 at position 9 of 16 in additional filter chain; firing Filter: 'DefaultLogoutPageGeneratingFilter'
2021-01-15 09:18:09.607 DEBUG 1 --- [tp1234905692-18] o.s.s.w.u.matcher.AntPathRequestMatcher : Request 'POST /UI/UIDL/' doesn't match 'GET /logout'
2021-01-15 09:18:09.607 DEBUG 1 --- [tp1234905692-18] o.s.security.web.FilterChainProxy : /UI/UIDL/?v-uiId=0 at position 10 of 16 in additional filter chain; firing Filter: 'RequestCacheAwareFilter'
2021-01-15 09:18:09.607 DEBUG 1 --- [tp1234905692-18] o.s.s.w.s.HttpSessionRequestCache : saved request doesn't match
2021-01-15 09:18:09.607 DEBUG 1 --- [tp1234905692-18] o.s.security.web.FilterChainProxy : /UI/UIDL/?v-uiId=0 at position 11 of 16 in additional filter chain; firing Filter: 'SecurityContextHolderAwareRequestFilter'
2021-01-15 09:18:09.607 DEBUG 1 --- [tp1234905692-18] o.s.security.web.FilterChainProxy : /UI/UIDL/?v-uiId=0 at position 12 of 16 in additional filter chain; firing Filter: 'AnonymousAuthenticationFilter'
2021-01-15 09:18:09.607 DEBUG 1 --- [tp1234905692-18] o.s.s.w.a.AnonymousAuthenticationFilter : Populated SecurityContextHolder with anonymous token: 'org.springframework.security.authentication.AnonymousAuthenticationToken@ff9b1cf2: Principal: anonymousUser; Credentials: [PROTECTED]; Authenticated: true; Details: org.springframework.security.web.authentication.WebAuthenticationDetails@2cd90: RemoteIpAddress: 10.0.2.2; SessionId: node01o0pnlb0ekeez180l4o6axsvmt0; Granted Authorities: ROLE_ANONYMOUS'
It's also a bit weird to me that when I login with user admin admin and then logout (with oauth parameters enabled), Hawkbit tries to do a redirect and I get a keycloak error:
redirect uri in the url is:
http://localhost:8081/login/oauth2/code/oidc
The logs say:
2021-01-22 06:43:51.548 DEBUG 1 --- [tp1130551263-20] o.s.s.w.a.ExceptionTranslationFilter : Access is denied (user is anonymous); redirecting to authentication entry point
org.springframework.security.access.AccessDeniedException: Access is denied
UPDATE:
Fixed the Access denied by adding the redirect uri to my keycloak client. I gues the problem now is that I login with a non keycloak user. When I logout I get a keycloak error log
[org.keycloak.events] (default task-2) type=USER_INFO_REQUEST_ERROR, realmId=master, clientId=null, userId=null, ipAddress=XXX.XXX.XXX, error=invalid_token, auth_method=validate_access_token
Can one explain to me why clientId is null here?

Activity
schabdo commentedon Feb 1, 2021
If you're running a Docker setup the above posted URI has to point to Keycloak instead of hawkBit's own container (localhost). According to your config, this should do the trick:
hawkbit-bot commentedon Feb 17, 2021
There has been no response from the original author so I closed this issue.
Please reach out if you have or find the answers we need so that we can investigate further.