+INVALID_TICKET = 'INVALID_TICKET'
+INVALID_SERVICE = 'INVALID_SERVICE'
+INVALID_REQUEST = 'INVALID_REQUEST'
+INTERNAL_ERROR = 'INTERNAL_ERROR'
+
+ERROR_MESSAGES = (
+ (INVALID_TICKET, u'The provided ticket is invalid.'),
+ (INVALID_SERVICE, u'Service is invalid'),
+ (INVALID_REQUEST, u'Not all required parameters were sent.'),
+ (INTERNAL_ERROR, u'An internal error occurred during ticket validation'),
+ )
+
+
+logger = logging.getLogger(__name__)
+
+
+_never_cache = cache_control(no_cache=True, must_revalidate=True)
+
+
+def never_cache(view_func):
+ """
+ Decorator that adds headers to a response so that it will
+ never be cached.
+ """
+ @wraps(view_func, assigned=available_attrs(view_func))
+ def _wrapped_view_func(request, *args, **kwargs):
+ response = view_func(request, *args, **kwargs)
+ patch_cache_control(response, no_cache=True,
+ must_revalidate=True, proxy_revalidate=True)
+ response['Pragma'] = 'no-cache'
+ return response
+ return _wrapped_view_func
+
+
+@sensitive_post_parameters()
+@csrf_protect
+@never_cache
+def login(request, template_name='cas/login.html',
+ success_redirect=settings.LOGIN_REDIRECT_URL,
+ warn_template_name='cas/warn.html', **kwargs):
+ merge = kwargs.get('merge', False)
+ logging.debug('CAS Provider Login view. Method is %s, merge is %s, template is %s.',
+ request.method, merge, template_name)