Beispiel #1
0
 def pre(self):
     MinimalController.pre(self)
     # override user loggedin behavior to ensure this page always
     # uses the page cache
     (user, maybe_admin) = \
         valid_cookie(c.cookies[g.login_cookie].value
                      if g.login_cookie in c.cookies
                      else '')
     if user:
         self.user_is_loggedin = True
Beispiel #2
0
    def pre(self):
        set_extension(request.environ, "json")
        MinimalController.pre(self)
        require_https()

        try:
            access_token = self._get_bearer_token()
            require(access_token)
            c.oauth2_access_token = access_token
            account = Account._byID(access_token.user_id, data=True)
            require(account)
            require(not account._deleted)
            c.oauth_user = account
        except RequirementException:
            self._auth_error(401, "invalid_token")

        handler = self._get_action_handler()
        if handler:
            oauth2_perms = getattr(handler, "oauth2_perms", None)
            if oauth2_perms:
                if access_token.scope not in oauth2_perms["allowed_scopes"]:
                    self._auth_error(403, "insufficient_scope")
            else:
                self._auth_error(400, "invalid_request")
Beispiel #3
0
 def pre(self):
     set_extension(request.environ, "json")
     MinimalController.pre(self)
     require_https()
     c.oauth2_client = self._get_client_auth()