From 99ef4287bdc39f2a5658c009e1ef6f1867454f74 Mon Sep 17 00:00:00 2001 From: sahama Date: Wed, 31 Jul 2024 11:49:56 +0330 Subject: [PATCH] add oauth2-provider templates to project --- accounts/settings.py | 2 - .../application_confirm_delete.html | 18 ++++++ .../oauth2_provider/application_detail.html | 56 +++++++++++++++++++ .../oauth2_provider/application_form.html | 42 ++++++++++++++ .../oauth2_provider/application_list.html | 20 +++++++ .../application_registration_form.html | 9 +++ templates/oauth2_provider/authorize.html | 40 +++++++++++++ .../authorized-token-delete.html | 9 +++ .../oauth2_provider/authorized-tokens.html | 23 ++++++++ templates/oauth2_provider/base.html | 48 ++++++++++++++++ templates/oauth2_provider/logout_confirm.html | 37 ++++++++++++ 11 files changed, 302 insertions(+), 2 deletions(-) create mode 100644 templates/oauth2_provider/application_confirm_delete.html create mode 100644 templates/oauth2_provider/application_detail.html create mode 100644 templates/oauth2_provider/application_form.html create mode 100644 templates/oauth2_provider/application_list.html create mode 100644 templates/oauth2_provider/application_registration_form.html create mode 100644 templates/oauth2_provider/authorize.html create mode 100644 templates/oauth2_provider/authorized-token-delete.html create mode 100644 templates/oauth2_provider/authorized-tokens.html create mode 100644 templates/oauth2_provider/base.html create mode 100644 templates/oauth2_provider/logout_confirm.html diff --git a/accounts/settings.py b/accounts/settings.py index 2daa79c..bd4d773 100644 --- a/accounts/settings.py +++ b/accounts/settings.py @@ -79,8 +79,6 @@ OIDC_RSA_PRIVATE_KEY_FILE_PATH = config('OIDC_RSA_PRIVATE_KEY_FILE_PATH', defaul with open(OIDC_RSA_PRIVATE_KEY_FILE_PATH) as oidc_rsa_private_key_file: OIDC_RSA_PRIVATE_KEY = oidc_rsa_private_key_file.read() -print(OIDC_RSA_PRIVATE_KEY) - OAUTH2_PROVIDER = { # this is the list of available scopes 'SCOPES_BACKEND_CLASS': 'apps.gooyal_oauth2.scopes.Scopes', diff --git a/templates/oauth2_provider/application_confirm_delete.html b/templates/oauth2_provider/application_confirm_delete.html new file mode 100644 index 0000000..4716dc5 --- /dev/null +++ b/templates/oauth2_provider/application_confirm_delete.html @@ -0,0 +1,18 @@ +{% extends "oauth2_provider/base.html" %} + +{% load i18n %} +{% block content %} +
+

{% trans "Are you sure to delete the application" %} {{ application.name }}?

+
+ {% csrf_token %} + + +
+
+{% endblock content %} diff --git a/templates/oauth2_provider/application_detail.html b/templates/oauth2_provider/application_detail.html new file mode 100644 index 0000000..74b71ee --- /dev/null +++ b/templates/oauth2_provider/application_detail.html @@ -0,0 +1,56 @@ +{% extends "oauth2_provider/base.html" %} + +{% load i18n %} +{% block content %} +
+

{{ application.name }}

+ + + + +
+{% endblock content %} diff --git a/templates/oauth2_provider/application_form.html b/templates/oauth2_provider/application_form.html new file mode 100644 index 0000000..7d8c079 --- /dev/null +++ b/templates/oauth2_provider/application_form.html @@ -0,0 +1,42 @@ +{% extends "oauth2_provider/base.html" %} + +{% load i18n %} +{% block content %} +
+
+

+ {% block app-form-title %} + {% trans "Edit application" %} {{ application.name }} + {% endblock app-form-title %} +

+ {% csrf_token %} + + {% for field in form %} +
+ +
+ {{ field }} + {% for error in field.errors %} + {{ error }} + {% endfor %} +
+
+ {% endfor %} + +
+ {% for error in form.non_field_errors %} + {{ error }} + {% endfor %} +
+ +
+
+ + {% trans "Go Back" %} + + +
+
+
+
+{% endblock %} diff --git a/templates/oauth2_provider/application_list.html b/templates/oauth2_provider/application_list.html new file mode 100644 index 0000000..509ccfc --- /dev/null +++ b/templates/oauth2_provider/application_list.html @@ -0,0 +1,20 @@ +{% extends "oauth2_provider/base.html" %} + +{% load i18n %} +{% block content %} +
+

{% trans "Your applications" %}

+ {% if applications %} + + + {% trans "New Application" %} + {% else %} + +

{% trans "No applications defined" %}. {% trans "Click here" %} {% trans "if you want to register a new one" %}

+ {% endif %} +
+{% endblock content %} diff --git a/templates/oauth2_provider/application_registration_form.html b/templates/oauth2_provider/application_registration_form.html new file mode 100644 index 0000000..c22eca9 --- /dev/null +++ b/templates/oauth2_provider/application_registration_form.html @@ -0,0 +1,9 @@ +{% extends "oauth2_provider/application_form.html" %} + +{% load i18n %} + +{% block app-form-title %}{% trans "Register a new application" %}{% endblock app-form-title %} + +{% block app-form-action-url %}{% url 'oauth2_provider:register' %}{% endblock app-form-action-url %} + +{% block app-form-back-url %}{% url "oauth2_provider:list" %}"{% endblock app-form-back-url %} diff --git a/templates/oauth2_provider/authorize.html b/templates/oauth2_provider/authorize.html new file mode 100644 index 0000000..96c4ca8 --- /dev/null +++ b/templates/oauth2_provider/authorize.html @@ -0,0 +1,40 @@ +{% extends "oauth2_provider/base.html" %} + +{% load i18n %} +{% block content %} +
+ {% if not error %} +
+

{% trans "Authorize" %} {{ application.name }}?

+ {% csrf_token %} + + {% for field in form %} + {% if field.is_hidden %} + {{ field }} + {% endif %} + {% endfor %} + +

{% trans "Application requires the following permissions" %}

+
    + {% for scope in scopes_descriptions %} +
  • {{ scope }}
  • + {% endfor %} +
+ + {{ form.errors }} + {{ form.non_field_errors }} + +
+
+ + +
+
+
+ + {% else %} +

Error: {{ error.error }}

+

{{ error.description }}

+ {% endif %} +
+{% endblock %} diff --git a/templates/oauth2_provider/authorized-token-delete.html b/templates/oauth2_provider/authorized-token-delete.html new file mode 100644 index 0000000..02a6ff4 --- /dev/null +++ b/templates/oauth2_provider/authorized-token-delete.html @@ -0,0 +1,9 @@ +{% extends "oauth2_provider/base.html" %} + +{% load i18n %} +{% block content %} +
{% csrf_token %} +

{% trans "Are you sure you want to delete this token?" %}

+ +
+{% endblock %} diff --git a/templates/oauth2_provider/authorized-tokens.html b/templates/oauth2_provider/authorized-tokens.html new file mode 100644 index 0000000..0f27325 --- /dev/null +++ b/templates/oauth2_provider/authorized-tokens.html @@ -0,0 +1,23 @@ +{% extends "oauth2_provider/base.html" %} + +{% load i18n %} +{% block content %} +
+

{% trans "Tokens" %}

+ +
+{% endblock %} diff --git a/templates/oauth2_provider/base.html b/templates/oauth2_provider/base.html new file mode 100644 index 0000000..048c41f --- /dev/null +++ b/templates/oauth2_provider/base.html @@ -0,0 +1,48 @@ + + + + + {% block title %}{% endblock title %} + + + + + {% block css %} + + {% endblock css %} + + + + + + +
+ {% block content %} + {% endblock content %} +
+ + + diff --git a/templates/oauth2_provider/logout_confirm.html b/templates/oauth2_provider/logout_confirm.html new file mode 100644 index 0000000..8b64f83 --- /dev/null +++ b/templates/oauth2_provider/logout_confirm.html @@ -0,0 +1,37 @@ +{% extends "oauth2_provider/base.html" %} + +{% load i18n %} +{% block content %} +
+ {% if not error %} +
+ {% if application %} +

Confirm Logout requested by {{ application.name }}

+ {% else %} +

Confirm Logout

+ {% endif %} + {% csrf_token %} + + {% for field in form %} + {% if field.is_hidden %} + {{ field }} + {% endif %} + {% endfor %} + + {{ form.errors }} + {{ form.non_field_errors }} + +
+
+ + +
+
+
+ + {% else %} +

Error: {{ error.error }}

+

{{ error.description }}

+ {% endif %} +
+{% endblock %}