Skip to content
This repository was archived by the owner on May 14, 2025. It is now read-only.

NullPointer throw when authenticate via Bearer Token to active endpoint i.e. register application #4861

Closed
szopal opened this issue Mar 23, 2022 · 0 comments
Assignees
Labels
type/bug Is a bug report
Milestone

Comments

@szopal
Copy link

szopal commented Mar 23, 2022

I've configured SCDF to use ADFS nad OAuth2.0. When user login to SCDF everything is fine, but when I want to call REST API to register new application I've got NullPointer:

curl -vik -H "Authorization: Bearer %TOKEN%" https://localhost:9445/apps/task/my-task-process/1.7.4.90-SNAPSHOT -d "uri=docker%3Aeu.gcr.io%2Fmy-project-gcp%2Fmy-task-process%3A1.7.4.90-SNAPSHOT&force=true"

While debug I noticed that it's caused by getCurrentAuditor method because when I authorize via client, there is no user info.

2022-03-23 14:48:04.419 TRACE 5132 --- [nio-9445-exec-9] o.s.s.w.a.i.FilterSecurityInterceptor    : Did not re-authenticate JwtAuthenticationToken [Principal=org.springframework.security.oauth2.jwt.Jwt@6bc00fb2, Credentials=[PROTECTED], Authenticated=true, Details=WebAuthenticationDetails [RemoteIpAddress=127.0.0.1, SessionId=null], Granted Authorities=[ROLE_CREATE, ROLE_MANAGE, ROLE_DEPLOY, ROLE_MODIFY, ROLE_DESTROY, ROLE_SCHEDULE, ROLE_VIEW]] before authorizing
2022-03-23 14:48:04.419 TRACE 5132 --- [nio-9445-exec-9] o.s.s.w.a.i.FilterSecurityInterceptor    : Authorizing filter invocation [POST /apps/task/my-task-process/1.7.4.90-SNAPSHOT] with attributes [hasRole('ROLE_CREATE')]
2022-03-23 14:48:04.419 DEBUG 5132 --- [nio-9445-exec-9] o.s.s.w.a.i.FilterSecurityInterceptor    : Authorized filter invocation [POST /apps/task/my-task-process/1.7.4.90-SNAPSHOT] with attributes [hasRole('ROLE_CREATE')]
2022-03-23 14:48:04.419 TRACE 5132 --- [nio-9445-exec-9] o.s.s.w.a.i.FilterSecurityInterceptor    : Did not switch RunAs authentication since RunAsManager returned null
2022-03-23 14:48:04.419 DEBUG 5132 --- [nio-9445-exec-9] o.s.security.web.FilterChainProxy        : Secured POST /apps/task/my-task-process/1.7.4.90-SNAPSHOT
2022-03-23 14:48:46.327 ERROR 5132 --- [nio-9445-exec-9] o.s.c.d.s.c.RestControllerAdvice         : Caught exception while handling a request

java.lang.NullPointerException: null
        at java.base/java.util.Objects.requireNonNull(Objects.java:221)
        at java.base/java.util.Optional.<init>(Optional.java:107)
        at java.base/java.util.Optional.of(Optional.java:120)
        at org.springframework.cloud.dataflow.server.service.SpringSecurityAuditorAware.getCurrentAuditor(SpringSecurityAuditorAware.java:45)
        at java.base/java.util.Optional.map(Optional.java:265)
        at org.springframework.data.auditing.AuditingHandler.getAuditor(AuditingHandler.java:109)
        at org.springframework.data.auditing.AuditingHandler.markCreated(AuditingHandler.java:92)
        at org.springframework.data.jpa.domain.support.AuditingEntityListener.touchForCreate(AuditingEntityListener.java:92)
        at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
        at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
        at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
        at java.base/java.lang.reflect.Method.invoke(Method.java:566)
        at org.hibernate.jpa.event.internal.ListenerCallback.performCallback(ListenerCallback.java:35)
        at org.hibernate.jpa.event.internal.CallbackRegistryImpl.callback(CallbackRegistryImpl.java:95)
        at org.hibernate.jpa.event.internal.CallbackRegistryImpl.preCreate(CallbackRegistryImpl.java:55)
        at org.hibernate.event.internal.AbstractSaveEventListener.saveWithGeneratedId(AbstractSaveEventListener.java:108)
@github-actions github-actions bot added the status/need-triage Team needs to triage and take a first look label Mar 23, 2022
@jvalkeal jvalkeal added type/bug Is a bug report and removed status/need-triage Team needs to triage and take a first look labels Apr 6, 2022
@jvalkeal jvalkeal added this to the 2.10.0-M2 milestone Apr 6, 2022
@onobc onobc closed this as completed in b8bf2de Apr 7, 2022
@markpollack markpollack modified the milestones: 2.10.0-M2, 2.10.0-M3 Aug 17, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
type/bug Is a bug report
Development

Successfully merging a pull request may close this issue.

4 participants