Files
Robbe Sneyders cbeac6f2c1 Update security docs (#1764)
Contributes to #1531
2023-10-31 20:08:04 +01:00

30 lines
571 B
Python
Executable File

"""
Basic example of a resource server
"""
from pathlib import Path
import connexion
# our hardcoded mock "Bearer" access tokens
TOKENS = {"123": "jdoe", "456": "rms"}
def get_secret(user) -> str:
return f"You are: {user}"
def token_info(token) -> dict:
sub = TOKENS.get(token)
if not sub:
return None
return {"sub": sub, "scope": ["uid"]}
app = connexion.FlaskApp(__name__, specification_dir="spec")
app.add_api("openapi.yaml")
app.add_api("swagger.yaml")
if __name__ == "__main__":
app.run(f"{Path(__file__).stem}:app", port=8080)