Ejemplo n.º 1
0
    def create_client(self):
        dataset = DictDBWrap(USERDB)
        dataset.register_scope('https://dirg.org.umu.se/uma/read', 'get')

        resource_owner = 'linda'

        self.srv = ResourceServer(dataset, resource_owner)
        # map client API operation (HTTP GET) to scope
        self.srv.rs_handler.op2scope = {
            'GET': 'https://dirg.org.umu.se/uma/read'
        }
Ejemplo n.º 2
0
class TestResourceSetSrv(object):
    @pytest.fixture(autouse=True)
    def create_client(self):
        dataset = DictDBWrap(USERDB)
        dataset.register_scope('https://dirg.org.umu.se/uma/read', 'get')

        resource_owner = 'linda'

        self.srv = ResourceServer(dataset, resource_owner)
        # map client API operation (HTTP GET) to scope
        self.srv.rs_handler.op2scope = {
            'GET': 'https://dirg.org.umu.se/uma/read'
        }

    def test_create_permission_request(self):
        self.srv.rs_handler.register_init()

        # Fake the result of a registration, I skip the resource_set_desc part
        self.srv.rs_handler.rsd_map['linda:sn:Lindgren'] = {'_id': '12345679'}

        prrs = self.srv.create_permission_request('GET', 'linda', 'attr=sn')

        # The needed permissions
        assert prrs == [{
            'scopes': ['https://dirg.org.umu.se/uma/read'],
            'resource_set_id': '12345679'
        }]
Ejemplo n.º 3
0
def main(base_url, cookie_handler):
    config = {
        "registration_info": {
            "token_endpoint_auth_method": "client_secret_basic",
            "application_type": "web",
            "redirect_uris": ["%s/uma" % base_url],
            "grant_types": ["authorization_code", "implicit"],
            "scope": [PAT],
            "response_types": ["code", "token"]
        },
        "client_authn_method": {
            "client_secret_basic": ClientSecretBasic,
            "bearer_header": BearerHeader
        },
        "flow_type": "code",
        "symkey": "abcdefghijklmnop",
        "baseurl": base_url,
        "scope": PAT
    }

    dataset = RESTIDMWrap(USERDB, baseurl=config["baseurl"])
    res_srv = ResourceServer(dataset, 'alice', {}, **config)

    jwks = keyjar_init(res_srv, KEYS, "a%d")

    fp = open("static/jwk_rs.json", "w")
    fp.write(json.dumps(jwks))
    fp.close()

    cookie_handler.init_srv(res_srv)

    return res_srv
Ejemplo n.º 4
0
    def create_client(self):
        dataset = DictDBWrap(USERDB)
        dataset.register_scope('https://dirg.org.umu.se/uma/read', 'get')

        resource_owner = 'linda'

        self.srv = ResourceServer(dataset, resource_owner)
        # map client API operation (HTTP GET) to scope
        self.srv.rs_handler.op2scope = {
            'GET': 'https://dirg.org.umu.se/uma/read'}
Ejemplo n.º 5
0
class TestResourceSetSrv(object):
    @pytest.fixture(autouse=True)
    def create_client(self):
        dataset = DictDBWrap(USERDB)
        dataset.register_scope('https://dirg.org.umu.se/uma/read', 'get')

        resource_owner = 'linda'

        self.srv = ResourceServer(dataset, resource_owner)
        # map client API operation (HTTP GET) to scope
        self.srv.rs_handler.op2scope = {
            'GET': 'https://dirg.org.umu.se/uma/read'}

    def test_create_permission_request(self):
        self.srv.rs_handler.register_init()

        # Fake the result of a registration, I skip the resource_set_desc part
        self.srv.rs_handler.rsd_map['linda:sn:Lindgren'] = {'_id': '12345679'}

        prrs = self.srv.create_permission_request('GET', 'linda', 'attr=sn')

        # The needed permissions
        assert prrs == [{'scopes': ['https://dirg.org.umu.se/uma/read'],
                         'resource_set_id': '12345679'}]