[ 
https://issues.apache.org/jira/browse/NIFI-10606?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel
 ]

David Handermann resolved NIFI-10606.
-------------------------------------
    Resolution: Information Provided

Closing based on current answer provided, feel free to reopen if the answer 
does not resolve the problem.

> Connection to Nifi API only succeeds sometimes(invalid token)
> -------------------------------------------------------------
>
>                 Key: NIFI-10606
>                 URL: https://issues.apache.org/jira/browse/NIFI-10606
>             Project: Apache NiFi
>          Issue Type: Bug
>          Components: Security
>    Affects Versions: 1.16.3
>            Reporter: Andreas Adamides
>            Assignee: David Handermann
>            Priority: Major
>
> Sometimes the connection to Nifi API succeeds, sometimes it doesn't.
>  
> When it doesn't, I get this:
>  
> {code:java}
> nipyapi.nifi.rest.ApiException: (401)61Reason: Unauthorized62HTTP response 
> headers: HTTPHeaderDict({'Date': 'Thu, 06 Oct 2022 13:06:14 GMT', 
> 'Content-Length': '0', 'Connection': 'keep-alive', 'Set-Cookie': 
> 'AWSALB=jc7aAv/roBICNC7Bpwr3Ks/bZBi2sCnRsIxUxipL1ytibmVcosZZYqP0bw5226jWB9apcQ5iEpGLbwMc0JjKKqykbR69hmT9OJA8EwtvVIoLFBRABlYwzvq7yXFK;
>  Expires=Thu, 13 Oct 2022 13:06:14 GMT; Path=/, 
> AWSALBCORS=jc7aAv/roBICNC7Bpwr3Ks/bZBi2sCnRsIxUxipL1ytibmVcosZZYqP0bw5226jWB9apcQ5iEpGLbwMc0JjKKqykbR69hmT9OJA8EwtvVIoLFBRABlYwzvq7yXFK;
>  Expires=Thu, 13 Oct 2022 13:06:14 GMT; Path=/; SameSite=None; Secure, 
> __Secure-Request-Token=0d8151fd-782a-480d-9b51-506bf8dedde4; Path=/; Secure', 
> 'X-Frame-Options': 'SAMEORIGIN', 'Content-Security-Policy': "frame-ancestors 
> 'self'", 'X-XSS-Protection': '1; mode=block', 'X-Content-Type-Options': 
> 'nosniff', 'Strict-Transport-Security': 'max-age=31540000', 'Expires': 'Thu, 
> 01 Jan 1970 00:00:00 GMT', 'WWW-Authenticate': 'Bearer error="invalid_token", 
> error_description="An error occurred while attempting to decode the Jwt: 
> Signed JWT rejected: Another algorithm expected, or no matching key(s) 
> found", error_uri="https://tools.ietf.org/html/rfc6750#section-3.1";', 
> 'Server': 'Jetty(9.4.46.v20220331)'}) {code}
> And the Nifi CLuster node user log entry:
>  
> {code:java}
> 2022-10-05 15:38:48,529 ERROR [NiFi Web Server-22] 
> o.a.nifi.web.api.config.ThrowableMapper An unexpected error has occurred: 
> org.springframework.security.oauth2.server.resource.InvalidBearerTokenException:
>  An error occurred while attempting to decode the Jwt: Signed JWT rejected: 
> Another algorithm expected, or no matching key(s) found. Returning Internal 
> Server Error response.
> org.springframework.security.oauth2.server.resource.InvalidBearerTokenException:
>  An error occurred while attempting to decode the Jwt: Signed JWT rejected: 
> Another algorithm expected, or no matching key(s) found
>         at 
> org.springframework.security.oauth2.server.resource.authentication.JwtAuthenticationProvider.getJwt(JwtAuthenticationProvider.java:101)
>         at 
> org.springframework.security.oauth2.server.resource.authentication.JwtAuthenticationProvider.authenticate(JwtAuthenticationProvider.java:88)
>         at 
> org.apache.nifi.web.api.AccessResource.getAccessStatus(AccessResource.java:252)
>         at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
>         at 
> sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
>         at 
> sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
>         at java.lang.reflect.Method.invoke(Method.java:498)
>         at 
> org.glassfish.jersey.server.model.internal.ResourceMethodInvocationHandlerFactory.lambda$static$0(ResourceMethodInvocationHandlerFactory.java:52)
>         at 
> org.glassfish.jersey.server.model.internal.AbstractJavaResourceMethodDispatcher$1.run(AbstractJavaResourceMethodDispatcher.java:124)
>         at 
> org.glassfish.jersey.server.model.internal.AbstractJavaResourceMethodDispatcher.invoke(AbstractJavaResourceMethodDispatcher.java:167)
>         at 
> org.glassfish.jersey.server.model.internal.JavaResourceMethodDispatcherProvider$ResponseOutInvoker.doDispatch(JavaResourceMethodDispatcherProvider.java:176)
>         at 
> org.glassfish.jersey.server.model.internal.AbstractJavaResourceMethodDispatcher.dispatch(AbstractJavaResourceMethodDispatcher.java:79)
>         at 
> org.glassfish.jersey.server.model.ResourceMethodInvoker.invoke(ResourceMethodInvoker.java:475)
>         at 
> org.glassfish.jersey.server.model.ResourceMethodInvoker.apply(ResourceMethodInvoker.java:397)
>         at 
> org.glassfish.jersey.server.model.ResourceMethodInvoker.apply(ResourceMethodInvoker.java:81)
>         at 
> org.glassfish.jersey.server.ServerRuntime$1.run(ServerRuntime.java:255)
>         at org.glassfish.jersey.internal.Errors$1.call(Errors.java:248)
>         at org.glassfish.jersey.internal.Errors$1.call(Errors.java:244)
>         at org.glassfish.jersey.internal.Errors.process(Errors.java:292)
>         at org.glassfish.jersey.internal.Errors.process(Errors.java:274)
>         at org.glassfish.jersey.internal.Errors.process(Errors.java:244)
>         at 
> org.glassfish.jersey.process.internal.RequestScope.runInScope(RequestScope.java:265)
>         at 
> org.glassfish.jersey.server.ServerRuntime.process(ServerRuntime.java:234)
>         at 
> org.glassfish.jersey.server.ApplicationHandler.handle(ApplicationHandler.java:684)
>         at 
> org.glassfish.jersey.servlet.WebComponent.serviceImpl(WebComponent.java:394)
>         at 
> org.glassfish.jersey.servlet.WebComponent.service(WebComponent.java:346)
>         at 
> org.glassfish.jersey.servlet.ServletContainer.service(ServletContainer.java:366)
>         at 
> org.glassfish.jersey.servlet.ServletContainer.service(ServletContainer.java:319)
>         at 
> org.glassfish.jersey.servlet.ServletContainer.service(ServletContainer.java:205)
>         at 
> org.eclipse.jetty.servlet.ServletHolder$NotAsync.service(ServletHolder.java:1459)
>         at 
> org.eclipse.jetty.servlet.ServletHolder.handle(ServletHolder.java:799)
>         at 
> org.eclipse.jetty.servlet.ServletHandler$ChainEnd.doFilter(ServletHandler.java:1631)
>         at 
> org.springframework.security.web.FilterChainProxy.doFilterInternal(FilterChainProxy.java:204)
>         at 
> org.springframework.security.web.FilterChainProxy.doFilter(FilterChainProxy.java:183)
>         at 
> org.springframework.web.filter.DelegatingFilterProxy.invokeDelegate(DelegatingFilterProxy.java:354)
>         at 
> org.springframework.web.filter.DelegatingFilterProxy.doFilter(DelegatingFilterProxy.java:267)
>         at 
> org.eclipse.jetty.servlet.FilterHolder.doFilter(FilterHolder.java:193)
>         at 
> org.eclipse.jetty.servlet.ServletHandler$Chain.doFilter(ServletHandler.java:1601)
>         at 
> org.apache.nifi.web.filter.ExceptionFilter.doFilter(ExceptionFilter.java:46)
>         at 
> org.eclipse.jetty.servlet.FilterHolder.doFilter(FilterHolder.java:201)
>         at 
> org.eclipse.jetty.servlet.ServletHandler$Chain.doFilter(ServletHandler.java:1601)
>         at 
> org.eclipse.jetty.servlets.DoSFilter.doFilterChain(DoSFilter.java:487)
>         at 
> org.apache.nifi.web.server.filter.DataTransferExcludedDoSFilter.doFilterChain(DataTransferExcludedDoSFilter.java:51)
>         at org.eclipse.jetty.servlets.DoSFilter.doFilter(DoSFilter.java:336)
>         at org.eclipse.jetty.servlets.DoSFilter.doFilter(DoSFilter.java:301)
>         at 
> org.eclipse.jetty.servlet.FilterHolder.doFilter(FilterHolder.java:193)
>         at 
> org.eclipse.jetty.servlet.ServletHandler$Chain.doFilter(ServletHandler.java:1601)
>         at 
> org.apache.nifi.web.server.log.RequestAuthenticationFilter.doFilterInternal(RequestAuthenticationFilter.java:59)
>         at 
> org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:117)
>         at 
> org.eclipse.jetty.servlet.FilterHolder.doFilter(FilterHolder.java:193)
>         at 
> org.eclipse.jetty.servlet.ServletHandler$Chain.doFilter(ServletHandler.java:1601)
>         at 
> org.apache.nifi.web.security.headers.StrictTransportSecurityFilter.doFilter(StrictTransportSecurityFilter.java:48)
>         at 
> org.eclipse.jetty.servlet.FilterHolder.doFilter(FilterHolder.java:193)
>         at 
> org.eclipse.jetty.servlet.ServletHandler$Chain.doFilter(ServletHandler.java:1601)
>         at 
> org.apache.nifi.web.security.headers.XContentTypeOptionsFilter.doFilter(XContentTypeOptionsFilter.java:48)
>         at 
> org.eclipse.jetty.servlet.FilterHolder.doFilter(FilterHolder.java:193)
>         at 
> org.eclipse.jetty.servlet.ServletHandler$Chain.doFilter(ServletHandler.java:1601)
>         at 
> org.apache.nifi.web.security.headers.XSSProtectionFilter.doFilter(XSSProtectionFilter.java:48)
>         at 
> org.eclipse.jetty.servlet.FilterHolder.doFilter(FilterHolder.java:193)
>         at 
> org.eclipse.jetty.servlet.ServletHandler$Chain.doFilter(ServletHandler.java:1601)
>         at 
> org.apache.nifi.web.security.headers.ContentSecurityPolicyFilter.doFilter(ContentSecurityPolicyFilter.java:47)
>         at 
> org.eclipse.jetty.servlet.FilterHolder.doFilter(FilterHolder.java:193)
>         at 
> org.eclipse.jetty.servlet.ServletHandler$Chain.doFilter(ServletHandler.java:1601)
>         at 
> org.apache.nifi.web.security.headers.XFrameOptionsFilter.doFilter(XFrameOptionsFilter.java:48)
>         at 
> org.eclipse.jetty.servlet.FilterHolder.doFilter(FilterHolder.java:193)
>         at 
> org.eclipse.jetty.servlet.ServletHandler$Chain.doFilter(ServletHandler.java:1601)
>         at 
> org.eclipse.jetty.servlet.ServletHandler.doHandle(ServletHandler.java:548)
>         at 
> org.eclipse.jetty.server.handler.ScopedHandler.handle(ScopedHandler.java:143)
>         at 
> org.eclipse.jetty.security.SecurityHandler.handle(SecurityHandler.java:600)
>         at 
> org.eclipse.jetty.server.handler.HandlerWrapper.handle(HandlerWrapper.java:127)
>         at 
> org.eclipse.jetty.server.handler.ScopedHandler.nextHandle(ScopedHandler.java:235)
>         at 
> org.eclipse.jetty.server.session.SessionHandler.doHandle(SessionHandler.java:1624)
>         at 
> org.eclipse.jetty.server.handler.ScopedHandler.nextHandle(ScopedHandler.java:233)
>         at 
> org.eclipse.jetty.server.handler.ContextHandler.doHandle(ContextHandler.java:1440)
>         at 
> org.eclipse.jetty.server.handler.ScopedHandler.nextScope(ScopedHandler.java:188)
>         at 
> org.eclipse.jetty.servlet.ServletHandler.doScope(ServletHandler.java:501)
>         at 
> org.eclipse.jetty.server.session.SessionHandler.doScope(SessionHandler.java:1594)
>         at 
> org.eclipse.jetty.server.handler.ScopedHandler.nextScope(ScopedHandler.java:186)
>         at 
> org.eclipse.jetty.server.handler.ContextHandler.doScope(ContextHandler.java:1355)
>         at 
> org.eclipse.jetty.server.handler.ScopedHandler.handle(ScopedHandler.java:141)
>         at 
> org.eclipse.jetty.server.handler.HandlerCollection.handle(HandlerCollection.java:146)
>         at 
> org.eclipse.jetty.server.handler.gzip.GzipHandler.handle(GzipHandler.java:763)
>         at 
> org.eclipse.jetty.server.handler.ContextHandlerCollection.handle(ContextHandlerCollection.java:191)
>         at 
> org.eclipse.jetty.server.handler.HandlerList.handle(HandlerList.java:59)
>         at 
> org.eclipse.jetty.server.handler.HandlerWrapper.handle(HandlerWrapper.java:127)
>         at org.eclipse.jetty.server.Server.handle(Server.java:516)
>         at 
> org.eclipse.jetty.server.HttpChannel.lambda$handle$1(HttpChannel.java:487)
>         at org.eclipse.jetty.server.HttpChannel.dispatch(HttpChannel.java:732)
>         at org.eclipse.jetty.server.HttpChannel.handle(HttpChannel.java:479)
>         at 
> org.eclipse.jetty.server.HttpConnection.onFillable(HttpConnection.java:277)
>         at 
> org.eclipse.jetty.io.AbstractConnection$ReadCallback.succeeded(AbstractConnection.java:311)
>         at org.eclipse.jetty.io.FillInterest.fillable(FillInterest.java:105)
>         at 
> org.eclipse.jetty.io.ssl.SslConnection$DecryptedEndPoint.onFillable(SslConnection.java:555)
>         at 
> org.eclipse.jetty.io.ssl.SslConnection.onFillable(SslConnection.java:410)
>         at 
> org.eclipse.jetty.io.ssl.SslConnection$2.succeeded(SslConnection.java:164)
>         at org.eclipse.jetty.io.FillInterest.fillable(FillInterest.java:105)
>         at 
> org.eclipse.jetty.io.ChannelEndPoint$1.run(ChannelEndPoint.java:104)
>         at 
> org.eclipse.jetty.util.thread.strategy.EatWhatYouKill.runTask(EatWhatYouKill.java:338)
>         at 
> org.eclipse.jetty.util.thread.strategy.EatWhatYouKill.doProduce(EatWhatYouKill.java:315)
>         at 
> org.eclipse.jetty.util.thread.strategy.EatWhatYouKill.tryProduce(EatWhatYouKill.java:173)
>         at 
> org.eclipse.jetty.util.thread.strategy.EatWhatYouKill.run(EatWhatYouKill.java:131)
>         at 
> org.eclipse.jetty.util.thread.ReservedThreadExecutor$ReservedThread.run(ReservedThreadExecutor.java:409)
>         at 
> org.eclipse.jetty.util.thread.QueuedThreadPool.runJob(QueuedThreadPool.java:883)
>         at 
> org.eclipse.jetty.util.thread.QueuedThreadPool$Runner.run(QueuedThreadPool.java:1034)
>         at java.lang.Thread.run(Thread.java:750)
> Caused by: org.springframework.security.oauth2.jwt.BadJwtException: An error 
> occurred while attempting to decode the Jwt: Signed JWT rejected: Another 
> algorithm expected, or no matching key(s) found
>         at 
> org.springframework.security.oauth2.jwt.NimbusJwtDecoder.createJwt(NimbusJwtDecoder.java:180)
>         at 
> org.springframework.security.oauth2.jwt.NimbusJwtDecoder.decode(NimbusJwtDecoder.java:137)
>         at 
> org.springframework.security.oauth2.server.resource.authentication.JwtAuthenticationProvider.getJwt(JwtAuthenticationProvider.java:97)
>         ... 104 common frames omitted
> Caused by: com.nimbusds.jose.proc.BadJOSEException: Signed JWT rejected: 
> Another algorithm expected, or no matching key(s) found
>         at 
> com.nimbusds.jwt.proc.DefaultJWTProcessor.process(DefaultJWTProcessor.java:357)
>         at 
> com.nimbusds.jwt.proc.DefaultJWTProcessor.process(DefaultJWTProcessor.java:303)
>         at 
> org.springframework.security.oauth2.jwt.NimbusJwtDecoder.createJwt(NimbusJwtDecoder.java:154)
>         ... 106 common frames omitted {code}
> I am on a Nifi Cluster on EKS with 3 nodes, I have also decoded the actual 
> JWT tokens, when it works VS when it doesn't, they are exactly the same.
> Is anyone else having this issue?



--
This message was sent by Atlassian Jira
(v8.20.10#820010)

Reply via email to