Giter Site home page Giter Site logo

Comments (8)

miguelgrinberg avatar miguelgrinberg commented on June 10, 2024

The definition of what "password" means is up to the implementer, it does not necessarily need to be the unencrypted password selected by the user. You could return a hashed password from the get_password callback, and as long as the client applies the same hash function before submitting the password with the request things will work the same. Would that work?

from flask-httpauth.

cliffmcc avatar cliffmcc commented on June 10, 2024

I considered that. It could work, but it requires that matching hashes be calculated on the client in JS. By definition there should be nothing "secret" about the hashing algorithm, so this doesn't lower security itself, but it does mean you need hashing code in JS. However, it does lower the security-through-obscurity factor a bit, since this would make any user-specific salt publicly visible.

Overall, it would still be better to do all the hashing on the server side and send the plain password over SSL.

Not a real problem for me personally, just an observation I had while reading about this extension in your recent blog post. Nice post by the way.

from flask-httpauth.

miguelgrinberg avatar miguelgrinberg commented on June 10, 2024

I think I now understand what you are saying. What I'm missing is a callback that can optionally transform the password submitted by the client before it gets compared against the one returned by get_password. If I had that then the client sends the plain password, but the server applies the hashing function that matches what was applied prior to storing the password in the database.

Not a bad idea.

from flask-httpauth.

cliffmcc avatar cliffmcc commented on June 10, 2024

That's exactly what I was thinking. This would let the server provide arbitrary hashing algorithms. Thanks for considering it.

from flask-httpauth.

miguelgrinberg avatar miguelgrinberg commented on June 10, 2024

I've added a hash_password callback (only for basic auth).

from flask-httpauth.

lunayo avatar lunayo commented on June 10, 2024

Is it possible to get both username and password information in hash_password callback? I need username to retrieve password's salt in database before creating a hash_password for comparing. The hash_password format is probably similar to this sha(password+salt)

from flask-httpauth.

miguelgrinberg avatar miguelgrinberg commented on June 10, 2024

@lunayo Makes perfect sense. I'll look into that.

from flask-httpauth.

miguelgrinberg avatar miguelgrinberg commented on June 10, 2024

@lunayo: just pushed version 2.1.0 with this change. The hash password callback can now also take two arguments, username and password in that order.

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.