bluesky-social / atproto

Social networking technology created by Bluesky
Other
6.17k stars 432 forks source link

OAuth: Add authorization scopes & remove OpenID compatibility #2734

Closed matthieusieben closed 1 month ago

matthieusieben commented 1 month ago

This PR adds support for scopes during the authorization flow. Three scopes are introduced

This change also removes the compatibility with OpenID.

The reason is that although the implementation was technically OpenID compatible, ATProto identifiers are distributed identifiers. When a client relies on OpenID to authenticate users, it will use the auth provider (issuer) in combination with the identifier to uniquely identify the user. Since ATProto identifiers are meant to be able to move from one provider to the other, OpenID compatibility could break authentication after a user was migrated to a different provider. Future authentication attempts would be considered as distinct identities from the one previsouly used by the client.

The way OpenID compliant clients would adapt to this particularity would typically be to remove the issuer + identifier combination and use the identifier alone. While this is indeed the right way to handle ATProto identifiers, it requires more work to avoid impersonation. In particular, when obtaining a user identifier, the client must verify that the issuer of the identity token is indeed the server responsible for that user. This mechanism being not enforced by the OpenID standard, OpenID compatibility could lead to security issues. For this reason, we decided to remove OpenID compatibility from the OAuth provider.

Note that a trusted central authority could still offer OpenID compatibility by relying on ATProto's regular OAuth flow under the hood. This capability is out of the scope of this library.

itaru2622 commented 1 month ago

@matthieusieben @devinivy please change the title of this PR, for easy tracking the lost of openID compatibility.

I understand that this scoping feature needs to break openID compatibility through discussions, but current title is hard to track when openID compatibility is lost, even the lost is big issue.