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

Allow disabling of local admin login #1498

Merged
merged 6 commits into from
Mar 11, 2025
Merged
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
2 changes: 1 addition & 1 deletion app/signals/apps/signals/tests/test_span_creation.py
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ def setUp(self):

def test_span_creation(self):
"""
Test if the app succesfully creates spans by creating a
Test if the app successfully creates spans by creating a
custom trace and performing a query inside it.
"""

Expand Down
5 changes: 4 additions & 1 deletion app/signals/settings.py
Original file line number Diff line number Diff line change
Expand Up @@ -173,9 +173,12 @@ def is_super_user(user) -> bool:

AUTHENTICATION_BACKENDS: list[str] = [
'signals.admin.oidc.backends.AuthenticationBackend',
'django.contrib.auth.backends.ModelBackend',
]

ADMIN_ENABLE_LOCAL_LOGIN: bool = os.getenv('ADMIN_ENABLE_LOCAL_LOGIN', False) in TRUE_VALUES
if ADMIN_ENABLE_LOCAL_LOGIN:
AUTHENTICATION_BACKENDS.append("django.contrib.auth.backends.ModelBackend")

LOGIN_REDIRECT_URL: str = '/signals/admin/'
LOGIN_REDIRECT_URL_FAILURE: str = '/signals/oidc/login_failure/'
LOGOUT_REDIRECT_URL: str = '/signals/admin/'
Expand Down
10 changes: 6 additions & 4 deletions app/signals/templates/admin/login.html
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,7 @@
</p>
{% endif %}

{% if ADMIN_ENABLE_LOCAL_LOGIN %}
<form action="{{ app_path }}" method="post" id="login-form">{% csrf_token %}
<div class="form-row">
{{ form.username.errors }}
Expand All @@ -66,16 +67,17 @@
{{ form.password.label_tag }} {{ form.password }}
<input type="hidden" name="next" value="{{ next }}">
</div>
<div class="submit-row">
<label>&nbsp;</label><input type="submit" value="{% trans 'Log in' %}">
</div>
</form>
{% endif %}
{% url 'admin_password_reset' as password_reset_url %}
{% if password_reset_url %}
<div class="password-reset-link">
<a href="{{ password_reset_url }}">{% trans 'Forgotten your password or username?' %}</a>
</div>
{% endif %}
<div class="submit-row">
<label>&nbsp;</label><input type="submit" value="{% trans 'Log in' %}">
</div>
</form>

{% if OIDC_RP_CLIENT_ID %}
<div class="sso">
Expand Down
1 change: 1 addition & 0 deletions docker-compose/environments/.api
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ OIDC_OP_USER_ENDPOINT=http://keycloak:8002/realms/signals/protocol/openid-connec
OIDC_OP_JWKS_ENDPOINT=http://keycloak:8002/realms/signals/protocol/openid-connect/certs
OIDC_OP_ISSUER=http://localhost:8002/realms/signals
OIDC_VERIFY_AUDIENCE=False
OIDC_USE_NONCE=False
SILK_ENABLED=False
SILK_PROFILING_ENABLED=False
SILK_AUTHENTICATION_ENABLED=False
Expand Down
1 change: 1 addition & 0 deletions docker-compose/environments/.test
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ OIDC_OP_AUTHORIZATION_ENDPOINT=http://127.0.0.1:5556/auth
OIDC_OP_TOKEN_ENDPOINT=http://dex:5556/token
OIDC_OP_USER_ENDPOINT=http://dex:5556/userinfo
OIDC_OP_JWKS_ENDPOINT=http://dex:5556/keys
ADMIN_ENABLE_LOCAL_LOGIN=True
SILK_ENABLED=False
SILK_PROFILING_ENABLED=False
SILK_AUTHENTICATION_ENABLED=False
Expand Down
Loading