this post was submitted on 25 Sep 2023
32 points (92.1% liked)

Programming

17129 readers
353 users here now

Welcome to the main community in programming.dev! Feel free to post anything relating to programming here!

Cross posting is strongly encouraged in the instance. If you feel your post or another person's post makes sense in another community cross post into it.

Hope you enjoy the instance!

Rules

Rules

  • Follow the programming.dev instance rules
  • Keep content related to programming in some way
  • If you're posting long videos try to add in some form of tldr for those who don't want to watch videos

Wormhole

Follow the wormhole through a path of communities !webdev@programming.dev



founded 1 year ago
MODERATORS
 

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?

you are viewing a single comment's thread
view the rest of the comments
[–] pe1uca@lemmy.pe1uca.dev 3 points 1 year ago (3 children)

Well, an "extra HTTP call" is any call besides the one required for the client to access my API, in this case is an extra call to generate an access token.
Why does it matter? In words of the client: "making a call to generate a token is slow"

[–] paysrenttobirds@sh.itjust.works 7 points 1 year ago (1 children)

The client is not always right. Make them define "slow" in concrete comparison to the rest of the things that happen in their product and once you have a reasonable number, I think it's likely you can beat it.

[–] pe1uca@lemmy.pe1uca.dev 2 points 1 year ago

Completely agree with you, I made that comment, but most people agreed with the client '-.-

[–] JakenVeina@lemm.ee 6 points 1 year ago* (last edited 1 year ago) (1 children)

making a call to generate a token is slow

If it was happening every page load or every API call, you might have a weak argument.

Regardless, what's the general architecture of this app? You've got an HTTP API, what else? How much is under your control, versus third parties?

[–] pe1uca@lemmy.pe1uca.dev 1 points 1 year ago (1 children)

I agree, the token has a lifespan of some hours so it could be generated after that amount of time, which for a ~400ms call is not that much, but I was overruled .-.

The only thing I control is the API, the client's implementation is outside of my control (although I know is a backend service).

[–] JakenVeina@lemm.ee 4 points 1 year ago

Okay, so you're building an API that another server needs to auth with? If the opposing side is a server, a pre-shared PKI cert ought to work. If the opposing side is a potentially-untrustworth client application, the truth is there's nothing that's going to fit such a simple definition of "extra". The back and forth it takes to establish token exchange is not "extra" is the cost you have to pay to get security.

[–] frezik@midwest.social 1 points 1 year ago

Are there a limited number of clients hitting the API? Would client side TLS certs be an option?