Skip to content

Commit

Permalink
Merge 96dfa1b into 2eeac44
Browse files Browse the repository at this point in the history
  • Loading branch information
Jerome Leclanche committed Mar 5, 2014
2 parents 2eeac44 + 96dfa1b commit 21254e9
Show file tree
Hide file tree
Showing 9 changed files with 164 additions and 9 deletions.
4 changes: 2 additions & 2 deletions docs/developers/roadmap.rst
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,8 @@ Estimated release April 2014
- Stats speedup -- work on Stats speedups.
- Concordance searching.
- amaGama -- automate updating of resources.
- Social/Persona authentication to make it easier for users to login and
contribute.
- Translation editor improvements:

- `Highlight placeable
Expand Down Expand Up @@ -59,8 +61,6 @@ Estimated release October 2014

- Social sharing of projects, strings, etc for community building and
community input.
- Social/Persona authentication to make it easier for users to login and
contribute.
- OpenBadges -- implement badges to reward team members contributions.

- Team review of translations.
Expand Down
14 changes: 14 additions & 0 deletions docs/features/authentication.rst
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,20 @@
Authentication Backends
=======================

.. _authentication#social:

Social Authentication
-------------------

Pootle uses Django-Allauth for authentication, which supports several social
authentication backends. By default, support for OpenID as well as
`Persona <https://www.mozilla.org/en-US/persona/>`_ is enabled with no further
configuration requirements.

Support for various OAuth and OAuth2 backends, such as Google and Facebook, can
be enabled. For a full list of providers and additional settings, refer to the
`Allauth documentation <https://github.com/pennersr/django-allauth#supported-providers>`_.

.. _authentication#ldap:

LDAP Authentication
Expand Down
3 changes: 3 additions & 0 deletions docs/releases/2.5.2-rc1.rst
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,9 @@ These are by no means exhaustive, check the `git log
<https://github.com/translate/pootle/compare/stable%2F2.5.1...master>`_
for more details.

- The registration and authentication layer is now handled by django-allauth.
This gives Pootle implicit support for OpenID, OAuth, OAuth2 and Persona
sign-in support.
- Placeables are used to highlight parts of the source text and easily insert
them into the translation.
- Local Translation Memory (TM) augments the already available `amaGama
Expand Down
20 changes: 20 additions & 0 deletions pootle/settings/40-apps.conf
Original file line number Diff line number Diff line change
Expand Up @@ -104,6 +104,26 @@ LOGIN_REDIRECT_URL = "/"
# Number of days users will have to activate their accounts after registering
ACCOUNT_EMAIL_CONFIRMATION_EXPIRE_DAYS = 10

# Available third-party authentication providers
# allauth.socialaccount.providers.<provider> must be present in INSTALLED_APPS
# in 50-project.conf in order for these to work.
SOCIALACCOUNT_PROVIDERS = {
"openid": {
# Here you can add various OpenID providers to be supported by default
# See: https://github.com/pennersr/django-allauth#openid
"SERVERS": [
{
"id": "google",
"name": "Google",
"openid_url": "https://www.google.com/accounts/o8/id",
},
],
},
"persona": {
"REQUEST_PARAMETERS": {"siteName": "Pootle"},
},
}

#
# South
#
Expand Down
3 changes: 3 additions & 0 deletions pootle/settings/50-project.conf
Original file line number Diff line number Diff line change
Expand Up @@ -96,6 +96,9 @@ INSTALLED_APPS = [
'allauth',
'allauth.account',
'allauth.socialaccount',
# Uncomment these to add support for OpenID / Persona authentication
# 'allauth.socialaccount.providers.openid',
# 'allauth.socialaccount.providers.persona',
'profiles',
'djblets.siteconfig',
'djblets.util',
Expand Down
41 changes: 41 additions & 0 deletions pootle/static/css/style.css
Original file line number Diff line number Diff line change
Expand Up @@ -1440,6 +1440,47 @@ div.settings-container
display: block;
}

#login-wrapper
{
margin: auto;
overflow: hidden;
padding: 2em;
}

#login-alternative
{
float: right;
padding-top: 2em;
text-align: right;
}

html[dir="rtl"] #login-alternative
{
float: left;
text-align: left;
}

#login-alternative h4
{
margin-bottom: 0.7em;
}

#login-alternative h5
{
font-size: 1.15em;
margin-bottom: 0.5em;
}

#forgot-password
{
float: left;
}

html[dir="rtl"] #forgot-password
{
float: right;
}

.settings-container table
{
width: 100%;
Expand Down
31 changes: 24 additions & 7 deletions pootle/templates/account/login.html
Original file line number Diff line number Diff line change
@@ -1,30 +1,47 @@
{% extends "layout.html" %}
{% load i18n locale %}
{% load i18n locale socialaccount %}

{% block title %}{% trans "Login" %} | {{ block.super }}{% endblock %}

{% block extra_head %}
{% providers_media_js %}
{% endblock %}

{% block breadcrumbs %}
{{ block.super }}<li>{% trans "Login" %}</li>
{% endblock %}

{% block content %}
<div id="login" class="form" dir="{% locale_dir %}">
<div id="login-wrapper">

{% if socialaccount.providers %}
<div id="login-alternative">
<h5>{% trans "Or sign in using:" %}</h5>
<ul class="socialaccount_providers">
{% include "socialaccount/snippets/provider_list.html" with process="login" %}
</ul>
</div>
{% endif %}

<div id="login" class="form">
<h2>{% trans 'Login to Pootle' %}</h2>
<form method="post" action="{% url 'account_login' %}" name="loginform">
{% csrf_token %}
{{ form.as_p }}
{% if redirect_field_value %}
<input type="hidden" name="{{ redirect_field_name }}" value="{{ redirect_field_value }}" />
<input type="hidden" name="{{ redirect_field_name }}" value="{{ redirect_field_value }}"/>
{% endif %}

<p class="buttons">
<input type="submit" class="login" value="{% trans 'Login' %}" />
<a href="{% url 'account_reset_password' %}" id="forgot-password">{% trans "Lost your Password?" %}</a>
<input type="submit" class="login" value="{% trans 'Login' %}"/>
</p>

</form>
</div>

<h2 class="formlink">
<a href="{% url 'account_reset_password' %}">{% trans "Lost your Password?" %}</a>
</h2>
</div>

{% if settings.CAN_REGISTER %}
<h2 class="formlink">{% trans "Don't have an account yet?" %}
<a href="{{ signup_url }}" title="{% trans 'Register.' %}">{% trans "Register." %}</a>
Expand Down
27 changes: 27 additions & 0 deletions pootle/templates/openid/login.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
{% extends "layout.html" %}
{% load i18n locale %}

{% block title %}{% trans "OpenID Login" %} | {{ block.super }}{% endblock %}

{% block breadcrumbs %}
{{ block.super }}<li>{% trans "OpenID Login" %}</li>
{% endblock %}

{% block content %}
<div id="login-wrapper">
<div id="login" class="form">
<h2>{% trans 'OpenID Login' %}</h2>
<form id="openid_login_form" class="openid_login" method="post" action="{% url 'openid_login' %}">
{% csrf_token %}
{{form.as_p}}
<p class="buttons">
<input type="submit" class="login" value="{% trans 'Login' %}"/>
</p>
</form>
</div>

<div id="login-alternative">
<h5><a href="{% url 'account_login' %}">{% trans "Return to password login" %}</a>
</div>
</div>
{% endblock content %}
30 changes: 30 additions & 0 deletions pootle/templates/socialaccount/signup.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
{% extends "layout.html" %}
{% load i18n locale %}

{% block title %}{% trans "Register" %} | {{ block.super }}{% endblock %}

{% block breadcrumbs %}
{{ block.super }}<li>{% trans "Register" %}</li>
{% endblock %}

{% block content %}
<div id="register" class="form" dir="{% locale_dir %}">
<h2>{% trans "Register a New Pootle Account" %}</h2>

<p>
{% blocktrans with provider_name=account.get_provider.name site_name=site.name %}You are about to use your {{provider_name}} account to login to {{site_name}}.<br/>
As a final step, please complete the following form:{% endblocktrans %}
</p>

<form class="signup" id="signup_form" method="post" action="{% url 'socialaccount_signup' %}">
{% csrf_token %}
{{ form.as_p }}
{% if redirect_field_value %}
<input type="hidden" name="{{ redirect_field_name }}" value="{{ redirect_field_value }}" />
{% endif %}
<p class="buttons">
<input type="submit" class="register" value="{% trans 'Register' %}" />
</p>
</form>
</div>
{% endblock %}

0 comments on commit 21254e9

Please sign in to comment.