Open kburger opened 1 month ago
Reproduced on develop branch on localhost (with default dev db):
...
2024-10-29 14:56:10,012 25292 [http-nio-8080-exec-1] INFO org.springframework.web.servlet.DispatcherServlet - Completed initialization in 2 ms
2024-10-29 14:56:10,036 25316 [http-nio-8080-exec-1] DEBUG org.springframework.security.web.FilterChainProxy - Securing POST /metadata-schemas
2024-10-29 14:56:10,052 25332 [http-nio-8080-exec-1] INFO org.fairdatapoint.api.filter.LoggingFilter - http://localhost:8080/metadata-schemas
2024-10-29 14:56:10,116 25396 [http-nio-8080-exec-1] DEBUG org.springframework.security.web.FilterChainProxy - Secured POST /metadata-schemas
2024-10-29 14:56:10,224 25504 [http-nio-8080-exec-1] DEBUG org.springframework.security.access.intercept.aopalliance.MethodSecurityInterceptor - Failed to authorize ReflectiveMethodInvocation: public org.springframework.http.ResponseEntity org.fairdatapoint.api.controller.schema.MetadataSchemaController.createSchemaDraft(org.fairdatapoint.api.dto.schema.MetadataSchemaChangeDTO); target is of class [org.fairdatapoint.api.controller.schema.MetadataSchemaController] with attributes [[authorize: 'hasRole('ADMIN')', filter: 'null', filterTarget: 'null']]
2024-10-29 14:56:10,226 25506 [http-nio-8080-exec-1] ERROR org.fairdatapoint.api.controller.exception.ExceptionControllerAdvice - Access is denied
So we're authenticated, but not authorized.
More detail:
...
2024-10-29 15:40:37,089 37848 [http-nio-8080-exec-1] TRACE org.springframework.security.access.intercept.aopalliance.MethodSecurityInterceptor - Did not re-authenticate UsernamePasswordAuthenticationToken [Principal=org.springframework.security.core.userdetails.User [Username=7e64818d-6276-46fb-8bb1-732e6e09f7e9, Password=[PROTECTED], Enabled=true, AccountNonExpired=true, CredentialsNonExpired=true, AccountNonLocked=true, Granted Authorities=[ROLE_USER]], Credentials=[PROTECTED], Authenticated=true, Details=null, Granted Authorities=[ROLE_USER]] before authorizing
2024-10-29 15:40:37,090 37849 [http-nio-8080-exec-1] TRACE org.springframework.security.access.intercept.aopalliance.MethodSecurityInterceptor - Authorizing ReflectiveMethodInvocation: public org.springframework.http.ResponseEntity org.fairdatapoint.api.controller.schema.MetadataSchemaController.createSchemaDraft(org.fairdatapoint.api.dto.schema.MetadataSchemaChangeDTO); target is of class [org.fairdatapoint.api.controller.schema.MetadataSchemaController] with attributes [[authorize: 'hasRole('ADMIN')', filter: 'null', filterTarget: 'null']]
2024-10-29 15:40:37,094 37853 [http-nio-8080-exec-1] TRACE org.springframework.security.access.intercept.aopalliance.MethodSecurityInterceptor - Failed to authorize ReflectiveMethodInvocation: public org.springframework.http.ResponseEntity org.fairdatapoint.api.controller.schema.MetadataSchemaController.createSchemaDraft(org.fairdatapoint.api.dto.schema.MetadataSchemaChangeDTO); target is of class [org.fairdatapoint.api.controller.schema.MetadataSchemaController] with attributes [[authorize: 'hasRole('ADMIN')', filter: 'null', filterTarget: 'null']] using AffirmativeBased
...
Note the Granted Authorities=[ROLE_USER]
.
POST /metadata-schemas
requires the ADMIN
role, but GET /users/current
returns
{
"uuid": "7e64818d-6276-46fb-8bb1-732e6e09f7e9",
"firstName": "Albert",
"lastName": "Einstein",
"email": "albert.einstein@example.com",
"role": "USER"
}
Note the "role": "USER"
.
This holds for both Albert Einstein and Nikola Tesla, even though the readme says Albert is ADMIN:
The dev db migrations show there is a new admin in town:
Using a token for admin@example.com
, POST /metadata-schemas
works as expected (using develop branch on localhost with the default dev db).
@kburger were you also using the local dev db with default users, or were you using a custom db with real users?
@MarekSuchanek I can try to fix the inconsistency between migration and readme, but how do you wish to proceed?
@kburger were you also using the local dev db with default users, or were you using a custom db with real users?
Default users, but also a confirmed ADMIN
user on a 'real' FDP.
[...] but also a confirmed ADMIN user on a 'real' FDP.
Hi @kburger, does the "real" FDP run the develop
image or one of the v1.17.x
images?
(assuming you are running one of the Docker images)
They're all running tagged docker images, mostly the 1.16.2
version to work around the bugs in 1.17.
What is your question?
When
POST
ing a metadata schema using the/metadata-schemas
I get a403 Access is denied
error. I've provided aBearer
token in theAuthorization
header (for the admin user), and the body is exactly the same as the client produces. The log output is not showing anything beyond the 403 error either. How can I best proceed from here?