Skip to content
Snippets Groups Projects
Commit a03702e1 authored by Nico Vermaas's avatar Nico Vermaas
Browse files

Merge branch 'astronauth' into 'master'

Astronauth integration

See merge request !276
parents 82e922f0 68196aa8
No related branches found
No related tags found
2 merge requests!277pulling change in master into astronauth branch,!276Astronauth integration
Pipeline #43746 passed
...@@ -108,5 +108,8 @@ This is the procedure for that. ...@@ -108,5 +108,8 @@ This is the procedure for that.
(this should say 'No changes detected', but do this step anyway as a check) (this should say 'No changes detected', but do this step anyway as a check)
> docker exec -it atdb-ldv python manage.py migrate --settings atdb.settings.docker_sdc > docker exec -it atdb-ldv python manage.py migrate --settings atdb.settings.docker_sdc
#### Integrating Astronauth
See the integration instructions in the [astronauth repo](https://git.astron.nl/astron-sdc/astronauth)
FROM python:3.6.7-alpine FROM python:3.10-slim
ENV PYTHONUNBUFFERED 1 RUN apt-get update && apt-get install --no-install-recommends -y bash nano mc libmagic1 git
RUN apk update && apk add bash && apk add nano && apk add mc
RUN mkdir /src RUN mkdir /src
WORKDIR /src WORKDIR /src
COPY . /src/ COPY . /src/
# install dependencies RUN pip install --upgrade pip
RUN \ RUN pip install -r requirements/prod.txt
apk add --no-cache python3 postgresql-libs && \
apk add --no-cache --virtual .build-deps gcc python3-dev musl-dev postgresql-dev && \ RUN python manage.py collectstatic --settings=atdb.settings.dev --noinput
pip install -r requirements/prod.txt && \
apk --purge del .build-deps
# run gunicorn # run gunicorn
CMD exec gunicorn atdb.wsgi_docker_sdc:application --bind 0.0.0.0:8000 --workers 4 CMD exec gunicorn atdb.wsgi_docker_sdc:application --bind 0.0.0.0:8000 --workers 4 --timeout 120
...@@ -31,7 +31,16 @@ INSTALLED_APPS = [ ...@@ -31,7 +31,16 @@ INSTALLED_APPS = [
'bootstrap_pagination', 'bootstrap_pagination',
'django_tables2', 'django_tables2',
'bootstrap3', 'bootstrap3',
'fontawesome-free' 'fontawesome-free',
## These are required for ASTRONauth
'django.contrib.sites',
"astronauth", # it is important that astronauth is included before allauth
'allauth',
'allauth.account',
'allauth.socialaccount',
'allauth.socialaccount.providers.keycloak',
] ]
MIDDLEWARE = [ MIDDLEWARE = [
...@@ -202,3 +211,29 @@ AGGREGATES = ['failed','active','total'] ...@@ -202,3 +211,29 @@ AGGREGATES = ['failed','active','total']
QUERY_LIMIT_MULTI_CHANGE = 1000 QUERY_LIMIT_MULTI_CHANGE = 1000
MAX_MONITORING_HISTORY_HOURS = 7 * 24 MAX_MONITORING_HISTORY_HOURS = 7 * 24
SERVICES_LATE_WARNING_SECONDS = 1800 SERVICES_LATE_WARNING_SECONDS = 1800
# astronauth settings
SITE_ID = 1
AUTHENTICATION_BACKENDS = [
# Needed to login by username in Django admin, regardless of `allauth`
"django.contrib.auth.backends.ModelBackend",
# `allauth` specific authentication methods, such as login by e-mail
"allauth.account.auth_backends.AuthenticationBackend",
]
SOCIALACCOUNT_PROVIDERS = {
'keycloak': {
'KEYCLOAK_URL': 'https://sdc-dev.astron.nl/auth', # replace by https://keycloak.astron.nl/auth for production
'KEYCLOAK_REALM': 'SDC', # change this depending on which realm to use
'SCOPE': ['openid', 'profile', 'email']
}
}
try:
LOGIN_REDIRECT_URL = os.environ['LOGIN_REDIRECT_URL']
except:
LOGIN_REDIRECT_URL = 'https://sdc-dev.astron.nl:5554/atdb/'
SESSION_COOKIE_NAME = 'my_service_name_session_id'
CSRF_COOKIE_NAME = 'my_service_csrftoken'
...@@ -13,7 +13,7 @@ DATABASES = { ...@@ -13,7 +13,7 @@ DATABASES = {
'ENGINE': 'django.db.backends.postgresql_psycopg2', 'ENGINE': 'django.db.backends.postgresql_psycopg2',
'USER': 'atdb_admin', 'USER': 'atdb_admin',
'PASSWORD': 'atdb123', 'PASSWORD': 'atdb123',
'NAME': 'atdb_ldv_27jan2023', 'NAME': 'atdb_ldv_astronauth_6feb2023',
'HOST': 'localhost', 'HOST': 'localhost',
'PORT': '5432', 'PORT': '5432',
}, },
...@@ -23,3 +23,14 @@ DATABASES = { ...@@ -23,3 +23,14 @@ DATABASES = {
# https://docs.djangoproject.com/en/1.10/ref/settings/#auth-password-validators # https://docs.djangoproject.com/en/1.10/ref/settings/#auth-password-validators
AUTH_PASSWORD_VALIDATORS = [] AUTH_PASSWORD_VALIDATORS = []
# astronauth settings
SOCIALACCOUNT_PROVIDERS = {
'keycloak': {
'KEYCLOAK_URL': 'https://sdc-dev.astron.nl/auth', # replace by https://keycloak.astron.nl/auth for production
'KEYCLOAK_REALM': 'SDC', # change this depending on which realm to use
'SCOPE': ['openid', 'profile', 'email']
}
}
LOGIN_REDIRECT_URL = "http://localhost:8000/atdb"
...@@ -37,3 +37,4 @@ DATABASES = { ...@@ -37,3 +37,4 @@ DATABASES = {
AUTH_PASSWORD_VALIDATORS = [] AUTH_PASSWORD_VALIDATORS = []
...@@ -6,4 +6,5 @@ urlpatterns = [ ...@@ -6,4 +6,5 @@ urlpatterns = [
path('atdb/', include('taskdatabase.urls')), path('atdb/', include('taskdatabase.urls')),
path('atdb/admin/', admin.site.urls), path('atdb/admin/', admin.site.urls),
path('atdb/api-auth/', include('rest_framework.urls')), path('atdb/api-auth/', include('rest_framework.urls')),
path("atdb/astronauth/", include("astronauth.urls")), # include astronauth
] ]
astronauth==0.3.3
Django==3.1.4 Django==3.1.4
djangorestframework==3.12.2 django-allauth==0.52.0
django-filter==2.3.0 django-bootstrap-pagination==1.7.0
psycopg2-binary==2.9.3 django-bootstrap3==14.2.0
django-cors-headers==3.6.0 django-cors-headers==3.6.0
django-extensions==3.1.0 django-extensions==3.1.0
django-bootstrap-pagination==1.7.0 django-filter==2.3.0
whitenoise==5.0.1
six==1.15.0
django-tables2==2.3.4 django-tables2==2.3.4
django-bootstrap3==14.2.0 djangorestframework==3.12.2
fontawesome-free==5.15.2 fontawesome-free==5.15.2
\ No newline at end of file oauthlib==3.2.2
psycopg2-binary==2.9.3
python3-openid==3.2.0
requests-oauthlib==1.3.1
six==1.15.0
whitenoise==5.0.1
\ No newline at end of file
{% load static %}
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<title>{% block head_title %}{% endblock %} - ASTRONauth</title>
<link rel="stylesheet" type="text/css" href="{% static 'taskdatabase/style.css' %}"/>
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/4.1.3/css/bootstrap.min.css">
<link href='https://fonts.googleapis.com/css?family=Raleway' rel='stylesheet' type='text/css'>
<link rel="stylesheet" href="https://use.fontawesome.com/releases/v5.4.2/css/all.css" integrity="sha384-/rXc/GQVaYpyDdyxK+ecHPVYJSN9bmVFBvjA/9eOB+pb3F2w2N6fc5qB9Ew5yIns" crossorigin="anonymous">
<link rel="stylesheet" href="{% static 'astronauth/css/dias.css' %}">
<link rel="stylesheet" href="{% static 'astronauth/css/custom.css' %}">
</head>
<body>
{% include "astronauth/navbar.html" %}
{% block content %}{% endblock %}
</body>
</html>
{% load static %}
{% load account %}
<nav class="navbar navbar-expand-lg navbar-light bg-light">
<div class="container-fluid">
<ul class="nav navbar-nav">
<!-- Header -->
<li><a class="navbar-brand" href="{% url 'index' %}">
<img src="{% static 'taskdatabase/new_ldv_logo.png' %}" height="30" alt="">
&nbsp;ATDB</a>
</li>
<li><a class="nav-link" href="{% url 'index' %}">Tasks</a></li>
{% comment %}
<li><a class="nav-link" href="{% url 'postprocessing-tasks' %}">PostProcessing</a></li>
{% endcomment %}
{% if user.is_authenticated %}
<li><a class="nav-link" href="{% url 'task-details'%}">Task Details</a></li>
{% endif %}
<li><a class="nav-link" href="{% url 'dashboard' 'active_nores_nofilter' %}">Dashboard</a></li>
<li><a class="nav-link" href="{% url 'query' %}">Filter</a></li>
<li><a class="nav-link" href="{% url 'quality' %}">Quality</a></li>
<li><a class="nav-link" href="{% url 'validation' %}">Validation</a></li>
<li><a class="nav-link" href="{% url 'failures' %}">Failures</a></li>
<li><a class="nav-link" href="{% url 'archived' %}">Archived</a></li>
<li><a class="nav-link" href="{% url 'monitoring' %}">Monitoring</a></li>
<li><a class="nav-link" href="{% url 'diagram' %}">Diagram</a></li>
{% if user.is_superuser %}
<li><a class="nav-link" href="{% url 'config' %}">Configuration</a></li>
<li><a class="nav-link" href="{% url 'admin:index' %}" target="_blank">Admin</a></li>
{% endif %}
</ul>
<ul class="nav navbar-nav">
{% if "/login/" in request.path or "/logout/" in request.path %}
{# don't render antyhing #}
{% elif user.is_authenticated %}
<li class="h-navbar-list__item">
<a class="button button--secondary margin-right" href="{% url 'account_logout' %}">Sign Out {{ user.get_username }}</a>
</li>
{% else %}
<li class="h-navbar-list__item">
<a class="button button--secondary margin-right" href="{% url 'account_login' %}">Sign In</a>
</li>
{% endif %}
</ul>
</div>
</nav>
\ No newline at end of file
...@@ -30,56 +30,10 @@ ...@@ -30,56 +30,10 @@
{% block extra_js %}{% endblock %} {% block extra_js %}{% endblock %}
</head> </head>
<body onload="readFromLocalStorage('search_box')"> <body onload="readFromLocalStorage('search_box')">
<nav class="navbar navbar-expand-lg navbar-light bg-light">
<div class="container-fluid">
<ul class="nav navbar-nav">
<!-- Header -->
<li><a class="navbar-brand" href="{% url 'index' %}">
<img src="{% static 'taskdatabase/new_ldv_logo.png' %}" height="30" alt="">
&nbsp;ATDB</a>
</li>
<li><a class="nav-link" href="{% url 'index' %}">Tasks</a></li>
{% comment %}
<li><a class="nav-link" href="{% url 'postprocessing-tasks' %}">PostProcessing</a></li>
{% endcomment %}
{% if user.is_authenticated %}
<li><a class="nav-link" href="{% url 'task-details'%}">Task Details</a></li>
{% endif %}
<li><a class="nav-link" href="{% url 'dashboard' 'active_nores_nofilter' %}">Dashboard</a></li>
<li><a class="nav-link" href="{% url 'query' %}">Filter</a></li>
<li><a class="nav-link" href="{% url 'quality' %}">Quality</a></li>
<li><a class="nav-link" href="{% url 'validation' %}">Validation</a></li>
<li><a class="nav-link" href="{% url 'failures' %}">Failures</a></li>
<li><a class="nav-link" href="{% url 'archived' %}">Archived</a></li>
<li><a class="nav-link" href="{% url 'monitoring' %}">Monitoring</a></li>
<li><a class="nav-link" href="{% url 'diagram' %}">Diagram</a></li>
{% if user.is_superuser %}
<li><a class="nav-link" href="{% url 'config' %}">Configuration</a></li>
<li><a class="nav-link" href="{% url 'admin:index' %}" target="_blank">Admin</a></li>
{% endif %}
</ul>
{% if user.is_authenticated %}
<a class="nav-link" href="{% url 'logout' %}" target="_blank">Logout {{ user.get_username }}</a>
{% endif %}
{% if not user.is_authenticated %}
<a class="nav-link" href="{% url 'login' %}" target="_blank">Login</a>
{% endif %}
</div>
</nav> {% include "astronauth/navbar.html" %}
{% for message in messages %} {% for message in messages %}
<div class="container-fluid p-0"> <div class="container-fluid p-0">
......
...@@ -34,7 +34,7 @@ ...@@ -34,7 +34,7 @@
{% include 'taskdatabase/pagination.html' %} {% include 'taskdatabase/pagination.html' %}
</div> </div>
</div> </div>
<p class="footer"> Version 6 Februari 2023 <p class="footer"> Version 6 Februari 2023 - 14:00
</div> </div>
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment