diff --git a/scipost_django/SciPost_v1/settings/base.py b/scipost_django/SciPost_v1/settings/base.py index 9f8c1459ff20f65eb3671f701b823ebd151960ae..95bd8d12afec3a543f7fc7bcea96f807710a7339 100644 --- a/scipost_django/SciPost_v1/settings/base.py +++ b/scipost_django/SciPost_v1/settings/base.py @@ -178,7 +178,8 @@ OAUTH2_PROVIDER = { REST_FRAMEWORK = { "DEFAULT_AUTHENTICATION_CLASSES": [ - "rest_framework.authentication.SessionAuthentication" + "rest_framework.authentication.SessionAuthentication", + "oauth2_provider.contrib.rest_framework.OAuth2Authentication", ], "DEFAULT_PERMISSION_CLASSES": ("rest_framework.permissions.IsAdminUser",), "DEFAULT_FILTER_BACKENDS": [ diff --git a/scipost_django/templates/oauth2_provider/application_detail.html b/scipost_django/templates/oauth2_provider/application_detail.html new file mode 100644 index 0000000000000000000000000000000000000000..e193c3ff7e1537b4df368dedb148d8daaa5fb08a --- /dev/null +++ b/scipost_django/templates/oauth2_provider/application_detail.html @@ -0,0 +1,90 @@ +{% extends "oauth2_provider/base.html" %} + +{% load i18n %} + +{% block breadcrumb_items %} + {{ block.super }} + <span class="breadcrumb-item"><a href="{% url 'oauth2_provider:list' %}">Applications</a></span> + + {% if object %} + <a href="#" + class="breadcrumb-item active">{{ object }}</a> + {% endif %} + +{% endblock %} + + +{% block content %} + <div class="block-center"> + <h3 class="block-center-heading">{{ application.name }}</h3> + + <dl> + + <dt>{% trans "Client id" %}</dt> + <dd> + <input class="form-control" + type="text" + value="{{ application.client_id }}" + readonly /> + </dd> + + + <dt>{% trans "Client secret" %}</dt> + <dd> + + {% if application.hash_client_secret %} + Client secret is hashed. If you don't remember it, you will need to generate a new application. + {% else %} + <input class="form-control" + type="text" + value="{{ application.client_secret }}" + readonly /> + {% endif %} + + </dd> + + + <dt>{% trans "Client type" %}</dt> + <dd> + {{ application.client_type }} + </dd> + + + <dt>{% trans "Authorization Grant Type" %}</dt> + <dd> + {{ application.authorization_grant_type }} + </dd> + + + <dt>{% trans "Redirect Uris" %}</dt> + <dd> + <textarea class="form-control" + readonly>{{ application.redirect_uris }}</textarea> + </dd> + + + <dt>{% trans "Post Logout Redirect Uris" %}</dt> + <dd> + <textarea class="form-control" + readonly>{{ application.post_logout_redirect_uris }}</textarea> + </dd> + + + <dt>{% trans "Allowed Origins" %}</dt> + <dd> + <textarea class="form-control" + readonly>{{ application.allowed_origins }}</textarea> + </dd> + + </ul> + + <div class="btn-toolbar"> + <a class="btn" + href="{% url "oauth2_provider:list" %}">{% trans "Go Back" %}</a> + <a class="btn btn-primary" + href="{% url "oauth2_provider:update" application.pk %}">{% trans "Edit" %}</a> + <a class="btn btn-danger" + href="{% url "oauth2_provider:delete" application.pk %}">{% trans "Delete" %}</a> + </div> + </div> +{% endblock content %} diff --git a/scipost_django/templates/oauth2_provider/application_form.html b/scipost_django/templates/oauth2_provider/application_form.html new file mode 100644 index 0000000000000000000000000000000000000000..d87653db9bc835e25f72e54f99a4c245799d3ac4 --- /dev/null +++ b/scipost_django/templates/oauth2_provider/application_form.html @@ -0,0 +1,38 @@ +{% extends "oauth2_provider/base.html" %} + +{% load crispy_forms_tags %} + +{% load i18n %} + +{% block breadcrumb_items %} + {{ block.super }} + <span class="breadcrumb-item"><a href="{% url 'oauth2_provider:list' %}">Applications</a></span> + + {% if object %} + <span class="breadcrumb-item">{{ object }}</span> + {% else %} + <span class="breadcrumb-item">Register</span> + {% endif %} + +{% endblock %} + + +{% block content %} + <form id="application-form" method="post" action=" + {% block app-form-action-url %}{% url 'oauth2_provider:update' application.pk %}{% endblock app-form-action-url %} + "> + {% csrf_token %} + {% crispy form %} + + + <div class="d-flex gap-2"> + <a class="btn" href=" + {% block app-form-back-url %}{% url "oauth2_provider:detail" application.pk %}{% endblock app-form-back-url %} + ">{% trans "Go Back" %}</a> + <button type="submit" + form="application-form" + class="btn btn-primary">{% trans "Save" %}</button> + </div> + + </form> +{% endblock %} diff --git a/scipost_django/templates/oauth2_provider/base.html b/scipost_django/templates/oauth2_provider/base.html index 2b14ed4c1c54ce8de9ac9a971931cb36591dd802..81670c08612dd5cc476e392bb53e446a78eb2e20 100644 --- a/scipost_django/templates/oauth2_provider/base.html +++ b/scipost_django/templates/oauth2_provider/base.html @@ -1 +1,13 @@ {% extends 'scipost/base.html' %} + +{% block breadcrumb %} + <div class="breadcrumb-container"> + <div class="container"> + <nav class="breadcrumb hidden-sm-down"> + + {% block breadcrumb_items %}<span class="breadcrumb-item">OAuth</span>{% endblock %} + + </nav> + </div> + </div> +{% endblock %}