File: models.py

package info (click to toggle)
python-authlib 1.6.1-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 3,016 kB
  • sloc: python: 26,998; makefile: 53; sh: 14
file content (40 lines) | stat: -rw-r--r-- 989 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
from ..rfc6749 import TokenMixin


class IntrospectionToken(dict, TokenMixin):
    def get_client_id(self):
        return self.get("client_id")

    def get_scope(self):
        return self.get("scope")

    def get_expires_in(self):
        # this method is only used in refresh token,
        # no need to implement it
        return 0

    def get_expires_at(self):
        return self.get("exp", 0)

    def __getattr__(self, key):
        # https://tools.ietf.org/html/rfc7662#section-2.2
        available_keys = {
            "active",
            "scope",
            "client_id",
            "username",
            "token_type",
            "exp",
            "iat",
            "nbf",
            "sub",
            "aud",
            "iss",
            "jti",
        }
        try:
            return object.__getattribute__(self, key)
        except AttributeError as error:
            if key in available_keys:
                return self.get(key)
            raise error