diff --git a/requirements-swh.txt b/requirements-swh.txt --- a/requirements-swh.txt +++ b/requirements-swh.txt @@ -1,4 +1,4 @@ -swh.auth[django] >= 0.5.3 +swh.auth[django] >= 0.6.7 swh.core >= 0.0.95 swh.counters >= 0.5.1 swh.indexer >= 2.0.0 diff --git a/swh/web/add_forge_now/admin_views.py b/swh/web/add_forge_now/admin_views.py --- a/swh/web/add_forge_now/admin_views.py +++ b/swh/web/add_forge_now/admin_views.py @@ -3,7 +3,6 @@ # License: GNU Affero General Public License version 3, or any later version # See top-level LICENSE file for more information -from django.conf import settings from django.contrib.auth.decorators import user_passes_test from django.shortcuts import render @@ -11,7 +10,7 @@ from swh.web.auth.utils import is_add_forge_now_moderator -@user_passes_test(is_add_forge_now_moderator, login_url=settings.LOGIN_URL) +@user_passes_test(is_add_forge_now_moderator) def add_forge_now_requests_moderation_dashboard(request): """Moderation dashboard to allow listing current requests.""" return render( @@ -21,7 +20,7 @@ ) -@user_passes_test(is_add_forge_now_moderator, login_url=settings.LOGIN_URL) +@user_passes_test(is_add_forge_now_moderator) def add_forge_now_request_dashboard(request, request_id): """Moderation dashboard to allow listing current requests.""" return render( diff --git a/swh/web/add_forge_now/templates/add-forge-creation-form.html b/swh/web/add_forge_now/templates/add-forge-creation-form.html --- a/swh/web/add_forge_now/templates/add-forge-creation-form.html +++ b/swh/web/add_forge_now/templates/add-forge-creation-form.html @@ -13,12 +13,11 @@

You must be logged in to submit an add forge request. Please log in + href="{% url login_url %}?next={% url 'forge-add-create' %}"> + log in +

+ {% else %}
HttpResponse: """View to retrieve the message source for a given request history entry""" diff --git a/swh/web/api/templates/api.html b/swh/web/api/templates/api.html --- a/swh/web/api/templates/api.html +++ b/swh/web/api/templates/api.html @@ -38,9 +38,11 @@
  • Rate limiting
  • -
  • - Authentication -
  • + {% if oidc_enabled %} +
  • + Authentication +
  • + {% endif %}

    Endpoint index

    @@ -277,28 +279,30 @@ X-RateLimit-Remaining: 119 X-RateLimit-Reset: 1620639052 -

    Authentication

    -

    - It is possible to perform authenticated requests to the Web API through the use of a bearer token - sent in HTTP Authorization headers. -
    - To obtain such a token, an account to the - Software Heritage Authentication service must be created. -
    - To generate and manage bearer tokens, a dedicated interface is available on the - user profile page once logged in. -

    -

    - The following shows how to perform an authenticated request to the Web API using curl. -

    export TOKEN=eyJhbGciOiJIUzI1NiIsInR5cCIgOiAiSldUIiwia2lkIiA6ICJhMTMxYTQ1My1hM2IyLTQwMTUtO...
    -curl -H "Authorization: Bearer ${TOKEN}" {{ site_base_url }}api/...
    -

    -

    - Authenticated requests can be used to lift rate limiting if the user account has the adequate - permission. - If you are in such a need, please contact us - and we will review your request. -

    + {% if oidc_enabled %} +

    Authentication

    +

    + It is possible to perform authenticated requests to the Web API through the use of a bearer token + sent in HTTP Authorization headers. +
    + To obtain such a token, an account to the + Software Heritage Authentication service must be created. +
    + To generate and manage bearer tokens, a dedicated interface is available on the + user profile page once logged in. +

    +

    + The following shows how to perform an authenticated request to the Web API using curl. +

    export TOKEN=eyJhbGciOiJIUzI1NiIsInR5cCIgOiAiSldUIiwia2lkIiA6ICJhMTMxYTQ1My1hM2IyLTQwMTUtO...
    +  curl -H "Authorization: Bearer ${TOKEN}" {{ site_base_url }}api/...
    +

    +

    + Authenticated requests can be used to lift rate limiting if the user account has the adequate + permission. + If you are in such a need, please contact us + and we will review your request. +

    + {% endif %}