示例#1
0
文件: routes.py 项目: bjorns/mock-idp
def authenticate():
    username = flask.request.form.get('username')
    password = flask.request.form.get('password')

    status, user = login_user(conf, username, password)
    if status == LOGIN_SUCCESS:
        saml_req_id = flask.request.cookies.get('mockidp_request_id')
        if saml_req_id not in open_saml_requests:
            return '404: Missing login session', 404
        saml_request = open_saml_requests[saml_req_id]
        session = get_session(user, saml_request)
        url, saml_response = create_auth_response(conf, session)
        return flask.render_template('auth_response.html', post_url=url, saml_response=saml_response)
    else:
        flask.flash(f"Incorrect username or password {username}")
        return flask.redirect("/saml/login", code=302)
示例#2
0
def test_incorrect_password():
    status, user = login_user(config, 'charlie', 'wrongpassword')
    eq_(LOGIN_FAIL, status)
    eq_(None, user)
示例#3
0
def test_non_existing_user():
    status, user = login_user(config, 'penelope', 'anypassword')
    eq_(LOGIN_FAIL, status)
    eq_(None, user)
示例#4
0
def test_successful_login():
    status, user = login_user(config, 'charlie', 'secret')
    eq_(LOGIN_SUCCESS, status)
    eq_('charlie brown', user['name'])