Based on the title you’re right, I asked about how to do X when probably I need to do Y, but the first and last paragraphs mention what’s my requirement: a for of authentication which doesn’t require to make an extra HTTP call to generate a token.
And what I mean by this is OAuth specifies the client needs to request an access token and an optional refresh token to the authorization server, afterwards the access token can be sent to the resource server (in this case my API), if the token expires the client can make another request to the authorization server with the refresh token.
Each call to the authorization server is that “extra http call” I mentioned.
Currently the only solution I found which seemed somewhat secure was WSSE, but again, I’ve only worked with OAuth2 and hashing passwords (or even better, using a dedicated service like keycloak), so I’m not sure what’s the best option to store the data it requires or if there’s a better solution.
I don’t know how to be more clear, is there a way to authenticate a client to the resource server (my API) without making the client call endpoints to generate the tokens? Is there a way for the client to generate their own tokens and for me to validate them?
towerful@programming.dev 1 year ago
As for client side token generation…
Never trust the client.
Say you hash the password client side. At this point, you have to have static salt (which can be extracted from clients), and the hashed result becomes the password.
All of this greatly weakens the security.
If the client sends a username, and the server returns a salt, then it’s a bit more secure. At least this way the salt can be randomly generated for each user.
But, it’s an extra API call.
You could use the username as the salt. This makes things a bit better, but you open yourself to being rainbow-tabled for usernames like “admin”. Also, the salt doesn’t change when a password is updated.
Here’s a SE post that kinda pertains to what you want:
…stackexchange.com/…/how-to-do-client-side-hashin…
This one has a section on client side hashing:
security.stackexchange.com/questions/211/…/31846#…