This repository has been archived on 2024-05-31. You can view files and clone it, but cannot push or open issues or pull requests.
authentik/passbook/policies/struct.py

39 lines
819 B
Python
Raw Normal View History

"""policy structures"""
2019-10-07 14:33:48 +00:00
from __future__ import annotations
2019-10-07 14:50:13 +00:00
from typing import TYPE_CHECKING, Tuple
2019-10-28 16:40:57 +00:00
from django.db.models import Model
from django.http import HttpRequest
if TYPE_CHECKING:
from passbook.core.models import User
2019-12-31 11:51:16 +00:00
class PolicyRequest:
"""Data-class to hold policy request data"""
2019-10-07 14:33:48 +00:00
user: User
http_request: HttpRequest
2019-10-28 16:40:57 +00:00
obj: Model
2019-10-07 14:33:48 +00:00
def __init__(self, user: User):
self.user = user
def __str__(self):
return f"<PolicyRequest user={self.user}>"
class PolicyResult:
"""Small data-class to hold policy results"""
passing: bool
messages: Tuple[str]
def __init__(self, passing: bool, *messages: str):
self.passing = passing
self.messages = messages
def __str__(self):
return f"<PolicyResult passing={self.passing}>"