Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: Allow disable IAM registration #7910

Open
wants to merge 2 commits into
base: develop
Choose a base branch
from
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
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
### Added

- Allow disabling user registration via Django settings from an environment variable.
(<https://github.com/cvat-ai/cvat/pull/7910>)
5 changes: 4 additions & 1 deletion cvat/apps/iam/urls.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,6 @@

if settings.IAM_TYPE == 'BASIC':
urlpatterns += [
path('register', RegisterViewEx.as_view(), name=BASIC_REGISTER_PATH_NAME),
# password
path('password/reset', PasswordResetView.as_view(),
name='rest_password_reset'),
Expand All @@ -37,6 +36,10 @@
path('password/change', PasswordChangeView.as_view(),
name='rest_password_change'),
]
if settings.IAM_REGISTRATION_ENABLED:
urlpatterns.append(
path('register', RegisterViewEx.as_view(), name=BASIC_REGISTER_PATH_NAME)
)
if allauth_settings.EMAIL_VERIFICATION != \
allauth_settings.EmailVerificationMethod.NONE:
# emails
Expand Down
5 changes: 5 additions & 0 deletions cvat/settings/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -234,6 +234,11 @@ def generate_secret_key():
IAM_ADMIN_ROLE = 'admin'
# Index in the list below corresponds to the priority (0 has highest priority)
IAM_ROLES = [IAM_ADMIN_ROLE, 'business', 'user', 'worker']

IAM_REGISTRATION_ENABLED = to_bool(os.getenv('IAM_REGISTRATION_ENABLED', 'true'))
if IAM_REGISTRATION_ENABLED:
INSTALLED_APPS.append('dj_rest_auth.registration')

IAM_OPA_HOST = 'http://opa:8181'
IAM_OPA_DATA_URL = f'{IAM_OPA_HOST}/v1/data'
LOGIN_URL = 'rest_login'
Expand Down
1 change: 1 addition & 0 deletions docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -88,6 +88,7 @@ services:
CVAT_ANALYTICS: 1
CVAT_BASE_URL:
ONE_RUNNING_JOB_IN_QUEUE_PER_USER:
IAM_REGISTRATION_ENABLED: 'true'
command: init run server
labels:
- traefik.enable=true
Expand Down
2 changes: 2 additions & 0 deletions helm-chart/templates/cvat_backend/server/deployment.yml
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,8 @@ spec:
env:
- name: ALLOWED_HOSTS
value: {{ $localValues.envs.ALLOWED_HOSTS | squote}}
- name: IAM_REGISTRATION_ENABLED
value: {{ $localValues.envs.IAM_REGISTRATION_ENABLED | squote}}
{{ include "cvat.sharedBackendEnv" . | indent 10 }}
{{- with concat .Values.cvat.backend.additionalEnv $localValues.additionalEnv }}
{{- toYaml . | nindent 10 }}
Expand Down
3 changes: 3 additions & 0 deletions helm-chart/values.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,9 @@ cvat:
tolerations: []
envs:
ALLOWED_HOSTS: "*"
# Disable the frontend elements by disabling the following key and rebuilding
# ui/reducers/server-api-reducer/defaultState.configuration.isRegistrationEnabled
IAM_REGISTRATION_ENABLED: "true"
additionalEnv: []
additionalVolumes: []
additionalVolumeMounts: []
Expand Down
Loading