Giter Site home page Giter Site logo

Comments (9)

miguelgrinberg avatar miguelgrinberg commented on June 18, 2024 1

Sorry, I dropped the ball on this. I have now release 2.7.0, which adds scheme and realm arguments to the two auth constructors. Set the scheme to anything other than Basic/Digest to prevent the browser from displaying the login prompt.

from flask-httpauth.

miguelgrinberg avatar miguelgrinberg commented on June 18, 2024

Can you be more explicit about this idea? Are you thinking in using a custom header or something else?

from flask-httpauth.

jackunion avatar jackunion commented on June 18, 2024

@miguelgrinberg Talking about this popup:
basicauth

This stackoverflow question and this blog post provide more details.

I think it's really dirty and ugly hack, but I couldn't find anything better.

from flask-httpauth.

miguelgrinberg avatar miguelgrinberg commented on June 18, 2024

Okay, this is something that is fairly easy to do, I'll look into it. My way of avoiding the login prompt was to return 403 instead of 401. I think this is still a hack, but less than switching status codes.

from flask-httpauth.

soda29 avatar soda29 commented on June 18, 2024

I would love to have this.

Where does you define to return a 403 instead of a 401?

from flask-httpauth.

miguelgrinberg avatar miguelgrinberg commented on June 18, 2024

@soda29 In the custom error handler. There you can return one, two or three values, just like you do in a regular Flask view function.

from flask-httpauth.

soda29 avatar soda29 commented on June 18, 2024

Yes sorry, i managed to change it from the custom error handler with a make_response as the documentation says.

Thanks Miguel!

from flask-httpauth.

jfpoilpret avatar jfpoilpret commented on June 18, 2024

Currently, in order to avoid browser popup, I return 401 without WWW-Authenticate header, and that does the trick.
Unfortunately, I have to somehow hack HTTPBasicAuth as follows:

auth = HTTPBasicAuth()

def auth_error_handler():
    res = make_response('Invalid credientials')
    res.status_code = 401
    return res

auth.auth_error_callback = auth_error_handler

But this short-circuits HTTPAuth @error_handler decorator which I cannot use anymore.
I think it would be much better if HTTPAuth supported a kind of no_authenticate_header flag or method to avoid this hack.

from flask-httpauth.

jfpoilpret avatar jfpoilpret commented on June 18, 2024

Great Miguel, thanks! I was using release 2.6.0.
Now everything is working fine, just using some "Dummy" authentication scheme.

from flask-httpauth.

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.