Description
The SDK uses lowercase bearer in the Authorization header, but the Cloud PDP (https://cloudpdp.api.permit.io) requires uppercase Bearer per RFC 6750.
Location
https://github.com/permitio/permit-python/blob/main/permit/enforcement/enforcer.py#L47
self._headers = {
"Content-Type": "application/json",
"Authorization": f"bearer {self._config.token}", # Should be "Bearer"
}
Steps to Reproduce
- Use permit SDK v2.8.3 with Cloud PDP
- Call
permit.check() with valid API key
- Get
PermitConnectionError: Permit SDK got unexpected status code: 401
Evidence
Lowercase bearer fails:
curl -X POST https://cloudpdp.api.permit.io/allowed
-H "Authorization: bearer permit_key_xxx"
-H "Content-Type: application/json"
-d '{"user": {"key": "test"}, "action": "view", "resource": {"type": "Resource"}}'
Returns: {"message":"Unauthorized"}
Uppercase Bearer works:
curl -X POST https://cloudpdp.api.permit.io/allowed
-H "Authorization: Bearer permit_key_xxx"
-H "Content-Type: application/json"
-d '{"user": {"key": "test"}, "action": "view", "resource": {"type": "Resource"}}'
Returns: {"allow": true, ...}
Fix
Change line 47 in permit/enforcement/enforcer.py:
"Authorization": f"Bearer {self._config.token}",
Environment
Description
The SDK uses lowercase
bearerin the Authorization header, but the Cloud PDP (https://cloudpdp.api.permit.io) requires uppercaseBearerper RFC 6750.Location
https://github.com/permitio/permit-python/blob/main/permit/enforcement/enforcer.py#L47
self._headers = {
"Content-Type": "application/json",
"Authorization": f"bearer {self._config.token}", # Should be "Bearer"
}
Steps to Reproduce
permit.check()with valid API keyPermitConnectionError: Permit SDK got unexpected status code: 401Evidence
Lowercase
bearerfails:curl -X POST https://cloudpdp.api.permit.io/allowed
-H "Authorization: bearer permit_key_xxx"
-H "Content-Type: application/json"
-d '{"user": {"key": "test"}, "action": "view", "resource": {"type": "Resource"}}'
Returns: {"message":"Unauthorized"}
Uppercase
Bearerworks:curl -X POST https://cloudpdp.api.permit.io/allowed
-H "Authorization: Bearer permit_key_xxx"
-H "Content-Type: application/json"
-d '{"user": {"key": "test"}, "action": "view", "resource": {"type": "Resource"}}'
Returns: {"allow": true, ...}
Fix
Change line 47 in
permit/enforcement/enforcer.py:"Authorization": f"Bearer {self._config.token}",
Environment