Add a new "Forbidden" FxA error.#7320
Conversation
da266a4 to
c5e4699
Compare
bendk
left a comment
There was a problem hiding this comment.
This change looks good to me. My only suggestion is maybe we could get rid of NoCachedToken entirely and replace it with more specific errors. Looking through the code I see 2 remaining uses:
- We don't have a refresh token immediately after exchanging it and setting a new one. This doesn't seem possible to me. Maybe that branch should just be
unreachable!()or the code could be refactored so it's not needed. - We've exchanged the refresh token after asking for a new scope, but the new token doesn't have the scope either. I think this is possible, but it represents a server error. Maybe we could replace that with a
ScopedKeyMissingInServerResponseerror which generalizes the currentSyncScopedKeyMissingInServerResponseerror.
If it's easy and makes sense to you, then I'm for adding those changes to this PR. Otherwise, we can land it as-is and keep iterating.
Yeah, good idea. I agree the first one is literally impossible, so I made that (A problem with |
|
( |
c5e4699 to
239166f
Compare
This is distinct from Authentication in that there's no implication the account state isn't good, it's just that you aren't allowed to do what you tried. An example of this is asking for an access token you don't have the scopes for. This has the side effect of fixing a bug in `get_access_token()` - when that code calls `exchange_token_for_scope()`, the server responds with a http 403 response - which ends up getting re-thrown as "other error". It arranges for `NoCachedToken` errors to turn into this (that was previously `Authentication`) and for `NoSessionToken` to be `Authentication`. It also tweaks `get_access_token()` to explicitly throw `NoSessionToken` when there's no session token. That way `get_access_token()` continues to return `Authentication` when not logged in, but otherwise will generally return `Forbidden`. Technically a breaking change, but both Android and iOS seem fine with new variants here.
239166f to
780150a
Compare
This is distinct from Authentication in that there's no implication the account state isn't good, it's just that you aren't allowed to do what you tried. An example of this is asking for an access token you don't have the scopes for.
This has the side effect of fixing a bug in
get_access_token()- when that code callsexchange_token_for_scope(), the server responds with a http 403 response - which ends up getting re-thrown as "other error".It arranges for
NoCachedTokenerrors to turn into this (that was previouslyAuthentication) and forNoSessionTokento beAuthentication. It also tweaksget_access_token()to explicitly throwNoSessionTokenwhen there's no session token. That wayget_access_token()continues to returnAuthenticationwhen not logged in, but otherwise will generally returnForbidden.Technically a breaking change, but both Android and iOS seem fine with new variants here.
Pull Request checklist
[ci full]to the PR title.