Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 8 additions & 0 deletions src/backend/core/external_api/permissions.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@
import logging
from typing import Dict

from django.conf import settings

from rest_framework import exceptions, permissions

from .. import models
Expand Down Expand Up @@ -55,6 +57,12 @@ def has_permission(self, request, view):
if isinstance(token_scopes, str):
token_scopes = token_scopes.split()

if settings.OIDC_RS_SCOPES_PREFIX:
token_scopes = [
scope.replace(f"{settings.OIDC_RS_SCOPES_PREFIX}:", "")
for scope in token_scopes
]

if required_scope not in token_scopes:
raise exceptions.PermissionDenied(
f"Insufficient permissions. Required scope: {required_scope}"
Expand Down
6 changes: 4 additions & 2 deletions src/backend/core/tests/test_external_api_rooms.py
Original file line number Diff line number Diff line change
Expand Up @@ -373,6 +373,7 @@ def test_resource_server_creates_user_on_first_authentication(settings):

settings.OIDC_RS_CLIENT_ID = "some_client_id"
settings.OIDC_RS_CLIENT_SECRET = "some_client_secret"
settings.OIDC_RS_SCOPES_PREFIX = "lasuite_meet"

settings.OIDC_OP_URL = "https://oidc.example.com"
settings.OIDC_VERIFY_SSL = False
Expand All @@ -389,7 +390,7 @@ def test_resource_server_creates_user_on_first_authentication(settings):
"aud": "some_client_id", # settings.OIDC_RS_CLIENT_ID
"sub": "very-specific-sub",
"client_id": "some_service_provider",
"scope": "openid lasuite_meet rooms:list",
"scope": "openid lasuite_meet lasuite_meet:rooms:list",
"active": True,
},
)
Expand Down Expand Up @@ -489,6 +490,7 @@ def test_resource_server_authentication_successful(settings):

settings.OIDC_RS_CLIENT_ID = "some_client_id"
settings.OIDC_RS_CLIENT_SECRET = "some_client_secret"
settings.OIDC_RS_SCOPES_PREFIX = "lasuite_meet"

settings.OIDC_OP_URL = "https://oidc.example.com"
settings.OIDC_VERIFY_SSL = False
Expand All @@ -505,7 +507,7 @@ def test_resource_server_authentication_successful(settings):
"aud": "some_client_id", # settings.OIDC_RS_CLIENT_ID
"sub": "very-specific-sub",
"client_id": "some_service_provider",
"scope": "openid lasuite_meet rooms:list",
"scope": "openid lasuite_meet lasuite_meet:rooms:list",
"active": True,
},
)
Expand Down
3 changes: 3 additions & 0 deletions src/backend/meet/settings.py
Original file line number Diff line number Diff line change
Expand Up @@ -538,6 +538,9 @@ class Base(Configuration):
OIDC_RS_ENCRYPTION_KEY_TYPE = values.Value(
default="RSA", environ_name="OIDC_RS_ENCRYPTION_KEY_TYPE", environ_prefix=None
)
OIDC_RS_SCOPES_PREFIX = values.Value(
default=None, environ_name="OIDC_RS_SCOPES_PREFIX", environ_prefix=None
)

# Video conference configuration
LIVEKIT_CONFIGURATION = {
Expand Down
Loading