Beispiel #1
0
def test_initialize_providers_unique():
    app = Flask("test")
    app.config["MULTIPASS_AUTH_PROVIDERS"] = {
        "test": {"type": "unique", "foo": "bar"},
        "test2": {"type": "unique", "hello": "world"},
    }
    multipass = Multipass()
    multipass.register_provider(FooProvider, "foo")
    multipass.register_provider(UniqueProvider, "unique")
    with pytest.raises(RuntimeError):
        multipass.init_app(app)
Beispiel #2
0
def test_initialize_providers_unique():
    app = Flask('test')
    app.config['MULTIPASS_AUTH_PROVIDERS'] = {
        'test': {'type': 'unique', 'foo': 'bar'},
        'test2': {'type': 'unique', 'hello': 'world'},
    }
    multipass = Multipass()
    multipass.register_provider(FooProvider, 'foo')
    multipass.register_provider(UniqueProvider, 'unique')
    with pytest.raises(RuntimeError):
        multipass.init_app(app)
Beispiel #3
0
def test_initialize_providers_unique():
    app = Flask('test')
    app.config['MULTIPASS_AUTH_PROVIDERS'] = {
        'test': {'type': 'unique', 'foo': 'bar'},
        'test2': {'type': 'unique', 'hello': 'world'},
    }
    multipass = Multipass()
    multipass.register_provider(FooProvider, 'foo')
    multipass.register_provider(UniqueProvider, 'unique')
    with pytest.raises(RuntimeError):
        multipass.init_app(app)
Beispiel #4
0
def test_initialize_providers():
    app = Flask("test")
    app.config["MULTIPASS_AUTH_PROVIDERS"] = {
        "test": {"type": "foo", "foo": "bar"},
        "test2": {"type": "unique", "hello": "world"},
    }
    multipass = Multipass()
    multipass.register_provider(FooProvider, "foo")
    multipass.register_provider(UniqueProvider, "unique")
    with app.app_context():
        auth_providers = multipass._create_providers("AUTH", AuthProvider)
        assert auth_providers["test"].settings == {"foo": "bar"}
        assert auth_providers["test2"].settings == {"hello": "world"}
Beispiel #5
0
def test_initialize_providers():
    app = Flask('test')
    app.config['MULTIPASS_AUTH_PROVIDERS'] = {
        'test': {'type': 'foo', 'foo': 'bar'},
        'test2': {'type': 'unique', 'hello': 'world'},
    }
    multipass = Multipass()
    multipass.register_provider(FooProvider, 'foo')
    multipass.register_provider(UniqueProvider, 'unique')
    with app.app_context():
        auth_providers = multipass._create_providers('AUTH', AuthProvider)
        assert auth_providers['test'].settings == {'foo': 'bar'}
        assert auth_providers['test2'].settings == {'hello': 'world'}
Beispiel #6
0
def test_initialize_providers():
    app = Flask('test')
    app.config['MULTIPASS_AUTH_PROVIDERS'] = {
        'test': {'type': 'foo', 'foo': 'bar'},
        'test2': {'type': 'unique', 'hello': 'world'},
    }
    multipass = Multipass()
    multipass.register_provider(FooProvider, 'foo')
    multipass.register_provider(UniqueProvider, 'unique')
    with app.app_context():
        auth_providers = multipass._create_providers('AUTH', AuthProvider)
        assert auth_providers['test'].settings == {'foo': 'bar'}
        assert auth_providers['test2'].settings == {'hello': 'world'}
Beispiel #7
0
def refresh():
    if not g.user:
        flash('Not logged in', 'error')
        return redirect(url_for('index'))
    for identity in g.user.identities:
        if json.loads(identity.multipass_data) is None:
            continue
        identity_info = multipass.refresh_identity(identity.identifier, json.loads(identity.multipass_data))
        identity.multipass_data = json.dumps(identity_info.multipass_data)
        flash('Refreshed IdentityInfo: {}'.format(identity_info), 'success')
    db.session.commit()
    return redirect(url_for('index'))


app.config.from_pyfile('example.cfg')
multipass.register_provider(LocalAuthProvider, 'example_local')
multipass.register_provider(LocalIdentityProvider, 'example_local')
multipass.init_app(app)
db.init_app(app)
with app.app_context():
    db.create_all()
    if not User.query.filter_by(name='Local Guinea Pig').count():
        user = User(name='Local Guinea Pig', email='*****@*****.**', affiliation='Local')
        identity = Identity(provider='local', identifier='Test', multipass_data='null', password='******')
        user.identities.append(identity)
        db.session.add(user)
        db.session.commit()


if __name__ == '__main__':
    app.run('0.0.0.0', 10500, use_evalex=False)
Beispiel #8
0
    if not g.user:
        flash('Not logged in', 'error')
        return redirect(url_for('index'))
    for identity in g.user.identities:
        if json.loads(identity.multipass_data) is None:
            continue
        identity_info = multipass.refresh_identity(
            identity.identifier, json.loads(identity.multipass_data))
        identity.multipass_data = json.dumps(identity_info.multipass_data)
        flash('Refreshed IdentityInfo: {}'.format(identity_info), 'success')
    db.session.commit()
    return redirect(url_for('index'))


app.config.from_pyfile('example.cfg')
multipass.register_provider(LocalAuthProvider, 'example_local')
multipass.register_provider(LocalIdentityProvider, 'example_local')
multipass.init_app(app)
db.init_app(app)
with app.app_context():
    db.create_all()
    if not User.query.filter_by(name='Local Guinea Pig').count():
        user = User(name='Local Guinea Pig',
                    email='*****@*****.**',
                    affiliation='Local')
        identity = Identity(provider='local',
                            identifier='Test',
                            multipass_data='null',
                            password='******')
        user.identities.append(identity)
        db.session.add(user)