Skip to content

Deny status 401 #11

Closed
Closed

Description

@lastlegion

How to return 401s to the client on auth failure.

frontend http
	# *snip*
	
	http-request deny if ! { var(txn.auth_response_successful) -m bool }

will return 403.

we can use

frontend http
	# *snip*
	
	http-request auth if ! { var(txn.auth_response_successful) -m bool }

But it'll return 401 with basic auth instead of bearer token. Do you have any workaround for this?

Activity

  1. TimWolla commented on Nov 22, 2019

    @TimWolla
    Owner
  2. lastlegion commented on Nov 22, 2019

    @lastlegion
    Author

    Hi @TimWolla, thanks for responding. For deny_status the list of permitted status codes is limited to those that can be overridden by the "errorfile" directive. 401 is not in the "errorfile" directive. https://cbonte.github.io/haproxy-dconv/1.7/configuration.html

  3. TimWolla commented on Nov 22, 2019

    @TimWolla
    Owner

    @lastlegion Yes, I'm aware of that limitation, but I incorrectly assumed that 401 would be on that list.

    As you need to have Lua anyway in order to run this script I guess the best solution for your use case is to add a Lua "service" to generate the correct response. An example can be found on this blog post: https://www.haproxy.com/de/blog/5-ways-to-extend-haproxy-with-lua/

  4. lastlegion commented on Nov 24, 2019

    @lastlegion
    Author

    Hi @TimWolla, thanks for the suggestion! That looks like it'll work. Great job with the library.

  5. Repository owner locked and limited conversation to collaborators on May 19, 2022
  6. converted this issue into a discussion #52 on May 19, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    questionFurther information is requested

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions