2 ms·
Not op, but I found it a bit lacking given the title. From the article: While I’ll dive further into how you actually use OAuth to protect an API in your syste
by magicalhippo 5y ago
Not op, but I found it a bit lacking given the title. From the article:
While I’ll dive further into how you actually use OAuth to protect an API in your system below, including code examples, [...]
I failed to find much concrete around how to use OAuth to protect an API, and no code samples. Is this a part one in a series? If so, it should be more clear about that perhaps.
edit: For example, I just had to secure my non-Azure API using access tokens issued by Azure AD. Lot of details[1] about how to verify that they're valid, actually issued by Azure AD (one does not simply download a certificate), and it's issued for the right thing.
That said, I found the why and standards section very nice, and the grant selection sections were helpful.
[1]: https://docs.microsoft.com/en-us/azure/active-directory/develop/access-tokens#validating-tokens https://docs.microsoft.com/en-us/azure/active-directory/deve...
- mooreds 5y ago> I failed to find much concrete around how to use OAuth to protect an API, and no code samples. I think this may have been an oversight during the final editing process. I ended up having to split this up into two articles, as you surmised. The second one is a blow by blow of the authorization code grant (and how an API should validate a token) and will be published later this week. But I should have caught that we promised the code in the intro and removed that.
- magicalhippo 5y agoJust to expand a bit on my criticism. It's called a "complete guide to protecting your APIs with OAuth", yet there's no discussion of: - Authorization server, roll your own, run your own (like Ory Hydra), or use third-party (like Azure AD)? - Tokes, if you can choose, should you go with opaque tokens, JWT or something else? What about token lifetimes? - When you get a token from a client, how do you validate that the token is valid? There's probably more, but I feel at least these points should be included in a "complete guide". Change the title and it's a fine OAuth blog post. edit: for example, add ", part 1 - introduction".
- mooreds 5y agoThanks for this critique. I have limited ability to edit the post, but will try to answer these here. > Authorization server, roll your own, run your own (like Ory Hydra), or use third-party (like Azure AD)? If by 'roll your own' you mean 'use an open source library like Python's OAuthLib', all three of these are valid options. Really hard to give general guidance because it depends on the complexity of your application environment (1 app in rails? 10 apps with mix of custom and COTS?) and operational maturity (do you want to run your own server for compliance or control reasons? do you have the skills to do so?). > Tokens, if you can choose, should you go with opaque tokens, JWT or something else? What about token lifetimes? "if you can choose" is an important clause here. Many times it'll be dictated by the Authorization server you choose. All other things being equal I'd lean toward JWTs because of their widespread support, but I know others have other opinions. Re: token lifetimes, this is something you need to threat model out (what happens if a token is stolen?). Generally recommend seconds to minutes for access tokens and longer lived refresh tokens. Also whether you should use token binding or can live with bearer tokens. > When you get a token from a client, how do you validate that the token is valid? That will be discussed in part 2 of this series, but in general you should validate the signature (if it is a signed token, often a JWT) or use introspection to ask the Authorization server if it is valid. Then you should validate the claims. There is definitely more, but thanks for the feedback!
- magicalhippo 5y agoThanks for the reply, good stuff. Most of this could go into part 2 I think. For part two I would definitely want at least some discussion around choice of authorization server. I realize a full deep dive is too much, but at least list the options (use a lib, use your own server, use third-party) with some pros and cons or something like that. If you do go into token generation and usage, and mention JWT, do mention the requirement to verify the alg field against expected value. Just given the issues it's caused in the past. Anyway, hope I wasn't being too negative, that wasn't my intention.
- mooreds 5y ago