0

Apache 2.4.51.

I need to extract a token from the QUERY_STRING and use it in a AuthBaiscFake directive.

The incoming request is:

GET /p000/vm/0/0?auth-token=HAI6i1eMT/uNeaIRpYw1Ww==&removable&readonly

In the HTTPD configuration file, the end result after variable substitution ought to be:

      AuthBasicFake nobody HAI6i1eMT/uNeaIRpYw1Ww==

The 2nd Elseif clause below shows what I'm trying to achieve, but it does not work. I've also tried using named variables in place of backreferences. What am I missing?

    <If "-n req('Authorization')">
      RequestHeader unset X-Auth-Token
    </If>
    <Elseif "-n req('X-Auth-Token')">
      AuthBasicFake nobody  "%{HTTP:X-Auth-Token}"
    </Elseif>
    #
    # Why doesn't variable substitution for "$2" work in the next Elseif clause???
    #
    <Elseif "%{QUERY_STRING} =~ m#(^|&)auth-token=(.*)($|&)#i">
      AuthBasicFake nobody "$2"
    </Elseif>
    <Else>
      LogMessage "CLIENT ERROR: No Authorization credentials provided in request"
    </Else>
Matt Muggeridge
  • 465
  • 3
  • 11

0 Answers0