mirror of
https://github.com/trustgraph-ai/trustgraph.git
synced 2026-07-26 05:31:01 +02:00
22 lines
469 B
Python
22 lines
469 B
Python
|
|
class Authenticator:
|
|
|
|
def __init__(self, token=None, allow_all=False):
|
|
|
|
if not allow_all and token is None:
|
|
raise RuntimeError("Need a token")
|
|
|
|
if not allow_all and token == "":
|
|
raise RuntimeError("Need a token")
|
|
|
|
self.token = token
|
|
self.allow_all = allow_all
|
|
|
|
def permitted(self, token, roles):
|
|
|
|
if self.allow_all: return True
|
|
|
|
if self.token != token: return False
|
|
|
|
return True
|
|
|