Commit 73effbed30efff1e577c1c32e3ef6b98cd78e269

Authored by Gust
Committed by Luciano Prestes
1 parent bdbb7a93

Remove persona from colab

Signed-off-by: Gustavo Jaruga <darksshades@gmail.com>
Signed-off-by: Lucas Moura <lucas.moura128@gmail.com>
colab.spec
... ... @@ -131,8 +131,6 @@ ALLOWED_HOSTS:
131 131 ## Disable indexing
132 132 ROBOTS_NOINDEX: false
133 133  
134   -## Disable browser id authentication
135   -# BROWSERID_ENABLED: true
136 134 EOF
137 135 chown root:colab /etc/colab/settings.yaml
138 136 chmod 0640 /etc/colab/settings.yaml
... ...
colab/accounts/auth.py
... ... @@ -1,7 +0,0 @@
1   -
2   -from django_browserid.auth import BrowserIDBackend
3   -
4   -
5   -class ColabBrowserIDBackend(BrowserIDBackend):
6   - def filter_users_by_email(self, email):
7   - return self.User.objects.filter(emails__address=email)
colab/accounts/middleware.py
... ... @@ -1,24 +0,0 @@
1   -
2   -from django.shortcuts import redirect
3   -from django.conf import settings
4   -
5   -VIEW_NAMES_ALLOWED = ('signup', 'Logout')
6   -
7   -
8   -class UserRegisterMiddleware(object):
9   -
10   - def process_view(self, request, view_func, view_args, view_kwargs):
11   - if not settings.BROWSERID_ENABLED:
12   - return
13   -
14   - if request.is_ajax():
15   - return
16   -
17   - if not request.user.is_authenticated():
18   - return
19   -
20   - if not request.user.needs_update:
21   - return
22   -
23   - if view_func.__name__ not in VIEW_NAMES_ALLOWED:
24   - return redirect('signup')
colab/accounts/templates/accounts/login.html
... ... @@ -1,12 +0,0 @@
1   -{% extends 'base.html' %}
2   -{% load browserid i18n %}
3   -
4   -{% block main-content %}
5   - <br><br><br>
6   - <div class="col-lg-12 text-center">
7   - <p>{% trans 'To login please click in the link below:'%}</p>
8   - {% trans 'Login' as login_text %}
9   - {% browserid_login text=login_text link_class='btn btn-primary btn-lg' %}
10   - </div>
11   - <br><br><br>
12   -{% endblock %}
colab/accounts/templates/accounts/user_update_form.html
... ... @@ -178,20 +178,18 @@ $(function() {
178 178 </div>
179 179 </div>
180 180 </div>
181   - {% if not BROWSERID_ENABLED %}
182   - <div class="col-lg-4 col-md-5 col-sm-12 col-xm-12">
183   - <div class="panel panel-default">
184   - <div class="panel-heading">
185   - <h3 class="panel-title">
186   - {% trans 'Change Password' %}
187   - </h3>
188   - </div>
189   - <div class="panel-body">
190   - <a href="{% url 'password_change' %}" class="btn btn-default btn-primary pull-right btn-block">{% trans "Change Password" %}</a>
191   - </div>
  181 + <div class="col-lg-4 col-md-5 col-sm-12 col-xm-12">
  182 + <div class="panel panel-default">
  183 + <div class="panel-heading">
  184 + <h3 class="panel-title">
  185 + {% trans 'Change Password' %}
  186 + </h3>
  187 + </div>
  188 + <div class="panel-body">
  189 + <a href="{% url 'password_change' %}" class="btn btn-default btn-primary pull-right btn-block">{% trans "Change Password" %}</a>
192 190 </div>
193 191 </div>
194   - {% endif %}
  192 + </div>
195 193 </div>
196 194 <div class="row">
197 195 <div class="submit">
... ...
colab/accounts/tests/test_view_signup.py
... ... @@ -21,13 +21,6 @@ class TestSignUpView(TestCase):
21 21 "usertest@colab.com.br", "123colab4")
22 22 return user
23 23  
24   - def test_user_not_authenticated(self):
25   - with self.settings(BROWSERID_ENABLED=True):
26   - response = self.client.get("/account/register")
27   - self.assertEquals(302, response.status_code)
28   - url = "http://testserver/account/login"
29   - self.assertEquals(url, response.url)
30   -
31 24 def test_user_authenticated_and_unregistered(self):
32 25 self.client.login(username="usertestcolab", password="123colab4")
33 26 response = self.client.get("/account/register/")
... ...
colab/accounts/urls.py
... ... @@ -2,48 +2,40 @@
2 2 from django.conf import settings
3 3 from django.conf.urls import patterns, url
4 4  
5   -from .views import (UserProfileDetailView, UserProfileUpdateView, LoginView,
  5 +from .views import (UserProfileDetailView, UserProfileUpdateView,
6 6 ManageUserSubscriptionsView)
7 7  
8 8 from colab.accounts import views
9 9 from django.contrib.auth import views as auth_views
10 10  
11 11  
12   -BROWSERID_ENABLED = getattr(settings, 'BROWSERID_ENABLED', False)
  12 +urlpatterns = patterns('',
  13 + url(r'^login/?$', 'django.contrib.auth.views.login', name='login'),
13 14  
  15 + url(r'^logout/?$', 'django.contrib.auth.views.logout',
  16 + {'next_page':'home'}, name='logout'),
14 17  
15   -if not BROWSERID_ENABLED:
16   - urlpatterns = patterns('',
17   - url(r'^login/?$', 'django.contrib.auth.views.login', name='login'),
  18 + url(r'^password-reset-done/?$', 'colab.accounts.views.password_reset_done_custom',
  19 + name="password_reset_done"),
  20 + url(r'^password-reset-complete/$', 'colab.accounts.views.password_reset_complete_custom',
  21 + name="password_reset_complete"),
18 22  
19   - url(r'^logout/?$', 'django.contrib.auth.views.logout',
20   - {'next_page':'home'}, name='logout'),
  23 + url(r'^password-reset-confirm/(?P<uidb64>[0-9A-Za-z]+)-(?P<token>.+)/$',
  24 + auth_views.password_reset_confirm,
  25 + {'template_name':'registration/password_reset_confirm_custom.html'},
  26 + name="password_reset_confirm"),
21 27  
22   - url(r'^password-reset-done/?$', 'colab.accounts.views.password_reset_done_custom',
23   - name="password_reset_done"),
24   - url(r'^password-reset-complete/$', 'colab.accounts.views.password_reset_complete_custom',
25   - name="password_reset_complete"),
  28 + url(r'^password-reset/?$', auth_views.password_reset,
  29 + {'template_name':'registration/password_reset_form_custom.html'},
  30 + name="password_reset"),
26 31  
27   - url(r'^password-reset-confirm/(?P<uidb64>[0-9A-Za-z]+)-(?P<token>.+)/$',
28   - auth_views.password_reset_confirm,
29   - {'template_name':'registration/password_reset_confirm_custom.html'},
30   - name="password_reset_confirm"),
  32 + url(r'^change-password/?$',auth_views.password_change,
  33 + {'template_name':'registration/password_change_form_custom.html'},
  34 + name='password_change'),
31 35  
32   - url(r'^password-reset/?$', auth_views.password_reset,
33   - {'template_name':'registration/password_reset_form_custom.html'},
34   - name="password_reset"),
35   -
36   - url(r'^change-password/?$',auth_views.password_change,
37   - {'template_name':'registration/password_change_form_custom.html'},
38   - name='password_change'),
39   -
40   - url(r'^change-password-done/?$',
41   - 'colab.accounts.views.password_changed', name='password_change_done'),
42   - )
43   -else:
44   - urlpatterns = patterns('',
45   - url(r'^login/?$', LoginView.as_view(), name='login'),
46   - )
  36 + url(r'^change-password-done/?$',
  37 + 'colab.accounts.views.password_changed', name='password_change_done'),
  38 +)
47 39  
48 40 urlpatterns += patterns('',
49 41 url(r'^register/?$', 'colab.accounts.views.signup', name='signup'),
... ...
colab/accounts/views.py
... ... @@ -23,10 +23,6 @@ from .forms import (UserCreationForm, UserForm, ListsForm,
23 23 from .utils import mailman
24 24  
25 25  
26   -class LoginView(TemplateView):
27   - template_name = "accounts/login.html"
28   -
29   -
30 26 class UserProfileBaseMixin(object):
31 27 model = get_user_model()
32 28 slug_field = 'username'
... ... @@ -86,37 +82,19 @@ class UserProfileDetailView(UserProfileBaseMixin, DetailView):
86 82  
87 83  
88 84 def signup(request):
89   - BROWSERID_ENABLED = getattr(settings, 'BROWSERID_ENABLED', False)
90   -
91   - if BROWSERID_ENABLED:
92   - # If the user is not authenticated, redirect to login
93   - if not request.user.is_authenticated():
94   - return redirect('login')
95 85  
96 86 if request.user.is_authenticated():
97   - # If the user doesn't need to update its main data,
98   - # redirect to its profile
99   - # It happens when user is created by browserid
100   - # and didn't set his/her main data
101 87 if not request.user.needs_update:
102 88 return redirect('user_profile', username=request.user.username)
103 89  
104   - # If the user is authenticated in Persona, but not in the Colab then he
105   - # will be redirected to the register form.
106 90 if request.method == 'GET':
107   - if BROWSERID_ENABLED:
108   - user_form = UserForm()
109   - else:
110   - user_form = UserCreationForm()
  91 + user_form = UserCreationForm()
111 92 lists_form = ListsForm()
112 93  
113 94 return render(request, 'accounts/user_create_form.html',
114 95 {'user_form': user_form, 'lists_form': lists_form})
115 96  
116   - if BROWSERID_ENABLED:
117   - user_form = UserForm(request.POST, instance=request.user)
118   - else:
119   - user_form = UserCreationForm(request.POST)
  97 + user_form = UserCreationForm(request.POST)
120 98 lists_form = ListsForm(request.POST)
121 99  
122 100 if not user_form.is_valid() or not lists_form.is_valid():
... ... @@ -126,12 +104,9 @@ def signup(request):
126 104 user = user_form.save(commit=False)
127 105 user.needs_update = False
128 106  
129   - if not BROWSERID_ENABLED:
130   - user.is_active = False
131   - user.save()
132   - EmailAddressValidation.create(user.email, user)
133   - else:
134   - user.save()
  107 + user.is_active = False
  108 + user.save()
  109 + EmailAddressValidation.create(user.email, user)
135 110  
136 111 # Check if the user's email have been used previously
137 112 # in the mainling lists to link the user to old messages
... ...
colab/home/context_processors.py
... ... @@ -26,6 +26,3 @@ def ribbon(request):
26 26 }
27 27 }
28 28  
29   -
30   -def browserid_enabled(request):
31   - return {'BROWSERID_ENABLED': getattr(settings, 'BROWSERID_ENABLED', False)}
... ...
colab/management/initconfig.py
... ... @@ -21,15 +21,6 @@ EMAIL_SUBJECT_PREFIX = &#39;[colab]&#39;
21 21  
22 22 SECRET_KEY = '{secret_key}'
23 23  
24   -# Must use it without trailing slash
25   -SITE_URL = 'http://localhost:8000'
26   -BROWSERID_AUDIENCES = [
27   - 'http://localhost:8000',
28   -# 'http://example.com',
29   -# 'https://example.org',
30   -# 'http://example.net',
31   -]
32   -
33 24 ALLOWED_HOSTS = [
34 25 'localhost',
35 26 # 'example.com',
... ... @@ -37,9 +28,6 @@ ALLOWED_HOSTS = [
37 28 # 'example.net',
38 29 ]
39 30  
40   -### Uncomment to enable Broswer ID protocol for authentication
41   -# BROWSERID_ENABLED = True
42   -
43 31 ### Uncomment to enable social networks fields profile
44 32 # SOCIAL_NETWORK_ENABLED = True
45 33  
... ...
colab/settings.py
... ... @@ -44,7 +44,6 @@ INSTALLED_APPS = (
44 44 # Not standard apps
45 45 'cliauth',
46 46 'django_mobile',
47   - 'django_browserid',
48 47 'haystack',
49 48 'hitcounter',
50 49 'i18n_model',
... ... @@ -196,7 +195,6 @@ TEMPLATE_CONTEXT_PROCESSORS = (
196 195 'colab.home.context_processors.robots',
197 196 'colab.home.context_processors.ribbon',
198 197 'colab.home.context_processors.google_analytics',
199   - 'colab.home.context_processors.browserid_enabled',
200 198 )
201 199  
202 200 MIDDLEWARE_CLASSES = (
... ... @@ -211,13 +209,10 @@ MIDDLEWARE_CLASSES = (
211 209 'django_mobile.middleware.MobileDetectionMiddleware',
212 210 'django_mobile.middleware.SetFlavourMiddleware',
213 211 'colab.tz.middleware.TimezoneMiddleware',
214   - 'colab.accounts.middleware.UserRegisterMiddleware',
215 212 )
216 213  
217   -# Add the django_browserid authentication backend.
218 214 AUTHENTICATION_BACKENDS = (
219 215 'django.contrib.auth.backends.ModelBackend',
220   - 'colab.accounts.auth.ColabBrowserIDBackend',
221 216 )
222 217  
223 218 LOCALE_PATHS = (
... ... @@ -245,16 +240,10 @@ SUPER_ARCHIVES_LOCK_FILE = &#39;/var/lock/colab/import_emails.lock&#39;
245 240 # Mailman API settings
246 241 MAILMAN_API_URL = 'http://localhost:8124'
247 242  
248   -# BrowserID / Persona
249   -SITE_URL = 'http://localhost:8000'
250   -BROWSERID_AUDIENCES = [SITE_URL, SITE_URL.replace('https', 'http')]
251   -
252   -
253 243 LOGIN_URL = '/user/login'
254 244 LOGIN_REDIRECT_URL = '/'
255 245 LOGIN_REDIRECT_URL_FAILURE = '/?bid_login_failed=true'
256 246 LOGOUT_REDIRECT_URL = '/'
257   -BROWSERID_CREATE_USER = True
258 247  
259 248 REVPROXY_ADD_REMOTE_USER = True
260 249  
... ... @@ -269,7 +258,6 @@ if locals().get(&#39;RAVEN_DSN&#39;, False):
269 258 }
270 259 INSTALLED_APPS += ('raven.contrib.django.raven_compat',)
271 260  
272   -BROWSERID_ENABLED = locals().get('BROWSERID_ENABLED') or False
273 261 SOCIAL_NETWORK_ENABLED = locals().get('SOCIAL_NETWORK_ENABLED') or False
274 262  
275 263 locals().update(load_colab_apps())
... ...
colab/templates/base.html
1 1 <!DOCTYPE html>
2   -{% load i18n browserid gravatar plugins %}
  2 +{% load i18n gravatar plugins %}
3 3 {% load static from staticfiles %}
4 4  
5 5 <html>
... ... @@ -50,10 +50,7 @@
50 50 </head>
51 51  
52 52 <!-- data-no-turbolink will disable Rails TurboLinks for all pages under Colab -->
53   - <body data-no-turbolink>
54   - {% if BROWSERID_ENABLED %}
55   - {% browserid_info %}
56   - {% endif %}
  53 + <body class="container" data-no-turbolink>
57 54  
58 55 {% block ribbon %}
59 56 {% if ribbon %}
... ... @@ -66,8 +63,82 @@
66 63 {% endblock %}
67 64  
68 65 {% block navbar %}
69   -
70   - {% include "header.html" %}
  66 + <nav class="navbar navbar-default navbar-fixed-top" role="navigation">
  67 + <div class="container">
  68 + <div class="navbar-header">
  69 +
  70 + <button type="button" class="navbar-toggle" data-toggle="collapse" data-target=".navbar-main">
  71 + <span class="sr-only">Toggle navigation</span>
  72 + <span class="icon-bar"></span>
  73 + <span class="icon-bar"></span>
  74 + <span class="icon-bar"></span>
  75 + <span class="icon-bar"></span>
  76 + </button>
  77 + <a class="navbar-brand" href="/"><img alt="Colab" src="{% static 'img/logo.svg' %}"></a>
  78 + </div>
  79 + <div class="collapse navbar-collapse navbar-main">
  80 + <ul class="nav navbar-nav">
  81 +
  82 + <li>
  83 + <a href="{% url 'thread_list' %}">{% trans "Groups" %}</a>
  84 + </li>
  85 +
  86 + {% plugins_menu %}
  87 +
  88 + <li class="hidden-lg hidden-md">
  89 + <a href="{% url 'haystack_search' %}?q=">{% trans "Search" %}</a>
  90 + </li>
  91 + </ul>
  92 +
  93 + <ul class="nav navbar-nav navbar-right">
  94 + {% if not user.is_authenticated %}
  95 +
  96 + <li class="dropdown hidden-xs hidden-lg">
  97 + <a href="#" class="dropdown-toggle" data-toggle="dropdown">Acesso <b class="caret"></b></a>
  98 + <ul class="dropdown-menu">
  99 + {% trans 'Login' as login_text %}
  100 + <li><a href="{% url 'signup' %}">{% trans "Register" %}</a></li>
  101 + <li><a href="{% url 'login' %}">{% trans "Login" %}</a></li>
  102 + </ul>
  103 + </li>
  104 + {% trans 'Login' as login_text %}
  105 + <li class="visible-xs hidden-sm hidden-md"><a href="{% url 'signup' %}">{% trans "Register" %}</a></li>
  106 + <li class="visible-xs hidden-sm hidden-md"><a href="{% url 'login' %}">{% trans "Login" %}</a></li>
  107 + {% else %}
  108 + <li id="user-menu" class="dropdown">
  109 + <a href="#" class="dropdown-toggle user" data-toggle="dropdown">{% gravatar user.email 40 %} <b class="caret"></b>&nbsp;&nbsp;</a>
  110 + <ul class="dropdown-menu" role="menu">
  111 + <li>
  112 + <div class="wrapper">
  113 + <div class="thumbnail">{% gravatar user.email 100 %}</div>
  114 + <div class="user-info">
  115 + <span><b>{{ user.get_full_name }}</b></span>
  116 + <span class="quiet">{{ user.email }}</span>
  117 + </div>
  118 + <div>
  119 + <a class="btn btn-info pull-left" href="{% url 'user_profile' user.username %}">{% trans "My Profile" %}</a>
  120 + {% trans 'Logout' as logout_text %}
  121 + <a class="btn btn-default pull-right" href="{% url 'logout' %}"> {% trans "Logout" %}</a>
  122 + </div>
  123 + </div>
  124 + </li>
  125 + </ul>
  126 + </li>
  127 + {% endif %}
  128 + </ul>
  129 +
  130 + <form action="{% url 'haystack_search' %}" method="GET" id="search-form" class="navbar-form navbar-right hidden-xs hidden-sm" role="search">
  131 + <div class="form-group">
  132 + <label class="sr-only" for="header-searchbox">{% trans 'Search here...' %}</label>
  133 + <input name="q" id="header-searchbox"
  134 + class="form-control" value="{{ request.GET.q }}"
  135 + type="search" placeholder="{% trans 'Search here...' %}" />
  136 + </div>
  137 + <button type="submit" class="btn btn-default"><span class="glyphicon glyphicon-search"></span></button>
  138 + </form>
  139 + </div>
  140 + </div>
  141 + </nav>
71 142  
72 143 {% endblock %}
73 144  
... ... @@ -105,12 +176,6 @@
105 176  
106 177 {% include "tz/set_utc_offset.html" %}
107 178  
108   - {% if BROWSERID_ENABLED %}
109   - <script src="https://login.persona.org/include.js"></script>
110   - <script src="{% static 'browserid/api.js' %}"></script>
111   - <script src="{% static 'browserid/browserid.js' %}"></script>
112   - {% endif %}
113   -
114 179 {% block footer_js %}{% endblock %}
115 180 </body>
116 181 </html>
... ...
colab/urls.py
... ... @@ -30,8 +30,6 @@ urlpatterns = patterns(&#39;&#39;,
30 30 url(r'^myaccount/(?P<route>.*)$',
31 31 'colab.accounts.views.myaccount_redirect', name='myaccount'),
32 32  
33   - url(r'', include('django_browserid.urls')),
34   -
35 33 # Uncomment the next line to enable the admin:
36 34 url(r'^colab/admin/', include(admin.site.urls)),
37 35  
... ...
docs/source/user.rst
... ... @@ -139,31 +139,6 @@ Social Networks
139 139 When this variable is True, the social networks fields, like Facebook and
140 140 Twitter, are added in user profile. By default, this fields are disabled.
141 141  
142   -Auth
143   -++++
144   -.. attribute:: BROWSERID_ENABLED
145   -
146   - :default: False
147   -
148   - When this variable is True, Colab use BrowserID authentication. By default,
149   - django authentication system is used.
150   -
151   -.. attribute:: BROWSERID_AUDIENCES
152   -
153   - :default: No default
154   -
155   - List of audiences that your site accepts. An audience is the protocol,
156   - domain name, and (optionally) port that users access your site from. This
157   - list is used to determine the audience a user is part of (how they are
158   - accessing your site), which is used during verification to ensure that the
159   - assertion given to you by the user was intended for your site.
160   -
161   - Without this, other sites that the user has authenticated with via Persona
162   - could use their assertions to impersonate the user on your site.
163   -
164   - Note that this does not have to be a publicly accessible URL, so local URLs
165   - like ``http://localhost:8000`` or ``http://127.0.0.1`` are acceptable as
166   - long as they match what you are using to access your site.
167 142  
168 143 Customization
169 144 -------------
... ...
setup.py
... ... @@ -29,8 +29,6 @@ REQUIREMENTS = [
29 29 'raven==3.5.2',
30 30 'tornado==3.1.1',
31 31  
32   - # Deps for Single SignOn (SSO) - Replaced with django-browserid==0.9
33   - 'django-browserid==0.11',
34 32 'django-revproxy==0.9.0',
35 33  
36 34 # Feedzilla (planet) and deps
... ...