示例#1
0
    def auth(self, app):
        app.config.update({
            'RESTY_JWT_DECODE_KEY': 'secret',
            'RESTY_JWT_DECODE_ALGORITHMS': ['HS256'],
        })
        authentication = JwtAuthentication(issuer='resty')

        class UserAuthorization(HasAnyCredentialsAuthorization):
            def filter_query(self, query, view):
                return query.filter_by(
                    owner_id=self.get_request_credentials()['sub'], )

        return {
            'authentication': authentication,
            'authorization': UserAuthorization(),
        }
示例#2
0
    def auth(self, app):
        app.config.update({
            "RESTY_JWT_DECODE_KEY": "secret",
            "RESTY_JWT_DECODE_ALGORITHMS": ["HS256"],
        })
        authentication = JwtAuthentication(issuer="resty")

        class UserAuthorization(HasAnyCredentialsAuthorization):
            def filter_query(self, query, view):
                return query.filter_by(
                    owner_id=self.get_request_credentials()["sub"])

        return {
            "authentication": authentication,
            "authorization": UserAuthorization(),
        }