OAuth 2.0 Flashcards
What are the problems of credentials sharing?
The user is impersonated (app acts just like the user and has too much access.
The creds can’t be revoked (needs to change the password)
The credentials are exposed all the time.
SPA’s will never be able to store it securely.
Why cookies isn’t a solution as well?
Because of Cross-site request forgery (CSRF, aka XSRF). Meaning that any tab of the browser will be able to acess that api.
Is API key a better solution for credentials sharing? What are the remaining issues?
Yes, API keys are still acceptable because you are no longer sharing creds and you can now define scopes for the key… however api keys has no standards, has to have long expirations (e.g 90 days, when the ideal would be 1 hour).
Why is oauth the solution to all problems?
Auth is a protocol, built for http apis, scoped access… can be called delegation protocol.
What are the oauth2 players?
The protected resource (http api), the client (the app that wants to access the api, the resource owner (the user) and the authorization server which is responsible for handling the authorization requests (all parties needs to trust it).
Is Oauth for authentication? What to do then?
No, meant for authorization only. Access tokens do not represent the user. Also, client cannot reliably verify the token… Use OpenId + OAuth
What OAuth got very right?
Delegated access, api access control, separation of user and client creds, user consent.
What is the OAuth big picture?
https://pasteboard.co/JDz1kM8.png
What is a scope?
Defines how much data the client application can access.
What are the minimum query string parameters used an authorization request?
?response_type=code&
client_id=example123&
redirect_uri=https://my.client/callback
What is the recommended parameter for an authorization request? Is it often used?
state=xyz
very often.
What is the optional parameter of an authorization request? What happens when not defined?
scope=ap1 api2.read
the auth server will define a default set of scopes
What is included in an authorization response? Where is it sent to? What happens when the state does not match?
sent to https://my.client/callback?code=kAsdg412bAdfA&
state=xyz
the client ideally should reject the whole response.
What needs to be done after I get the authorization code?
Do a token request, passing the authorization code, defining the grant type as authorization_code and also defining another redirect_uri… needs to define the client id secret.
How many times I can use an authorization code?
Once.
What does it mean using basic authentication in oauth2? What it actually is asked in the docs?
we can use basic auth style:
Base64(client_id + “:” + client_secret)
use urlformencode for client id and secret, then base64 the whole thing.
If the token request works ok, what will I receive?
a token response json with the access token, the type and the expiration (in seconds). Optionally the scopes
What is the Implicit Grant Type?
Is the workflow that SPA needs to follow (since they do not have a backend to relly on). Considered less secure.
What differs from implicit grant type and the authorization workflow?
The token is directly asked (we need to pass most of the data in the request, such as client Id and redirect_uri
Why redirect URI is important to be as less dynamic as possible (meaning to avoid wildcards)?
because this is the main defense (the redirect_uri needs to match in the server.
What is the URL fragment (#)?
Is a protected place where the access_token is placed… seems to be a protected type of query string.
Cite 2 concerns of using the implicit grant workflow
access token is exposed to resource owner, js libs that the site is using can access this token too (not other websites), no validation of the token (someone might inject a diff one).
What is a better option for the implicit flow?
CORS + PKCE
What is the client credentials flow? How many times the credentials are sent?
there’s no user involved.. only machines. sent once…