In an API I have there’s a requirement to use an authentication method other than OAuth2 or any kind of token generation which requires making an extra HTTP call.

With this in mind there’s this https://www.xml.com/pub/a/2003/12/17/dive.html
I’ve only stored passwords as hashes and used functions like password_verify to know the user sent the proper credentials without actually knowing the password stored in DB.
WSSE requires to encrypt with SHA1 the credentials being sent, which means the API needs to retrieve the password in plain text to recreate the digest and compare it to the one sent by the user.
So, how should I be storing this password if the code needs it to recreate the hash?
Should I have something like a master password and store them encrypted instead of hashed?


Most of the information I’ve found about WSSE is very very old, and some implementations have it marked as deprecated, do you know any other type of standard authentication where the user can generate the token instead of having to make an extra HTTP call?

  • @pe1ucaOP
    link
    fedilink
    19 months ago

    Thanks for all the information and advises!

    So in theory basic auth is enough when sent through HTTPS, right?
    If this is the case then the user would need to handle their password and my API can keep storing just the hash.

    In another comment JWT was suggested, maybe this could also be a solution?
    I’m thinking the user can worry about generating and signing the token and we could only be storing the public key , which requires less strictness when handling it, this way we can validate the token has been signed by who we expect and the user will worry about the private key.

    • @MajorHavoc@lemmy.world
      link
      fedilink
      29 months ago

      So in theory basic auth is enough when sent through HTTPS, right?

      Yes. Don’t put nuclear weapons, health data or huge sums of money behind it, but basic Auth has been doing a fine job for a lot of things for a long time, and HTTPS is a complete solution (until the next time it gets owned).

      If this is the case then the user would need to handle their password and my API can keep storing just the hash.

      Yep. The hard part is securely delivering the generated secret to them. And making sure that, the shorter and less random that secret is, the more often it gets replaced. For a lot of not-too-sensitive use cases, a phone call and a long random secret will do the job.

      In another comment JWT was suggested, maybe this could also be a solution?

      JWT is a fantastic solution, and probably the first thing you want to upgrade to if your use case needs more than Basic Auth.

      I’m thinking the user can worry about generating and signing the token and we could only be storing the public key , which requires less strictness when handling it, this way we can validate the token has been signed by who we expect and the user will worry about the private key.

      That makes sense. Note that many popular JWT libraries will do a lot of that for you.