Ejemplo n.º 1
0
    def get(self, request, *args, **kwargs):
        """
        (2.1) As a credential requestor, /login accepts three optional
        parameters:

        1. ``service``: the identifier of the application the client is
           accessing. We assume this identifier to be a URL.
        2. ``renew``: requires a client to present credentials
           regardless of any existing single sign-on session.
        3. ``gateway``: causes the client to not be prompted for
           credentials. If a single sign-on session exists the user
           will be logged in and forwarded to the specified service.
           Otherwise, the user remains logged out and is forwarded to
           the specified service.
        """

        service = request.GET.get('service')
        renew = to_bool(request.GET.get('renew'))
        gateway = to_bool(request.GET.get('gateway'))

        #if (service  and service.find("genomics")!= -1) :
        #    service=request.build_absolute_uri().split("service=")[1]
        if renew:
            logger.debug("Renew request received by credential requestor")

        elif gateway and service:
            logger.debug("Gateway request received by credential requestor")
            if is_authenticated(request.user):
                st = ServiceTicket.objects.create_ticket(service=service,
                                                         user=request.user)
                if self.warn_user():
                    return redirect('cas_warn',
                                    params={
                                        'service': service,
                                        'ticket': st.ticket
                                    })
                return redirect(service, params={'ticket': st.ticket})
            else:
                #ipdb.set_trace();
                return redirect(service)
        elif is_authenticated(request.user):
            if service:
                logger.debug(
                    "Service ticket request received by credential requestor")
                st = ServiceTicket.objects.create_ticket(service=service,
                                                         user=request.user)
                #ipdb.set_trace();
                if self.warn_user():
                    return redirect('cas_warn',
                                    params={
                                        'service': service,
                                        'ticket': st.ticket
                                    })
                return redirect(service, params={'ticket': st.ticket})
            else:
                msg = _("You are logged in as %s") % request.user
                messages.success(request, msg)
        return super(LoginView, self).get(request, *args, **kwargs)
Ejemplo n.º 2
0
def logout_user(request):
    """End a single sign-on session for the current user."""
    logger.debug("Logout request received for %s" % request.user)
    if is_authenticated(request.user):
        ServiceTicket.objects.consume_tickets(request.user)
        ProxyTicket.objects.consume_tickets(request.user)
        ProxyGrantingTicket.objects.consume_tickets(request.user)

        ServiceTicket.objects.request_sign_out(request.user)

        logger.info("Single sign-on session ended for %s" % request.user)
        logout(request)
        messages.success(request, _('Αποσυνδεθήκατε από την υπηρεσία Ermis-F'))
Ejemplo n.º 3
0
def logout_user(request):
    """End a single sign-on session for the current user."""
    logger.debug("Logout request received for %s" % request.user)
    if is_authenticated(request.user):
        ServiceTicket.objects.consume_tickets(request.user)
        ProxyTicket.objects.consume_tickets(request.user)
        ProxyGrantingTicket.objects.consume_tickets(request.user)

        ServiceTicket.objects.request_sign_out(request.user)

        logger.info("Single sign-on session ended for %s" % request.user)
        logout(request)
        messages.success(request, _('You have been successfully logged out'))
Ejemplo n.º 4
0
def logout_user(request):
    """End a single sign-on session for the current user."""
    logger.debug("Logout request received for %s" % request.user)
    if is_authenticated(request.user):
        ServiceTicket.objects.consume_tickets(request.user)
        ProxyTicket.objects.consume_tickets(request.user)
        ProxyGrantingTicket.objects.consume_tickets(request.user)

        ServiceTicket.objects.request_sign_out(request.user)

        logger.info("Single sign-on session ended for %s" % request.user)
        logout(request)
        messages.success(request, _('You have been successfully logged out'))
Ejemplo n.º 5
0
 def dispatch(self, request, *args, **kwargs):
     if not is_authenticated(request.user):
         return redirect('cas_login')
     return super(LoginRequiredMixin,
                  self).dispatch(request, *args, **kwargs)
Ejemplo n.º 6
0
 def dispatch(self, request, *args, **kwargs):
     if not is_authenticated(request.user):
         return redirect('cas_login')
     return super(LoginRequiredMixin, self).dispatch(request, *args, **kwargs)