Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add SPNEGO authentication header #107

Open
wants to merge 2 commits into
base: master
Choose a base branch
from

Conversation

TheLydonKing
Copy link
Collaborator

Added WWW-Authentication: Negotiate Header to 401 Status response when Kerberos is enabled

closes #106

@TheLydonKing TheLydonKing self-assigned this Nov 15, 2024
@TheLydonKing TheLydonKing linked an issue Nov 15, 2024 that may be closed by this pull request
Copy link

github-actions bot commented Nov 15, 2024

JaCoCo code coverage report - scala:2.12.17

File Coverage [84.91%] 🍏
SecurityConfig.scala 84.91% 🍏
Total Project Coverage 62.72% 🍏

Copy link
Collaborator

@dk1844 dk1844 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There is also the matter of existing Swagger v3 OAS Annotations (aka OpenAPI docs) - this has bears no information about the Negotiate Auth option.
GET http://localhost:9090/v3/api-docs.yaml gives

  /token/generate:
    post:
      security:
      - basicAuth: []
  ...
  securitySchemes:
    basicAuth:
      type: http
      scheme: basic
...

but it should probably give

  /token/generate:
    post:
      security:
      - negotiate: []
      - basicAuth: []
  ...
  securitySchemes:
    negotiate:
      type: http
      scheme: negotiate
    basicAuth:
      type: http
      scheme: basic

I think that the solution might be adding another

  @SecurityRequirement(name = "negotiate")

and introducing something like

@SecurityScheme(
  name = "negotiate",
  `type` = SecuritySchemeType.HTTP,
  scheme = "negotiate"
)

I am not sure that it is entirely correct (perhaps do your own research how it should be done properly, but something along these lines

response: HttpServletResponse,
authException: AuthenticationException) => {
response.setStatus(HttpServletResponse.SC_UNAUTHORIZED)
response.addHeader("WWW-Authenticate", "Negotiate")
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I tried it and when kerberos was disabled in config, running a POST against the endpoint ( curl -X POST http://localhost:9090/token/generate -v) resulted only in:
< WWW-Authenticate: Basic realm="Realm"
(as expected ✅ ).

However, when running the same while having kerberos enabled in config, it only returned
< WWW-Authenticate: Negotiate
This time I would expect both options being present in the headers:
< WWW-Authenticate: Basic realm="Realm"
< WWW-Authenticate: Negotiate

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.

Add SPNEGO auth to response headers
2 participants