Skip to content

Instantly share code, notes, and snippets.

@danizen
Last active August 27, 2018 20:19
Show Gist options
  • Save danizen/ec280ea856fa057137a82bbb9e8584d0 to your computer and use it in GitHub Desktop.
Save danizen/ec280ea856fa057137a82bbb9e8584d0 to your computer and use it in GitHub Desktop.
Django template for authentication
{% if user.is_authenticated %}
{# ... other menu options ... #}
<li class="dropdown">
<a class="dropdown-toggle" data-toggle="dropdown" role="button" aria-haspop="true" aria-expanded="false">
<i class="fa fa-user"></i> {{ user.nih_login_id }}
</a>
<ul class="dropdown-menu">
<li role="menuitem">
<a href="{% url 'casauth:profile' %}"><i class="fa fa-user"></i> Profile</a>
</li>
<li role="menuitem">
<a href="{% url 'casauth:logout' %}"><i class="fa fa-sign-out" aria-hidden="true"></i> Logout</a>
</li>
</ul>
</li>
{% else %}
<li role="menuitem"><a href="{% url 'casauth:login' %}"><i class="fa fa-sign-in" aria-hidden="true"></i> Login</a></li>
{% endif %}
urlpatterns = [
url(r'^accounts/', include('nlm.occs.casauth.urls')),
# ...
AUTHENTICATION_BACKENDS = (
'nlm.occs.casauth.backends.CASBackend',
)
CAS_SERVER_URL = 'https://login-prod.nlm.nih.gov/cas/'
CAS_CREATE_USER = False
CAS_STORE_NEXT = True
CAS_IGNORE_REFERRER = True
CAS_FORCE_CHANGE_USERNAME_CASE = 'lower'
ADMIN_GROUP = 'admin'
# Custom user model matching existing serials user table
# AUTH_USER_MODEL = '<appname>.<ModelName>'
CSRF_COOKIE_HTTPONLY = True
CSRF_COOKIE_SECURE = True
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment