Lurker News

Comments (249) 36 threads

Earlier comments
jongpieter#
Depending on your usecase, a quick setup would be to use https://auth0.com/ They have a lot of documentation and samples to get started.

We have implemented it for authentication with a Asp.Net Core webservice, with a REST based API. Authorization is also possible, either by working with the JWT token scopes, or using the Auth0 app_metadata.

NicoJuicy#
Depends on what you want. You can just use an API key if it's for easy access, through a header.

If you want more, then use username + pass. Encrypt both or generate something from both of them. Eg. encrypt(username):encrypt(pass)
If you want more, use private & public keys, which receive a session token the first time ( when authenticating).
...
I think the end result would be a self hosted oauth server with permission management.

tboyd471 reply#
Authentication is such a mess, I don't even know where to begin. Most APIs rely on some sort of token-based auth, communicated via the header format: "Authorization: Bearer abc123", as opposed to placing it in the Cookie, as most web sites will do. Many solutions exist, like OAuth2, JWT, etc. but that's ultimately what it all boils down to.
jmulho1 reply#
Is there any reason to favor bearer tokens over cookies?
tboyd471 reply#
If you use a cookie for an API, it will look like you don't know what you are doing. Also, there are extra rules around Cookies (expiration, length, etc.) that may bite you if you use them outside a browser context.
jmulho#
Ah, so there are other contexts (e.g. native mobile apps) that may be sharing the API, not just browser (web) apps. I think I get it. Thanks.

Load more comments