Create an ``query_token`` function for revocation, introspection token endpoints. :param session: SQLAlchemy session :param token_model: Token model class
(session, token_model)
| 38 | |
| 39 | |
| 40 | def create_query_token_func(session, token_model): |
| 41 | """Create an ``query_token`` function for revocation, introspection |
| 42 | token endpoints. |
| 43 | |
| 44 | :param session: SQLAlchemy session |
| 45 | :param token_model: Token model class |
| 46 | """ |
| 47 | |
| 48 | def query_token(token, token_type_hint): |
| 49 | q = session.query(token_model) |
| 50 | if token_type_hint == "access_token": |
| 51 | return q.filter_by(access_token=token).first() |
| 52 | elif token_type_hint == "refresh_token": |
| 53 | return q.filter_by(refresh_token=token).first() |
| 54 | # without token_type_hint |
| 55 | item = q.filter_by(access_token=token).first() |
| 56 | if item: |
| 57 | return item |
| 58 | return q.filter_by(refresh_token=token).first() |
| 59 | |
| 60 | return query_token |
| 61 | |
| 62 | |
| 63 | def create_revocation_endpoint(session, token_model): |
no outgoing calls
no test coverage detected