account linking and docs update
This commit is contained in:
parent
a112824578
commit
8d65d20d1f
17
cookbook/migrations/0107_auto_20210128_1535.py
Normal file
17
cookbook/migrations/0107_auto_20210128_1535.py
Normal file
@ -0,0 +1,17 @@
|
|||||||
|
# Generated by Django 3.1.5 on 2021-01-28 14:35
|
||||||
|
|
||||||
|
from django.db import migrations
|
||||||
|
|
||||||
|
|
||||||
|
class Migration(migrations.Migration):
|
||||||
|
|
||||||
|
dependencies = [
|
||||||
|
('cookbook', '0106_shoppinglist_supermarket'),
|
||||||
|
]
|
||||||
|
|
||||||
|
operations = [
|
||||||
|
migrations.AlterModelOptions(
|
||||||
|
name='supermarketcategoryrelation',
|
||||||
|
options={'ordering': ('order',)},
|
||||||
|
),
|
||||||
|
]
|
@ -35,6 +35,7 @@
|
|||||||
class="fas fa-save"></i> {% trans 'Save' %}</button>
|
class="fas fa-save"></i> {% trans 'Save' %}</button>
|
||||||
</form>
|
</form>
|
||||||
|
|
||||||
|
<a href="{% url 'socialaccount_connections' %}">{% trans 'Link social account' %}</a>
|
||||||
<br/>
|
<br/>
|
||||||
<br/>
|
<br/>
|
||||||
|
|
||||||
|
55
cookbook/templates/socialaccount/connections.html
Normal file
55
cookbook/templates/socialaccount/connections.html
Normal file
@ -0,0 +1,55 @@
|
|||||||
|
{% extends "base.html" %}
|
||||||
|
{% load i18n %}
|
||||||
|
|
||||||
|
{% block head_title %}{% trans "Account Connections" %}{% endblock %}
|
||||||
|
|
||||||
|
{% block content %}
|
||||||
|
<h3>{% trans "Account Connections" %}</h3>
|
||||||
|
|
||||||
|
{% if form.accounts %}
|
||||||
|
<p>{% blocktrans %}You can sign in to your account using any of the following third party
|
||||||
|
accounts:{% endblocktrans %}</p>
|
||||||
|
|
||||||
|
|
||||||
|
<form method="post" action="{% url 'socialaccount_connections' %}">
|
||||||
|
{% csrf_token %}
|
||||||
|
|
||||||
|
<fieldset>
|
||||||
|
{% if form.non_field_errors %}
|
||||||
|
<div id="errorMsg">{{ form.non_field_errors }}</div>
|
||||||
|
{% endif %}
|
||||||
|
|
||||||
|
{% for base_account in form.accounts %}
|
||||||
|
{% with base_account.get_provider_account as account %}
|
||||||
|
<div>
|
||||||
|
<label for="id_account_{{ base_account.id }}">
|
||||||
|
<input id="id_account_{{ base_account.id }}" type="radio" name="account"
|
||||||
|
value="{{ base_account.id }}"/>
|
||||||
|
<span class="socialaccount_provider {{ base_account.provider }} {{ account.get_brand.id }}">{{ account.get_brand.name }}</span>
|
||||||
|
{{ account }}
|
||||||
|
</label>
|
||||||
|
</div>
|
||||||
|
{% endwith %}
|
||||||
|
{% endfor %}
|
||||||
|
|
||||||
|
<div>
|
||||||
|
<button class="btn btn-warning" type="submit">{% trans 'Remove' %}</button>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
</fieldset>
|
||||||
|
|
||||||
|
</form>
|
||||||
|
|
||||||
|
{% else %}
|
||||||
|
<p>{% trans 'You currently have no social network accounts connected to this account.' %}</p>
|
||||||
|
{% endif %}
|
||||||
|
|
||||||
|
<h4>{% trans 'Add a 3rd Party Account' %}</h4>
|
||||||
|
|
||||||
|
<ul class="socialaccount_providers">
|
||||||
|
{% include "socialaccount/snippets/provider_list.html" with process="connect" %}
|
||||||
|
</ul>
|
||||||
|
|
||||||
|
{% include "socialaccount/snippets/login_extra.html" %}
|
||||||
|
|
||||||
|
{% endblock %}
|
@ -18,19 +18,50 @@ Choose a provider from the [list](https://django-allauth.readthedocs.io/en/lates
|
|||||||
in the example below.
|
in the example below.
|
||||||
|
|
||||||
```ini
|
```ini
|
||||||
SOCIAL_PROVIDERS = allauth.socialaccount.providers.github, allauth.socialaccount.providers.nextcloud,
|
SOCIAL_PROVIDERS=allauth.socialaccount.providers.github,allauth.socialaccount.providers.nextcloud
|
||||||
```
|
```
|
||||||
|
|
||||||
|
!!! warning "Formatting"
|
||||||
|
The exact formatting is important so make sure to follow the steps explained here!
|
||||||
|
|
||||||
|
Depending on your authentication provider you **might need** to configure it.
|
||||||
|
This needs to be done trough the settings system. To make the system flexible (allow multiple providers) and to
|
||||||
|
not require another file to be mounted into the container the configuration ins done trough a single
|
||||||
|
environment variable. The downside of this approach is that the configuration needs to be put into a single line
|
||||||
|
as environment files loaded by docker compose don't support multiple lines for a single variable.
|
||||||
|
|
||||||
|
Take the example configuration from the allauth docs, fill in your settings and then inline the whole object
|
||||||
|
(you can use a service like [www.freeformatter.com](https://www.freeformatter.com/json-formatter.html) for formatting).
|
||||||
|
Assign it to the `SOCIALACCOUNT_PROVIDERS` variable.
|
||||||
|
|
||||||
|
```ini
|
||||||
|
SOCIALACCOUNT_PROVIDERS={"nextcloud":{"SERVER":"https://nextcloud.example.org"}}
|
||||||
|
```
|
||||||
|
|
||||||
|
!!! success "Improvements ?"
|
||||||
|
There are most likely ways to achieve the same goal but with a cleaner or simpler system.
|
||||||
|
If you know such a way feel free to let me know.
|
||||||
|
|
||||||
After that, use your superuser account to configure your authentication backend.
|
After that, use your superuser account to configure your authentication backend.
|
||||||
Open the admin page and do the following
|
Open the admin page and do the following
|
||||||
|
|
||||||
1. Select `Sites` and create a new site with the URL of your installation.
|
1. Select `Sites` and edit the default site with the URL of your installation (or create a new).
|
||||||
2. Create a new `Social Application` with the required information as stated in the provider documentation of allauth.
|
2. Create a new `Social Application` with the required information as stated in the provider documentation of allauth.
|
||||||
3. Make sure to add your site to the list of available sites
|
3. Make sure to add your site to the list of available sites
|
||||||
|
|
||||||
Now the provider is configured and you should be able to sign up and sign in using the provider.
|
Now the provider is configured and you should be able to sign up and sign in using the provider.
|
||||||
|
Use the superuser account to grant permissions to the newly created users.
|
||||||
|
|
||||||
|
!!! info "WIP"
|
||||||
|
I do not have a ton of experience with using various single signon providers and also cannot test all of them.
|
||||||
|
If you have any Feedback or issues let me know.
|
||||||
|
|
||||||
|
### Linking accounts
|
||||||
|
To link an account to an already existing normal user go to the settings page of the user and link it.
|
||||||
|
Here you can also unlink your account if you no longer want to use a social login method.
|
||||||
|
|
||||||
## Reverse Proxy Authentication
|
## Reverse Proxy Authentication
|
||||||
|
|
||||||
!!! Info "Community Contributed Tutorial"
|
!!! Info "Community Contributed Tutorial"
|
||||||
This tutorial was provided by a community member. Since I do not use reverse proxy authentication, I cannot provide any
|
This tutorial was provided by a community member. Since I do not use reverse proxy authentication, I cannot provide any
|
||||||
assistance should you choose to use this authentication method.
|
assistance should you choose to use this authentication method.
|
||||||
|
Loading…
Reference in New Issue
Block a user