コード例 #1
0
ファイル: provider.py プロジェクト: htobenothing/pyoidc
    def verify_client(self, environ, areq, authn_method, client_id=""):
        """

        :param environ: WSGI environ
        :param areq: The request
        :param authn_method: client authentication method
        :return:
        """

        if not client_id:
            client_id = get_client_id(self.cdb, areq, environ["HTTP_AUTHORIZATION"])

        try:
            method = self.client_authn_methods[authn_method]
        except KeyError:
            raise UnSupported()
        return method(self).verify(environ, client_id=client_id)
コード例 #2
0
    def verify_client(self, environ, areq, authn_method, client_id=""):
        """
        Verify the client based on credentials.

        :param environ: WSGI environ
        :param areq: The request
        :param authn_method: client authentication method
        :return:
        """
        if not client_id:
            client_id = get_client_id(self.cdb, areq, environ["HTTP_AUTHORIZATION"])

        try:
            method = self.client_authn_methods[authn_method]
        except KeyError:
            raise UnSupported()
        return method(self).verify(environ, client_id=client_id)
コード例 #3
0
 def test_basic_authn_client_invalid(self):
     authn = "Basic " + b64encode(b"expired:drickyoughurt").decode()
     with pytest.raises(FailedAuthentication):
         get_client_id(self.cdb, AuthorizationRequest(), authn)
コード例 #4
0
 def test_basic_authn_client_ok(self):
     authn = "Basic " + b64encode(b"number5:drickyoughurt").decode()
     assert get_client_id(self.cdb, AuthorizationRequest(), authn)
コード例 #5
0
 def test_basic_authn_client_wrongpass(self):
     authn = "Basic " + b64encode(b"number5:wrongpassword").decode()
     with pytest.raises(FailedAuthentication):
         get_client_id(self.cdb, AuthorizationRequest(), authn)
コード例 #6
0
 def test_empty_authn_client_invalid(self):
     bib = {"client_id": "expired"}
     arq = AuthorizationRequest(**bib)
     with pytest.raises(FailedAuthentication):
         get_client_id(self.cdb, arq, None)
コード例 #7
0
 def test_wrong_authn(self):
     with pytest.raises(FailedAuthentication):
         get_client_id(self.cdb, AuthorizationRequest(), "mumbo jumbo")
コード例 #8
0
 def test_wrong_authn(self):
     with pytest.raises(FailedAuthentication):
         get_client_id(self.cdb, AuthorizationRequest(), 'mumbo jumbo')
コード例 #9
0
 def test_empty_authn_empty_request(self):
     with pytest.raises(FailedAuthentication):
         get_client_id(self.cdb, AuthorizationRequest(), None)
コード例 #10
0
 def test_bearer_authn_client_invalid(self):
     authn = 'Bearer expired_token'
     with pytest.raises(FailedAuthentication):
         get_client_id(self.cdb, AuthorizationRequest(), authn)
コード例 #11
0
 def test_bearer_authn_client_invalid(self):
     authn = "Bearer expired_token"
     with pytest.raises(FailedAuthentication):
         get_client_id(self.cdb, AuthorizationRequest(), authn)
コード例 #12
0
 def test_bearer_authn_client_ok(self):
     authn = 'Bearer secret_token'
     assert get_client_id(self.cdb, AuthorizationRequest(), authn) == 'token_client'
コード例 #13
0
 def test_bearer_authn_client_missing(self):
     authn = 'Bearer wrong_token'
     with pytest.raises(FailedAuthentication):
         get_client_id(self.cdb, AuthorizationRequest(), authn)
コード例 #14
0
 def test_basic_authn_client_invalid(self):
     authn = 'Basic ' + b64encode(b'expired:drickyoughurt').decode()
     with pytest.raises(FailedAuthentication):
         get_client_id(self.cdb, AuthorizationRequest(), authn)
コード例 #15
0
 def test_basic_authn_client_wrongpass(self):
     authn = 'Basic ' + b64encode(b'number5:wrongpassword').decode()
     with pytest.raises(FailedAuthentication):
         get_client_id(self.cdb, AuthorizationRequest(), authn)
コード例 #16
0
 def test_basic_authn_client_ok(self):
     authn = 'Basic ' + b64encode(b'number5:drickyoughurt').decode()
     assert get_client_id(self.cdb, AuthorizationRequest(), authn)
コード例 #17
0
 def test_bearer_authn_client_ok(self):
     authn = "Bearer secret_token"
     assert get_client_id(self.cdb, AuthorizationRequest(),
                          authn) == "token_client"
コード例 #18
0
 def test_empty_authn_empty_request(self):
     with pytest.raises(FailedAuthentication):
         get_client_id(self.cdb, AuthorizationRequest(), None)
コード例 #19
0
 def test_bearer_authn_client_missing(self):
     authn = "Bearer wrong_token"
     with pytest.raises(FailedAuthentication):
         get_client_id(self.cdb, AuthorizationRequest(), authn)
コード例 #20
0
 def test_empty_authn_client_invalid(self):
     bib = {'client_id': 'expired'}
     arq = AuthorizationRequest(**bib)
     with pytest.raises(FailedAuthentication):
         get_client_id(self.cdb, arq, None)
コード例 #21
0
 def test_empty_authn_client_ok(self):
     bib = {"client_id": "number5"}
     arq = AuthorizationRequest(**bib)
     assert get_client_id(self.cdb, arq, None) == "number5"
コード例 #22
0
 def test_empty_authn_client_ok(self):
     bib = {'client_id': 'number5'}
     arq = AuthorizationRequest(**bib)
     assert get_client_id(self.cdb, arq, None) == 'number5'