Esempio n. 1
0
    def has_permission(self, auth: Auth, router: Router, path: http.Path,
                       method: http.Method):
        if not auth.is_authenticated():
            return False

        _, kwargs = router.lookup(path, method)
        scopes_required = {
            scope.format(**kwargs)
            for scope in self.scopes_required
        }
        scopes_given = set(auth.token['scope'].split())
        return scopes_required <= scopes_given
 def has_permission(self, auth: Auth):
     return auth.is_authenticated() and auth.token is None
 def has_permission(self, auth: Auth):
     return auth.is_authenticated()
Esempio n. 4
0
def me(auth: Auth):
    return {
        "is_authenticated": auth.is_authenticated(),
        "username": auth.get_display_name(),
    }
Esempio n. 5
0
def get_auth(auth: Auth):
    return {
        'user_id': auth.get_user_id(),
        'display_name': auth.get_display_name(),
        'is_authenticated': auth.is_authenticated()
    }
Esempio n. 6
0
 def has_permission(self, auth: Auth):
     if not auth.is_authenticated():
         return False
     return bool(auth.user.is_guest)
Esempio n. 7
0
def display_user(auth: Auth):
    return {
        'is_authenticated': auth.is_authenticated(),
        'user': auth.get_display_name(),
    }