-
-
Notifications
You must be signed in to change notification settings - Fork 455
Make Endpoint respond with a 401 status code if the Authorization header is missing #3281
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
base: main
Are you sure you want to change the base?
Conversation
maybeUnauthedResponse.get | ||
case Some(_) => | ||
case Some(HttpCodecError.MissingAuthorizationHeader) => | ||
Handler.succeed(Response.unauthorized) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Let me know if this should be reported the same way as any other missing header.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The specs say, that we have to return acceptable auth methods.
And we have that data from the Endpoint API
The server generating a 401 response MUST send
a WWW-Authenticate header field (Section 4.1) containing at least one
challenge applicable to the target resource.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Most things are optional and can be omitted. Digest nonce is generated anyway.
Basic Digest and OAuth need a realm. We can add this to AuthType
in the same fashion like ScopedAuth
.
In case there is no realm, we could return no header or a default value. I tend to a default value. Like "default"
or "restricted"
zio-http/shared/src/main/scala/zio/http/endpoint/Endpoint.scala
Outdated
Show resolved
Hide resolved
zio-http/shared/src/main/scala/zio/http/codec/HttpCodecError.scala
Outdated
Show resolved
Hide resolved
I suspect |
Hi @987Nabil — could you please take a look at the PR? The suspected tests are indeed flaky, the tests were green before I merged master. And now it failed again. |
Hey @jdegoes — could you please take a look at this? |
@Omar8345 I did no get any response from the maintainers so I don't really know. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sorry for the late review. I hope you can still work on this :)
zio-http/shared/src/main/scala/zio/http/codec/HttpCodecError.scala
Outdated
Show resolved
Hide resolved
zio-http/shared/src/main/scala/zio/http/endpoint/Endpoint.scala
Outdated
Show resolved
Hide resolved
maybeUnauthedResponse.get | ||
case Some(_) => | ||
case Some(HttpCodecError.MissingAuthorizationHeader) => | ||
Handler.succeed(Response.unauthorized) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The specs say, that we have to return acceptable auth methods.
And we have that data from the Endpoint API
The server generating a 401 response MUST send
a WWW-Authenticate header field (Section 4.1) containing at least one
challenge applicable to the target resource.
@notxcain I think errors of decoding the header should also lead to 401 |
❌ Deploy Preview for zio-http failed. Why did it fail? →
|
The link says explicitly that malformed is 401 🤔
|
/claim #3235