Skip to content

NIFI-10322 Correct Cookie path when removing Bearer Token#6278

Closed
exceptionfactory wants to merge 1 commit intoapache:mainfrom
exceptionfactory:NIFI-10322
Closed

NIFI-10322 Correct Cookie path when removing Bearer Token#6278
exceptionfactory wants to merge 1 commit intoapache:mainfrom
exceptionfactory:NIFI-10322

Conversation

@exceptionfactory
Copy link
Copy Markdown
Contributor

Summary

NIFI-10322 Corrects path attribute building when sending the Set-Cookie header to remove the __Secure-Authorization-Bearer Cookie as part of HTTP 401 Unauthorized response processing.

When access Apache NiFi through a proxy server that provides access through a prefixed path, the HTTP response processing does not append a / character to the path attribute to the Set-Cookie as part of the 401 Unauthorized response handling. The initial login process does append the / character to the path attribute, resulting in a mismatch between the initial addition of the Cookie and the later request to remove the Cookie from browser storage. As a result of failing to remove the Cookie from browser storage, the browser continues to send an expired JSON Web Token, resulting in an HTTP 401 Unauthorized response.

Changes include setting the root path in the RequestUriBuilder, following the same pattern used in application REST resources, and updating unit tests to verify the expected path for both the default root path as well as a forwarded root path.

Tracking

Please complete the following tracking steps prior to pull request creation.

Issue Tracking

Pull Request Tracking

  • Pull Request title starts with Apache NiFi Jira issue number, such as NIFI-00000
  • Pull Request commit message starts with Apache NiFi Jira issue number, as such NIFI-00000

Pull Request Formatting

  • Pull Request based on current revision of the main branch
  • Pull Request refers to a feature branch with one commit containing changes

Verification

Please indicate the verification steps performed prior to pull request creation.

Build

  • Build completed using mvn clean install -P contrib-check
    • JDK 8
    • JDK 11
    • JDK 17

Licensing

  • New dependencies are compatible with the Apache License 2.0 according to the License Policy
  • New dependencies are documented in applicable LICENSE and NOTICE files

Documentation

  • Documentation formatting appears as expected in rendered files

- Appended root path to Cookie path attribute when removing Bearer Tokens as part of unauthorized response handling
- Updated Saml2AuthenticationSuccessHandler to follow standard Cookie path building strategy
@thenatog
Copy link
Copy Markdown
Contributor

thenatog commented Aug 9, 2022

Will review

@thenatog
Copy link
Copy Markdown
Contributor

thenatog commented Aug 9, 2022

Tried setting up a reverse proxy to test this but I had some issues. I did verify that normal bearer token functionality is still working with LDAP for example (checked that when logging out, the cookie removed correctly). I verified the change through your unit test and it looks good to me. +1 will merge.

@thenatog thenatog closed this in 77033ec Aug 9, 2022
p-kimberley pushed a commit to p-kimberley/nifi that referenced this pull request Oct 15, 2022
- Appended root path to Cookie path attribute when removing Bearer Tokens as part of unauthorized response handling
- Updated Saml2AuthenticationSuccessHandler to follow standard Cookie path building strategy

Signed-off-by: Nathan Gough <thenatog@gmail.com>

This closes apache#6278.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants