def test_access_token_srv_conf():
    service = factory('AccessToken',
                      client_authn_method=CLIENT_AUTHN_METHOD,
                      conf={'default_authn_method': 'client_secret_post'})
    client_config = {
        'client_id': 'client_id',
        'client_secret': 'password',
        'redirect_uris': ['https://example.com/cli/authz_cb']
    }
    cli_info = ClientInfo(config=client_config)
    cli_info.state_db['state'] = {'code': 'access_code'}

    req_args = {
        'redirect_uri': 'https://example.com/cli/authz_cb',
        'code': 'access_code'
    }
    service.endpoint = 'https://example.com/authorize'
    _info = service.request_info(cli_info,
                                 request_args=req_args,
                                 state='state')

    assert _info
    msg = AccessTokenRequest().from_urlencoded(
        service.get_urlinfo(_info['body']))
    assert 'client_secret' in msg
    assert 'Authorization' not in _info['kwargs']['headers']
Example #2
0
def test_authz_service_conf():
    srv = factory('Authorization',
                  client_authn_method=CLIENT_AUTHN_METHOD,
                  conf={
                      'request_args': {
                          'claims': {
                              "id_token": {
                                  "auth_time": {
                                      "essential": True
                                  },
                                  "acr": {
                                      "values":
                                      ["urn:mace:incommon:iap:silver"]
                                  }
                              }
                          }
                      }
                  })
    client_config = {
        'client_id': 'client_id',
        'client_secret': 'password',
        'redirect_uris': ['https://example.com/cli/authz_cb'],
        'behaviour': {
            'response_types': ['code']
        }
    }
    cli_info = ClientInfo(keyjar, config=client_config)
    req = srv.construct(cli_info)
    assert 'claims' in req
    assert set(req['claims'].keys()) == {'id_token'}
 def create_service(self):
     self.service = factory('Authorization')
     client_config = {
         'client_id': 'client_id',
         'client_secret': 'password',
         'redirect_uris': ['https://example.com/cli/authz_cb']
     }
     self.cli_info = ClientInfo(config=client_config)
     self.cli_info.state_db['state'] = {}
Example #4
0
 def create_request(self):
     self.req = factory('Authorization',
                        client_authn_method=CLIENT_AUTHN_METHOD)
     client_config = {
         'client_id': 'client_id',
         'client_secret': 'password',
         'redirect_uris': ['https://example.com/cli/authz_cb']
     }
     self.cli_info = ClientInfo(keyjar, config=client_config)
 def create_service(self):
     self.service = factory('ProviderInfoDiscovery')
     self._iss = 'https://example.com/as'
     client_config = {
         'client_id': 'client_id',
         'client_secret': 'password',
         'redirect_uris': ['https://example.com/cli/authz_cb'],
         'issuer': self._iss
     }
     self.cli_info = ClientInfo(config=client_config)
 def create_service(self):
     self.service = factory('AccessToken',
                            client_authn_method=CLIENT_AUTHN_METHOD)
     client_config = {
         'client_id': 'client_id',
         'client_secret': 'password',
         'redirect_uris': ['https://example.com/cli/authz_cb']
     }
     self.cli_info = ClientInfo(config=client_config)
     self.cli_info.state_db['state'] = {'code': 'access_code'}
Example #7
0
 def create_request(self):
     self.req = factory('WebFinger',
                        client_authn_method=CLIENT_AUTHN_METHOD)
     client_config = {
         'redirect_uris': ['https://example.com/cli/authz_cb'],
         'requests_dir': 'requests',
         'base_url': 'https://example.com/cli/',
         'resource': '*****@*****.**'
     }
     self.cli_info = ClientInfo(config=client_config)
     self.cli_info.service = build_services(DEFAULT_SERVICES, factory, None,
                                            None, CLIENT_AUTHN_METHOD)
Example #8
0
 def create_request(self):
     self.req = factory('CheckID', client_authn_method=CLIENT_AUTHN_METHOD)
     self._iss = 'https://example.com/as'
     client_config = {
         'client_id': 'client_id',
         'client_secret': 'password',
         'redirect_uris': ['https://example.com/cli/authz_cb'],
         'issuer': self._iss,
         'requests_dir': 'requests',
         'base_url': 'https://example.com/cli/'
     }
     self.cli_info = ClientInfo(config=client_config)
     self.cli_info.service = build_services(DEFAULT_SERVICES, factory, None,
                                            None, CLIENT_AUTHN_METHOD)
 def create_service(self):
     self.service = factory('RefreshAccessToken',
                            client_authn_method=CLIENT_AUTHN_METHOD)
     self.service.endpoint = 'https://example.com/token'
     client_config = {
         'client_id': 'client_id',
         'client_secret': 'password',
         'redirect_uris': ['https://example.com/cli/authz_cb']
     }
     self.cli_info = ClientInfo(config=client_config)
     self.cli_info.state_db['abcdef'] = {'code': 'access_code'}
     self.cli_info.state_db.add_response(
         {
             'access_token': 'bearer_token',
             'refresh_token': 'refresh'
         }, 'abcdef')
Example #10
0
 def create_request(self):
     self.req = factory('ProviderInfoDiscovery',
                        client_authn_method=CLIENT_AUTHN_METHOD)
     self._iss = 'https://example.com/as'
     client_config = {
         'client_id': 'client_id',
         'client_secret': 'password',
         'redirect_uris': ['https://example.com/cli/authz_cb'],
         'issuer': self._iss,
         'client_prefs': {
             'id_token_signed_response_alg': 'RS384',
             'userinfo_signed_response_alg': 'RS384'
         }
     }
     self.cli_info = ClientInfo(config=client_config)
     self.cli_info.service = build_services(DEFAULT_SERVICES, factory, None,
                                            None, CLIENT_AUTHN_METHOD)