Skip to content

Commit

Permalink
remove enterprise license requirements from RAC
Browse files Browse the repository at this point in the history
  • Loading branch information
gergosimonyi committed Feb 14, 2025
1 parent 1496f59 commit 4cf69b6
Show file tree
Hide file tree
Showing 8 changed files with 9 additions and 76 deletions.
3 changes: 1 addition & 2 deletions authentik/providers/rac/api/connection_tokens.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,13 +6,12 @@
from authentik.core.api.groups import GroupMemberSerializer
from authentik.core.api.used_by import UsedByMixin
from authentik.core.api.utils import ModelSerializer
from authentik.enterprise.api import EnterpriseRequiredMixin
from authentik.providers.rac.api.endpoints import EndpointSerializer
from authentik.providers.rac.api.providers import RACProviderSerializer
from authentik.providers.rac.models import ConnectionToken


class ConnectionTokenSerializer(EnterpriseRequiredMixin, ModelSerializer):
class ConnectionTokenSerializer(ModelSerializer):
"""ConnectionToken Serializer"""

provider_obj = RACProviderSerializer(source="provider", read_only=True)
Expand Down
3 changes: 1 addition & 2 deletions authentik/providers/rac/api/endpoints.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@
from authentik.core.api.used_by import UsedByMixin
from authentik.core.api.utils import ModelSerializer
from authentik.core.models import Provider
from authentik.enterprise.api import EnterpriseRequiredMixin
from authentik.policies.engine import PolicyEngine
from authentik.providers.rac.api.providers import RACProviderSerializer
from authentik.providers.rac.models import Endpoint
Expand All @@ -28,7 +27,7 @@ def user_endpoint_cache_key(user_pk: str) -> str:
return f"goauthentik.io/providers/rac/endpoint_access/{user_pk}"


class EndpointSerializer(EnterpriseRequiredMixin, ModelSerializer):
class EndpointSerializer(ModelSerializer):
"""Endpoint Serializer"""

provider_obj = RACProviderSerializer(source="provider", read_only=True)
Expand Down
3 changes: 1 addition & 2 deletions authentik/providers/rac/api/providers.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,10 @@

from authentik.core.api.providers import ProviderSerializer
from authentik.core.api.used_by import UsedByMixin
from authentik.enterprise.api import EnterpriseRequiredMixin
from authentik.providers.rac.models import RACProvider


class RACProviderSerializer(EnterpriseRequiredMixin, ProviderSerializer):
class RACProviderSerializer(ProviderSerializer):
"""RACProvider Serializer"""

outpost_set = ListField(child=CharField(), read_only=True, source="outpost_set.all")
Expand Down
2 changes: 1 addition & 1 deletion authentik/providers/rac/apps.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@


class AuthentikProviderRAC(AppConfig):
"""authentik enterprise rac app config"""
"""authentik rac app config"""

name = "authentik.providers.rac"
label = "authentik_providers_rac"
Expand Down
6 changes: 3 additions & 3 deletions authentik/providers/rac/consumer_client.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,14 +15,14 @@
# to authentik for a specific connection
# The `RACClientConsumer` consumer adds itself to this group on connection,
# and removes itself once it has been assigned a specific outpost channel
RAC_CLIENT_GROUP = "group_enterprise_rac_client"
RAC_CLIENT_GROUP = "group_rac_client"
# A group for all connections in a given authentik session ID
# A disconnect message is sent to this group when the session expires/is deleted
RAC_CLIENT_GROUP_SESSION = "group_enterprise_rac_client_%(session)s"
RAC_CLIENT_GROUP_SESSION = "group_rac_client_%(session)s"
# A group for all connections with a specific token, which in almost all cases
# is just one connection, however this is used to disconnect the connection
# when the token is deleted
RAC_CLIENT_GROUP_TOKEN = "group_enterprise_rac_token_%(token)s" # nosec
RAC_CLIENT_GROUP_TOKEN = "group_rac_token_%(token)s" # nosec

# Step 1: Client connects to this websocket endpoint
# Step 2: We prepare all the connection args for Guac
Expand Down
19 changes: 0 additions & 19 deletions authentik/providers/rac/tests/test_api.py
Original file line number Diff line number Diff line change
@@ -1,16 +1,10 @@
"""Test RAC Provider"""

from datetime import timedelta
from time import mktime
from unittest.mock import MagicMock, patch

from django.urls import reverse
from django.utils.timezone import now
from rest_framework.test import APITestCase

from authentik.core.tests.utils import create_test_admin_user, create_test_flow
from authentik.enterprise.license import LicenseKey
from authentik.enterprise.models import License
from authentik.lib.generators import generate_id


Expand All @@ -20,21 +14,8 @@ class TestAPI(APITestCase):
def setUp(self) -> None:
self.user = create_test_admin_user()

@patch(
"authentik.enterprise.license.LicenseKey.validate",
MagicMock(
return_value=LicenseKey(
aud="",
exp=int(mktime((now() + timedelta(days=3000)).timetuple())),
name=generate_id(),
internal_users=100,
external_users=100,
)
),
)
def test_create(self):
"""Test creation of RAC Provider"""
License.objects.create(key=generate_id())
self.client.force_login(self.user)
response = self.client.post(
reverse("authentik_api:racprovider-list"),
Expand Down
45 changes: 0 additions & 45 deletions authentik/providers/rac/tests/test_views.py
Original file line number Diff line number Diff line change
@@ -1,18 +1,12 @@
"""RAC Views tests"""

from datetime import timedelta
from json import loads
from time import mktime
from unittest.mock import MagicMock, patch

from django.urls import reverse
from django.utils.timezone import now
from rest_framework.test import APITestCase

from authentik.core.models import Application
from authentik.core.tests.utils import create_test_admin_user, create_test_flow
from authentik.enterprise.license import LicenseKey
from authentik.enterprise.models import License
from authentik.lib.generators import generate_id
from authentik.policies.denied import AccessDeniedResponse
from authentik.policies.dummy.models import DummyPolicy
Expand All @@ -39,21 +33,8 @@ def setUp(self):
provider=self.provider,
)

@patch(
"authentik.enterprise.license.LicenseKey.validate",
MagicMock(
return_value=LicenseKey(
aud="",
exp=int(mktime((now() + timedelta(days=3000)).timetuple())),
name=generate_id(),
internal_users=100,
external_users=100,
)
),
)
def test_no_policy(self):
"""Test request"""
License.objects.create(key=generate_id())
self.client.force_login(self.user)
response = self.client.get(
reverse(
Expand All @@ -70,26 +51,13 @@ def test_no_policy(self):
final_response = self.client.get(next_url)
self.assertEqual(final_response.status_code, 200)

@patch(
"authentik.enterprise.license.LicenseKey.validate",
MagicMock(
return_value=LicenseKey(
aud="",
exp=int(mktime((now() + timedelta(days=3000)).timetuple())),
name=generate_id(),
internal_users=100,
external_users=100,
)
),
)
def test_app_deny(self):
"""Test request (deny on app level)"""
PolicyBinding.objects.create(
target=self.app,
policy=DummyPolicy.objects.create(name="deny", result=False, wait_min=1, wait_max=2),
order=0,
)
License.objects.create(key=generate_id())
self.client.force_login(self.user)
response = self.client.get(
reverse(
Expand All @@ -99,26 +67,13 @@ def test_app_deny(self):
)
self.assertIsInstance(response, AccessDeniedResponse)

@patch(
"authentik.enterprise.license.LicenseKey.validate",
MagicMock(
return_value=LicenseKey(
aud="",
exp=int(mktime((now() + timedelta(days=3000)).timetuple())),
name=generate_id(),
internal_users=100,
external_users=100,
)
),
)
def test_endpoint_deny(self):
"""Test request (deny on endpoint level)"""
PolicyBinding.objects.create(
target=self.endpoint,
policy=DummyPolicy.objects.create(name="deny", result=False, wait_min=1, wait_max=2),
order=0,
)
License.objects.create(key=generate_id())
self.client.force_login(self.user)
response = self.client.get(
reverse(
Expand Down
4 changes: 2 additions & 2 deletions authentik/providers/rac/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@

from authentik.core.models import Application, AuthenticatedSession
from authentik.core.views.interface import InterfaceView
from authentik.enterprise.policy import EnterprisePolicyAccessView
from authentik.events.models import Event, EventAction
from authentik.flows.challenge import RedirectChallenge
from authentik.flows.exceptions import FlowNonApplicableException
Expand All @@ -19,10 +18,11 @@
from authentik.flows.stage import RedirectStage
from authentik.lib.utils.time import timedelta_from_string
from authentik.policies.engine import PolicyEngine
from authentik.policies.views import PolicyAccessView
from authentik.providers.rac.models import ConnectionToken, Endpoint, RACProvider


class RACStartView(EnterprisePolicyAccessView):
class RACStartView(PolicyAccessView):
"""Start a RAC connection by checking access and creating a connection token"""

endpoint: Endpoint
Expand Down

0 comments on commit 4cf69b6

Please sign in to comment.