From 00f1ab184e1681db1247a98cf43e230b27113382 Mon Sep 17 00:00:00 2001 From: Matthieu Fesselier <matthieu.fesselier@gmail.com> Date: Tue, 1 Dec 2020 11:01:01 +0100 Subject: [PATCH] update solid-auth --- .../Components/Solid-Auth.rst | 82 ++++++++++++------- 1 file changed, 51 insertions(+), 31 deletions(-) diff --git a/source/import_documentation/Components/Solid-Auth.rst b/source/import_documentation/Components/Solid-Auth.rst index 9126145..000b88e 100644 --- a/source/import_documentation/Components/Solid-Auth.rst +++ b/source/import_documentation/Components/Solid-Auth.rst @@ -8,16 +8,15 @@ Installation -------------- Initialize ``sib-auth`` in your HTML file: - .. code:: html +.. code:: html - <script type="module" src="https://unpkg.com/@startinblox/oidc@latest"></script> - <sib-auth> - <sib-auth-provider - data-authority="https://test-paris.happy-dev.fr/openid/" - data-id="paris" - > - </sib-auth-provider> - </sib-auth> + <script type="module" src="https://unpkg.com/@startinblox/oidc@latest"></script> + <sib-auth> + <sib-auth-provider + data-authority="https://test-paris.happy-dev.fr/openid/" + data-id="paris" + ></sib-auth-provider> + </sib-auth> `You'll find here the detail of the attributes configuration. <https://github.com/IdentityModel/oidc-client-js/wiki#usermanager>`__ @@ -26,13 +25,14 @@ Set an OIDC provider to your server ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ The Django package associated is there => https://github.com/jblemee/django-oidc-provider + More documentation here => https://django-oidc-provider.readthedocs.io/en/latest/ Don't forget to set up your RSA key: - .. code:: bash +.. code:: bash - python3 ./manage.py creatersakey + python3 ./manage.py creatersakey Setup your login button @@ -40,36 +40,56 @@ Setup your login button Here is an example to make you understand the logic: - .. code:: html +.. code:: html - <button id="login">Login</button> - <!-- wherever you want in your interface --> + <button id="login">Login</button> + <!-- wherever you want in your interface --> - <script> - // wherever you want in your project - document.querySelector('#login').addEventListener('click', () => { - document.querySelector('sib-auth').login() - }); - </script> + <script> + // wherever you want in your project + document.querySelector('#login').addEventListener('click', () => { + document.querySelector('sib-auth').login() + }); + </script> -.. _bind-user: -bind-user +Attributes ---------- - To associate the currently logged in user to a component, add the bind-user attribute to it. - It will set its ``data-src`` attribute to the currently logged in user's resource URL. - Example: - .. code:: html +.. _bind-user: +``bind-user`` +~~~~~~~~~~~~~ +To associate the currently logged in user to a component, add the bind-user attribute to it. +It will set its ``data-src`` attribute to the currently logged in user's resource URL. +Example: + +.. code:: html + + <sib-conversation bind-user></sib-conversation> + +will result in: + +.. code:: html + + <sib-conversation data-src="https://your-domain/your-user-uri/3" bind-user></sib-conversation> + - <sib-conversation bind-user></sib-conversation> +``auto-login`` +~~~~~~~~~~~~~~ +If set, ``auto-login`` will automatically redirect the user to the login page of his +provider if he's not authenticated yet. - will result in: +Example: - .. code:: html +.. code:: html - <sib-conversation data-src="https://your-domain/your-user-uri/3" bind-user></sib-conversation> + <sib-auth auto-login> + <sib-auth-provider + data-authority="https://test-paris.happy-dev.fr/openid/" + data-id="paris" + ></sib-auth-provider> + </sib-auth> -Methods available +Methods ------------------ ``login`` -- GitLab