Uh oh!
There was an error while loading. Please reload this page.
- Notifications
You must be signed in to change notification settings - Fork 17
Add API key format validation #4
Copy link
Copy link
Open
Labels
GrantFox OSSIssue tracked in GrantFox OSSIssue tracked in GrantFox OSSMaybe RewardedIssue may be eligible for a GrantFox rewardIssue may be eligible for a GrantFox rewardOfficial CampaignCampaign: Official CampaignCampaign: Official Campaignarea:clientpriority:p1type:feature
Description
Metadata
Metadata
Assignees
Labels
GrantFox OSSIssue tracked in GrantFox OSSIssue tracked in GrantFox OSSMaybe RewardedIssue may be eligible for a GrantFox rewardIssue may be eligible for a GrantFox rewardOfficial CampaignCampaign: Official CampaignCampaign: Official Campaignarea:clientpriority:p1type:feature
Description:
API keys must conform to a format (e.g.
pk_live_,sk_live_,pk_test_,sk_test_prefixes). Catching a malformed key before the first network call saves developers from cryptic 401 errors. Validation should also enforce that a live key is not accidentally used with the sandbox environment, and vice versa.Proposed Steps:
validate_api_key(key: str, environment: Environment)function inconfig.py.test_key is used withPRODUCTIONor alive_key withSANDBOX.ShadeClientconstructor and in the global setter.Acceptance Criteria:
AuthenticationErrorat configuration time, not at request time.pk_test_key used withenvironment="production"emits aUserWarning.sk_live_key passes validation without error.Noneor empty string raisesAuthenticationErrorimmediately.