Beispiel #1
0
def login():
    """
    Endpoint which frontend should call when wanting to perform a login.

    :return:
    """
    auth = get_saml_auth(request)
    redirect_url = quote(request.args.get('relay', '/'))
    return redirect(auth.login(redirect_url))
Beispiel #2
0
def saml_metadata():
    """
    Optional. Prints out the public saml metadata for the service.

    :return:
    """
    auth = get_saml_auth(request)
    settings = auth.get_settings()
    metadata = settings.get_sp_metadata()
    errors = settings.validate_metadata(metadata)

    if len(errors) == 0:
        resp = make_response(metadata, 200)
        resp.headers['Content-Type'] = 'text/xml'
    else:
        resp = make_response(', '.join(errors), 500)
    return resp
Beispiel #3
0
def saml_single_logout_service():
    """
    The endpoint which is used by the saml library on auth.logout call

    :return:
    """
    auth = get_saml_auth(request)
    slo_success = False
    url = auth.process_slo(delete_session_cb=lambda: session.clear())
    errors = auth.get_errors()
    if len(errors) == 0:
        if url is not None:
            return redirect(url)
        else:
            slo_success = True

    return _render_index_template(saml_errors=errors, slo_success=slo_success)
Beispiel #4
0
def logout():
    """
    Endpoint which frontend should call when wanting to perform a logout.

    Currently not working since Fairdata authentication service does not support SLO.

    :return:
    """
    auth = get_saml_auth(request)
    name_id = None
    session_index = None
    if 'samlNameId' in session:
        name_id = session['samlNameId']
    if 'samlSessionIndex' in session:
        session_index = session['samlSessionIndex']

    return redirect(auth.logout(name_id=name_id, session_index=session_index))
Beispiel #5
0
def logout():
    """
    Endpoint which frontend should call when wanting to perform a logout.

    Currently not working since Fairdata authentication service does not support SLO.

    :return:
    """
    auth = get_saml_auth(request)
    name_id = None
    session_index = None
    if 'samlNameId' in session:
        name_id = session['samlNameId']
    if 'samlSessionIndex' in session:
        session_index = session['samlSessionIndex']
    log.debug("LOGOUT request to /slo")
    # Clear the flask session here because the idp doesnt seem to call the sls route.
    session.clear()
    return redirect(auth.logout(name_id=name_id, session_index=session_index))