Questions tagged [flask-httpauth]

Simple extension that provides Basic and Digest HTTP authentication for Flask routes.

Flask is a microframework for Python based on Werkzeug, Jinja 2 and good intentions. Flask-httpauth is built on this framework and is available at https://github.com/miguelgrinberg/flask-httpauth.

42 questions
8
votes
5 answers

Flask-HTTPAuth verify_password function not receiving username or password

When I try access a route with the @auth.login_required decorator, I am prompted with a window to enter my username and password. After entering this info, the parameters username_or_token and password for the verify_password function are ''. Why…
user2268507
6
votes
1 answer

Default login_required rather than adding decorator everywhere

I'm using Flask-HTTPAuth to handle authentication in my app. I have a lot of views, and I don't want to add login_required to every one of them. How can I make login required by default? from flask.ext.httpauth import HTTPBasicAuth auth =…
Ohad Perry
  • 1,315
  • 2
  • 15
  • 26
6
votes
2 answers

flask http-auth and unittesting

Hi! I have a route that I have protected using HTTP Basic authentication, which is implemented by Flask-HTTPAuth. Everything works fine (i can access the route) if i use curl, but when unit testing, the route can't be accessed, even though i provide…
stensootla
  • 13,945
  • 9
  • 45
  • 68
5
votes
2 answers

flask-httpauth: How is get_password decorator meant to work for basic-auth?

I wonder if anyone has used this flask extension to simplify the http-basic-auth. Basically I don't understand this example: users = { "john": "hello", "susan": "bye" } @auth.get_password def get_pw(username): if username in users: …
Houman
  • 64,245
  • 87
  • 278
  • 460
4
votes
3 answers

Check if Flask-HTTPAuth is authenticated inside view

I'm using Flask-HTTPAuth for authentication. I want to display different data from a view depending on if the request was authenticated or not. Decorating the view with auth.login_required only shows it to authenticated users. How can I test if the…
Shahryar Saljoughi
  • 2,599
  • 22
  • 41
4
votes
5 answers

Conditionally applying Flask-HTTPAuth's login_required decorator

I'm trying to apply a decorator (Flask-HTTPAuth's login_required) conditionally. If sky_is_blue == True, I want to apply the decorator, if False, to not. This needs to happen on call, as it could change during the lifetime of the application…
Alex Forbes
  • 3,039
  • 2
  • 19
  • 22
3
votes
3 answers

Using a Celery worker to interact with a SQLAlchemy DB, including knowing the user from the request

I have done plenty of research on this, including trying answers like this. It appears Celery has no access to my Flask app's context. I know fully well my celery object, what will decorate my tasks, must have access to my Flask app's context. And I…
Zeke Marffy
  • 188
  • 3
  • 14
3
votes
2 answers

How do I unit test HTTP Digest Authentication in Flask?

I've got a flask app that implements a REST api. For reasons, I'm using HTTP Digest Authentication. I've used the Flask-HTTPAuth library to implement the digest authentication and it works; however, I am unable to authenticate in the unit tests.…
3
votes
2 answers

flask-restful with flask-auth :multiple HTTP method with different authentication

i'm trying to have same url that have multiple HTTP (GET,POST,PUT,DELETE) method and for each method it has different authentication using flask-auth. i tried creating more than class like class GetUser(Resource): decorators =…
Hamoudaq
  • 1,490
  • 4
  • 23
  • 42
2
votes
1 answer

How to get Params from the URL to the Authentification function? (Python, Flask)

I would like to get the Parameter "organisation" from the URL into my flask-httpauth password verification function. By now I just can get the value into my normal function: @app.route('/api//admin/todo',…
levi.hrb
  • 51
  • 6
2
votes
1 answer

Create privileged users with Flask-HTTPAuth by chaining decorators --- losing context?

I'm trying to create a two-tiered authentication system with basic auth, using Flask-HTTPAuth. My application has two routes, a base route at / accessible to any logged in user, and an admin route at /admin accessible only to users who are (as you…
2
votes
1 answer

flask_httpauth decorators missing required positional argument f

I've been working with some of Miguel Grinberg's auth tutorials and have come across an issue using flask_httpauth's HTTPBasicAuth decorators. Whenever I use one of them on a function I get an error stating that the decorator is missing required…
JwM
  • 354
  • 2
  • 15
2
votes
1 answer

Trouble importing HTTPTokenAuth from flask_httpauth

I am trying to use token authentication for a Flask project. from flask_httpauth import HTTPBasicAuth # works from flask_httpauth import HTTPTokenAuth # does not work. I get the following error ImportError: cannot import name HTTPTokenAuth I…
2
votes
3 answers

I am restructuring my Flask-restful app, but having trouble placing the HTTP-auth in order to get app running

Essentially, I have a directory as such: /app runserver.py /myapp __init__.py api.py auth.py /resources __init.py users.py login.py /models __init.py models.py /common /assets In my…
Peter Li
  • 309
  • 3
  • 11
1
vote
1 answer

flask restful api dynamic endpoints with restrictions

So i am relatively new to flask only a couple weeks. To learn flask more I have set myself an objective on building my own api. use case of the API: authenticated users should be able to hit the endpoint www.mydomain.com/api/ and do the below…
RooneyMUFC
  • 103
  • 2
  • 11
1
2 3