Giter VIP home page Giter VIP logo

Comments (6)

tuupola avatar tuupola commented on May 18, 2024

It is unclear from your report what is not working. Copy pasting the code you provided and running it works as expected.

$ php -S 0.0.0.0:8080 index.php 

$ curl --include http://localhost:8080/open/test
HTTP/1.1 200 OK

Success Open

$ curl --include http://localhost:8080/close/test
HTTP/1.1 401 Unauthorized

curl --user root:t00r --include http://localhost:8080/close/test
HTTP/1.1 200 OK

Success Close

from slim-basic-auth.

1moere1 avatar 1moere1 commented on May 18, 2024

I tried it on localhost too, and there it works for me aswell. Only on an external IP it's not working. Did I forget to enable something?

When I try this on the ip then i get for the /close/test route a 500er error eventhough i don't see something being wrong with the code

from slim-basic-auth.

tuupola avatar tuupola commented on May 18, 2024

https://github.com/tuupola/slim-basic-auth#security

If you are not using https you need to specifically set secure to false.

$app->add(new \Slim\Middleware\HttpBasicAuthentication([
    "secure" => false,
    "users" => [
        "root" => "t00r",
        "user" => "passw0rd"
    ]
]));

from slim-basic-auth.

1moere1 avatar 1moere1 commented on May 18, 2024

thank you very much. this solved the problem.

from slim-basic-auth.

tuupola avatar tuupola commented on May 18, 2024

Great :)

from slim-basic-auth.

BrevAlessio avatar BrevAlessio commented on May 18, 2024

If it helps, I had a similar problem on a shaerd hosting, I solved by adding SetEnvIf Authorization "(.*)" HTTP_AUTHORIZATION=$1 to .htaccess

from slim-basic-auth.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.