def force_fresh_session(view):
@wraps(view)<EOL>def wrapper(request, *args, **kwargs):<EOL><INDENT>"""<STR_LIT>"""<EOL>if not request.GET.get(FRESH_LOGIN_PARAMETER):<EOL><INDENT>enterprise_customer = get_enterprise_customer_or_404(kwargs.get('<STR_LIT>'))<EOL>provider_id = enterprise_customer.identity_provider or '<STR_LIT>'<EOL>sso_provider = get_identity_provider(provider_id)<EOL>if sso_provider:<EOL><INDENT>scheme, netloc, path, params, query, fragment = urlparse(request.get_full_path())<EOL>redirect_url = urlunparse((scheme, netloc, quote(path), params, query, fragment))<EOL>return redirect(<EOL>'<STR_LIT>'.format(<EOL>logout_url='<STR_LIT>',<EOL>params=urlencode(<EOL>{'<STR_LIT>': redirect_url}<EOL>)<EOL>)<EOL>)<EOL><DEDENT><DEDENT>return view(request, *args, **kwargs)<EOL><DEDENT>return wrapper<EOL>
View decorator which terminates stale TPA sessions.

This decorator forces the user to obtain a new session
the first time they access the decorated view. This prevents
TPA-authenticated users from hijacking the session of another
user who may have been previously logged in using the same
browser window.

This decorator should be used in conjunction with the
enterprise_login_required decorator.

Usage::
    @enterprise_login_required
    @force_fresh_session()
    def my_view(request, enterprise_uuid):
        # Some functionality ...

    OR

    class MyView(View):
        ...
        @method_decorator(enterprise_login_required)
        @method_decorator(force_fresh_session)
        def get(self, request, enterprise_uuid):
            # Some functionality ...