Ejemplo n.º 1
0
def genericsso(request):
    '''Assertion consume service (acs) of pepper'''

    log.debug("===== genericsso: receiving a token =====")

    # Both POST and GET method are supported to get IDP name
    idp_name = request.REQUEST.get('idp', '')

    request.session['idp'] = idp_name

    if idp_name == '':
        raise Exception("error: No IDP name passed")
        # log.error("error: No IDP name passed")
        # raise Http404()

    metadata_setting = metadata.idp_by_name(idp_name)

    if metadata_setting is None:
        raise Exception("error: Unkonwn IDP")
        # log.error("error: Unkonwn IDP")
        # raise Http404()
    
    # Call different type of ACS seperatly
    if metadata_setting.get('sso_type') == 'SAML':
        log.debug("message: it's SAML")
        return saml_acs(request, idp_name, metadata_setting)
    elif metadata_setting.get('sso_type') == 'OAuth2':
        return oauth2_acs(request, idp_name, metadata_setting)
Ejemplo n.º 2
0
def register_sso(request, activation_key):
    '''Register page for not acitved sso auto created user.'''
    registration = Registration.objects.get(activation_key=activation_key)
    user_id = registration.user_id
    profile = UserProfile.objects.get(user_id=user_id)

    ms = metadata.idp_by_name(profile.sso_idp)
    attribute_setting = ms.get('attributes')

    attribute_mapping = {}
    for attr in attribute_setting:
        mapped_name = attr['map'] if attr['map'] else attr['name']
        attribute_mapping[mapped_name] = attr

    context = {
        'profile': profile,
        'activation_key': activation_key,
        'attribute_mapping': attribute_mapping
    }
    return render_to_response('register_sso.html', context)