def create_cookie_dealer(self): conf = { "issuer": "https://example.com/", "password": "******", "token_expires_in": 600, "grant_expires_in": 300, "refresh_token_expires_in": 86400, "verify_ssl": False, "endpoint": {}, "authentication": [{ 'acr': INTERNETPROTOCOLPASSWORD, 'name': 'NoAuthn', 'kwargs': { 'user': '******' } }], 'template_dir': 'template' } endpoint_context = EndpointContext(conf, keyjar=KEYJAR) self.cookie_dealer = CookieDealer(endpoint_context, 'kaka', 'https://example.com', 'op')
class TestCookieDealer(object): @pytest.fixture(autouse=True) def create_cookie_dealer(self): conf = { "issuer": "https://example.com/", "password": "******", "token_expires_in": 600, "grant_expires_in": 300, "refresh_token_expires_in": 86400, "verify_ssl": False, "endpoint": {}, "authentication": [{ 'acr': INTERNETPROTOCOLPASSWORD, 'name': 'NoAuthn', 'kwargs': { 'user': '******' } }], 'template_dir': 'template' } endpoint_context = EndpointContext(conf, keyjar=KEYJAR) self.cookie_dealer = CookieDealer(endpoint_context, 'kaka', 'https://example.com', 'op') def test_init(self): assert self.cookie_dealer def test_create_cookie(self): _cookie = self.cookie_dealer.create_cookie('value', 'sso') assert _cookie def test_read_created_cookie(self): _cookie = self.cookie_dealer.create_cookie('value', 'sso') _value = self.cookie_dealer.get_cookie_value(_cookie[1]) assert len(_value) == 3 assert _value[0] == 'value' assert _value[2] == 'sso' def test_delete_cookie(self): _cookie = self.cookie_dealer.delete_cookie('openid') assert 'expires=' in _cookie[1] _value = self.cookie_dealer.get_cookie_value(_cookie[1], 'openid') assert _value[0] == '' assert _value[2] == ''
def init_oidc_op_endpoints(app): _config = app.config.get('CONFIG') _server_info_config = _config['server_info'] for path,val in app.config.get('PATH').items(): pos = _server_info_config part = path.split(':') for p in part[:-1]: try: pos = pos[p] except TypeError: p = int(p) pos = pos[p] pos[part[-1]] = val.format(folder) _jwks_def = _server_info_config['jwks'] _jwks_def['public_path'] = _jwks_def['public_path'].format(folder) _jwks_def['private_path'] = _jwks_def['private_path'].format(folder) _kj = init_key_jar(iss=_server_info_config['issuer'], **_jwks_def) # _jwks = _kj.export_jwks_as_json(True, '') # _kj.import_jwks_as_json(_jwks, ) cookie_dealer = CookieDealer(**_server_info_config['cookie_dealer']) endpoint_context = EndpointContext(_server_info_config, keyjar=_kj, cwd=folder, cookie_dealer=cookie_dealer) cookie_dealer.endpoint_context = endpoint_context for endp in endpoint_context.endpoint.values(): p = urlparse(endp.endpoint_path) _vpath = p.path.split('/') if _vpath[0] == '': endp.vpath = _vpath[1:] else: endp.vpath = _vpath return endpoint_context
'log.screen': True, 'cors.expose_public.on': True } } _server_info_config = config.CONFIG['server_info'] _jwks_config = _server_info_config['jwks'] _kj = init_key_jar(owner=_server_info_config['issuer'], **_jwks_config) if args.insecure: verify_ssl = False else: verify_ssl = True cookie_dealer = CookieDealer(**_server_info_config['cookie_dealer']) endpoint_context = EndpointContext(_server_info_config, keyjar=_kj, cwd=folder, httpcli=requests.request, verify_ssl=verify_ssl, cookie_dealer=cookie_dealer) for endp in endpoint_context.endpoint.values(): p = urlparse(endp.endpoint_path) _vpath = p.path.split('/') if _vpath[0] == '': endp.vpath = _vpath[1:] else: endp.vpath = _vpath
'tools.staticdir.content_types': { 'json': 'application/json', 'jwks': 'application/json', 'jose': 'application/jose' }, 'log.screen': True, 'cors.expose_public.on': True } } _server_info_config = config.CONFIG['server_info'] _jwks_config = _server_info_config['jwks'] _kj = init_key_jar(iss=_server_info_config['issuer'], **_jwks_config) cookie_dealer = CookieDealer(**_server_info_config['cookie_dealer']) endpoint_context = EndpointContext(config.CONFIG['server_info'], keyjar=_kj, cwd=folder, cookie_dealer=cookie_dealer) cookie_dealer.endpoint_context = endpoint_context for endp in endpoint_context.endpoint.values(): p = urlparse(endp.endpoint_path) _vpath = p.path.split('/') if _vpath[0] == '': endp.vpath = _vpath[1:] else: endp.vpath = _vpath