
* initial import Signed-off-by: Jens Langhammer <jens@goauthentik.io> * update imports Signed-off-by: Jens Langhammer <jens@goauthentik.io> * remove email and hotp for now Signed-off-by: Jens Langhammer <jens@goauthentik.io> * remove things we don't need and clean up Signed-off-by: Jens Langhammer <jens@goauthentik.io> * initial merge static Signed-off-by: Jens Langhammer <jens@goauthentik.io> * initial merge totp Signed-off-by: Jens Langhammer <jens@goauthentik.io> * more fixes Signed-off-by: Jens Langhammer <jens@goauthentik.io> * fix migrations Signed-off-by: Jens Langhammer <jens@goauthentik.io> * update webui Signed-off-by: Jens Langhammer <jens@goauthentik.io> * add system migration Signed-off-by: Jens Langhammer <jens@goauthentik.io> * more cleanup, add doctests to test_runner Signed-off-by: Jens Langhammer <jens@goauthentik.io> * more cleanup Signed-off-by: Jens Langhammer <jens@goauthentik.io> * fixup more lint Signed-off-by: Jens Langhammer <jens@goauthentik.io> * cleanup last tests Signed-off-by: Jens Langhammer <jens@goauthentik.io> * update docstrings Signed-off-by: Jens Langhammer <jens@goauthentik.io> * fix tests Signed-off-by: Jens Langhammer <jens@goauthentik.io> * implement SerializerModel Signed-off-by: Jens Langhammer <jens@goauthentik.io> * fix web format Signed-off-by: Jens Langhammer <jens@goauthentik.io> --------- Signed-off-by: Jens Langhammer <jens@goauthentik.io>
33 lines
1.1 KiB
Python
33 lines
1.1 KiB
Python
"""Enterprise license policies"""
|
|
from typing import Optional
|
|
|
|
from authentik.core.models import User, UserTypes
|
|
from authentik.enterprise.models import LicenseKey
|
|
from authentik.policies.types import PolicyRequest, PolicyResult
|
|
from authentik.policies.views import PolicyAccessView
|
|
|
|
|
|
class EnterprisePolicyAccessView(PolicyAccessView):
|
|
"""PolicyAccessView which also checks enterprise licensing"""
|
|
|
|
def check_license(self):
|
|
"""Check license"""
|
|
if not LicenseKey.get_total().is_valid():
|
|
return False
|
|
if self.request.user.type != UserTypes.INTERNAL:
|
|
return False
|
|
return True
|
|
|
|
def user_has_access(self, user: Optional[User] = None) -> PolicyResult:
|
|
user = user or self.request.user
|
|
request = PolicyRequest(user)
|
|
request.http_request = self.request
|
|
result = super().user_has_access(user)
|
|
enterprise_result = self.check_license()
|
|
if not enterprise_result:
|
|
return enterprise_result
|
|
return result
|
|
|
|
def resolve_provider_application(self):
|
|
raise NotImplementedError
|