trustgraph/trustgraph-flow/trustgraph/gateway/auth.py
cybermaggedon 67d69b5285
Fixed a problem with the packages, api/__init__.py appeared in both (#196)
trustgraph-flow and trustgraph-base, moved the gateway stuff into a
different directory.
2024-12-06 13:05:56 +00:00

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