indieweb / indieauth

IndieAuth.net website code and IndieAuth Specification
52 stars 7 forks source link

Allow clients to always exchange authorization codes at the token endpoint #58

Closed aaronpk closed 2 years ago

aaronpk commented 3 years ago

One of the last deviations from OAuth 2.0 is that currently the spec requires clients to send the authorization code back to the authorization endpoint for the "login" flow when the client doesn't expect an access token back. In OAuth 2.0, the authorization code is always exchanged at the token endpoint.

The reason for this behavior in IndieAuth was prior to the changes in #42 and #44, this allowed the authorization endpoint to be the only one that needed to be aware of user's URLs, and token endpoints could be standalone. The token endpoint could turn around and go verify the authorization code at the authorization endpoint.

I would like to suggest that the spec allows clients to be more like standard OAuth clients where they can always exchange the authorization code at the token endpoint, whether or not they expect an access token in the response or just the user's profile URL.

This wouldn't actually be a major change for current IndieAuth servers, since it's very likely that some of them already support this behavior at the token endpoint. It just means that the token endpoint would not throw an error if the authorization code had no scopes granted.

The proposed change would mean:

manton commented 3 years ago

Sounds good to me.

martymcguire commented 3 years ago

Seems reasonable!

Zegnat commented 3 years ago

Sounds fine to me.

What would this mean for the spec? If the token endpoint can now handle all types of code exchanges, would this shorten 5.3? I am always for a shorter specification as it makes it less likely things are forgotten or left unimplemented.

If the exchange with the authorization endpoint is kept for backwards compatibility reasons, should we discourage new clients of making that request at all? Possibly gearing up to deprecating that request entirely for a future IndieAuth update?

Zegnat commented 3 years ago

Token endpoints need to be aware that they should not issue an access token if no scope or only profile scopes are issued [...]

Emphasis by me. When I was writing up #62 and rereading this issue, I realised that this does not seem to be in the current spec. Per the code exchange step in 5.3.3. a token endpoint should not return a token only if no scopes were granted. profile is still a valid scope value.

We should clarify how access tokens and the different profile scopes are related. More thoughts in #62.

aaronpk commented 2 years ago
dshanske commented 2 years ago

I believe this is addressed with the latest refresh. We can reopen if not.