-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Added support for CAS ESN Accounts login #27
- Loading branch information
1 parent
73693d3
commit ab320f1
Showing
15 changed files
with
231 additions
and
19 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
{% extends "fiesta/base.html" %} | ||
|
||
{% block main %} | ||
<ul class="list-disc"> | ||
{% for sa in request.user.socialaccount_set.all %} | ||
<li> | ||
{% if sa.provider == 'esnaccounts' %} | ||
<ul class="list-disc"> | ||
{% for role in sa.extra_data.roles %} | ||
<li>role: {{ role }}</li> | ||
{% endfor %} | ||
|
||
<li>joined: {{ sa.date_joined }} | ||
<li>email: {{ sa.extra_data.mail }} | ||
<li>uid: {{ sa.extra_data.uid }} | ||
<li><img src="{{ sa.extra_data.picture }}" width="60px"> | ||
<li>data: {{ sa.extra_data }} | ||
</ul> | ||
{% else %} | ||
{{ sa.provider }} | ||
{% endif %} | ||
</li> | ||
{% endfor %} | ||
</ul> | ||
|
||
{% endblock %} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,13 +1,15 @@ | ||
from django.urls import path | ||
|
||
# Define your urls here | ||
from django.views.generic import TemplateView | ||
|
||
from apps.accounts.views.profile import ProfileView | ||
|
||
urlpatterns = [ | ||
path( | ||
"auth/login", | ||
TemplateView.as_view(template_name="accounts/auth/login.html"), | ||
name="login", | ||
), | ||
path("profile", ProfileView.as_view()), | ||
path("", TemplateView.as_view(template_name="accounts/index.html")), | ||
] |
Empty file.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
from django.views.generic import TemplateView | ||
from django.utils.translation import gettext_lazy as _ | ||
|
||
from apps.utils.breadcrumbs import with_breadcrumb | ||
|
||
|
||
@with_breadcrumb(_('My Profile')) | ||
class ProfileView(TemplateView): | ||
template_name = 'accounts/profile.html' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
__version__ = "0.5.0" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
from django.apps import AppConfig | ||
|
||
|
||
class ESNAccountsConfig(AppConfig): | ||
default_auto_field = "django.db.models.BigAutoField" | ||
name = "apps.esnaccounts" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
from allauth.socialaccount.providers.base import ProviderAccount | ||
from allauth_cas.providers import CASProvider | ||
|
||
|
||
class ESNAccountsAccount(ProviderAccount): | ||
pass | ||
|
||
|
||
class ESNAccountsProvider(CASProvider): | ||
id = "esnaccounts" | ||
name = "ESN Accounts" | ||
account_class = ESNAccountsAccount | ||
|
||
# TODO: fix extract_common_fields to load data from extra_data | ||
|
||
|
||
provider_classes = [ESNAccountsProvider] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
from allauth_cas.urls import default_urlpatterns | ||
|
||
from .provider import ESNAccountsProvider | ||
|
||
urlpatterns = default_urlpatterns(ESNAccountsProvider) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
from allauth_cas.views import CASAdapter, CASCallbackView, CASLoginView, CASLogoutView | ||
|
||
from .provider import ESNAccountsProvider | ||
|
||
|
||
class ESNAccountsAdapter(CASAdapter): | ||
provider_id = ESNAccountsProvider.id | ||
url = "https://accounts.esn.org/cas/" | ||
version = 3 | ||
|
||
|
||
login = CASLoginView.adapter_view(ESNAccountsAdapter) | ||
|
||
callback = CASCallbackView.adapter_view(ESNAccountsAdapter) | ||
|
||
logout = CASLogoutView.adapter_view(ESNAccountsAdapter) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
File renamed without changes.
Oops, something went wrong.