lepture / authlib

The ultimate Python library in building OAuth, OpenID Connect clients and servers. JWS,JWE,JWK,JWA,JWT included.
https://authlib.org/
BSD 3-Clause "New" or "Revised" License
4.45k stars 445 forks source link

register several endpoints of a kind #576

Closed azmeuk closed 11 months ago

azmeuk commented 11 months ago

I am currently tackling #427 and I realize it would be easier for me if one could register several endpoints of a kind. For instance one JWTAccessTokenIntrospectionEndpoint that would read the introspection data from the JWT access token, and a regular IntrospectionEndpoint for the other kind of tokens.

With this patch, if JWTAccessTokenIntrospectionEndpoint would meet a plain-text access token, it would raise a ContinueIteration exception and pass to the IntrospectionEndpoint. Same if the token_hint is a refresh token for instance (RFC9068 is only about access tokens).

This would also help for the revokation endpoint.

What do you think?

azmeuk commented 11 months ago

An alternative to this would be to implement register_introspection_endpoint and register_revokation_endpoint with an optional token_type parameter, in the fashion of register_token_generator. However that would be a breaking change. What do you think @lepture?

lepture commented 11 months ago

@azmeuk I think your implementation looks good. Would you like to add endpoints in this branch, or let me merge it at first?

azmeuk commented 11 months ago

We can merge this now so the branch diff will be easier to read.

lepture commented 11 months ago

Merged.