zhukov
04/28/2022, 8:17 AMNeedle
04/28/2022, 8:17 AM/title
command!
We have solved your problem?
Click the button below to archive it.zhukov
04/28/2022, 8:18 AMVidski
04/28/2022, 8:35 AMzhukov
04/28/2022, 8:35 AMzhukov
04/28/2022, 8:36 AMVidski
04/28/2022, 8:36 AMpython
import jwt
from falcon import HTTPUnauthorized
class JwtChecker:
def __init__(self, secret='', algorithm='', exempt_routes=None,
exempt_methods=None, issuer=None, audience=None, leeway=0):
self.secret = secret
self.algorithm = algorithm
self.exempt_routes = exempt_routes or []
self.exempt_methods = exempt_methods or []
self.issuer = issuer
self.audience = audience
self.leeway = leeway
algorithms = [
'HS256', 'HS384', 'HS512',
'ES256', 'ES384', 'ES512',
'RS256', 'RS384', 'RS512',
'PS256', 'PS384', 'PS512'
]
if self.algorithm not in algorithms:
raise RuntimeError('Unsupported algorithm')
async def process_resource(self, req, resp, resource, params):
if req.path in self.exempt_routes or req.method in self.exempt_methods:
return
token = req.headers.get('authorization', '').partition('Bearer ')[2]
try:
claims = jwt.decode(token,
key=self.secret,
algorithms=self.algorithm,
issuer=self.issuer,
audience=self.audience,
leeway=self.leeway)
# print(claims['sub'])
except jwt.InvalidTokenError as err:
raise HTTPUnauthorized()
Vidski
04/28/2022, 8:37 AMVidski
04/28/2022, 8:38 AMpython
JwtChecker(
secret='your-super-secret-jwt-token-with-at-least-32-characters-long', # May be a public key
algorithm='HS256',
audience='authenticated',
)
Vidski
04/28/2022, 8:42 AMVidski
04/28/2022, 8:43 AMzhukov
04/28/2022, 8:51 AMzhukov
04/28/2022, 8:51 AMVidski
04/28/2022, 8:54 AMzhukov
04/28/2022, 8:55 AMzhukov
04/28/2022, 8:55 AMVidski
04/28/2022, 8:57 AMzhukov
04/28/2022, 8:57 AMVidski
04/28/2022, 8:57 AMVidski
04/28/2022, 8:58 AMMihai Andrei
04/28/2022, 6:43 PMVidski
04/28/2022, 7:13 PMVidski
04/28/2022, 7:19 PMVidski
04/28/2022, 7:20 PMMihai Andrei
04/28/2022, 7:22 PMVidski
04/28/2022, 7:26 PMMihai Andrei
04/28/2022, 7:31 PMVidski
04/29/2022, 6:03 AMVidski
04/29/2022, 6:05 AMMihai Andrei
04/29/2022, 6:55 AMMihai Andrei
04/29/2022, 6:56 AMconst { user, error } = await this.$supabase.auth.update({
data: { role: 'superadmin' }
})
Mihai Andrei
04/29/2022, 6:56 AMMihai Andrei
04/29/2022, 6:57 AMVidski
04/29/2022, 7:03 AMVidski
04/29/2022, 7:07 AMVidski
04/29/2022, 7:08 AMMihai Andrei
04/29/2022, 7:12 AMVidski
04/29/2022, 7:12 AMVidski
04/29/2022, 7:13 AMMihai Andrei
04/29/2022, 7:14 AMupdate auth.users set raw_app_meta_data = '{"role": "admin"}' where id='11538f33-7f11-4c5a-b9a4-1ec009085d42';
Vidski
04/29/2022, 7:14 AMMihai Andrei
04/29/2022, 7:14 AMMihai Andrei
04/29/2022, 7:15 AMMihai Andrei
04/29/2022, 7:15 AMVidski
04/29/2022, 7:16 AMMihai Andrei
04/29/2022, 7:19 AMVidski
04/29/2022, 7:19 AMVidski
04/29/2022, 7:19 AMMihai Andrei
04/29/2022, 7:20 AMMihai Andrei
04/29/2022, 7:20 AMVidski
04/29/2022, 7:20 AMMihai Andrei
04/29/2022, 8:18 AMsql
UPDATE auth.users
SET raw_app_meta_data = jsonb_set(raw_app_meta_data, '{role}', to_json('USER'::text)::jsonb) where id='f2bf56a2-0398-4891-b860-a7bc757ac656';