Skip to content

Commit

Permalink
Remove API key prefix check (#24)
Browse files Browse the repository at this point in the history
  • Loading branch information
silas authored Nov 30, 2024
1 parent 8afa0e7 commit 0d3991d
Show file tree
Hide file tree
Showing 3 changed files with 2 additions and 8 deletions.
2 changes: 0 additions & 2 deletions adminapi/adminapi.go
Original file line number Diff line number Diff line change
Expand Up @@ -32,8 +32,6 @@ func New(adminKey string, opts ...option.ClientOption) (Client, error) {
adminKey = strings.TrimSpace(adminKey)
if adminKey == "" {
return nil, internal.CallErrorf(nil, nil, "adminKey required")
} else if !strings.HasPrefix(adminKey, internal.AdminKeyPrefix) {
return nil, internal.CallErrorf(nil, nil, "adminKey must start with `%s`", internal.AdminKeyPrefix)
} else {
o.Headers.Set(internal.AuthHeader, "Bearer "+adminKey)
}
Expand Down
6 changes: 2 additions & 4 deletions internal/constants.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,10 +11,8 @@ const (
UserAgent = "UserHub-Go/0.7.0"
Version = "0.7.0"

AuthHeader = "Authorization"
ApiKeyHeader = "UserHub-Api-Key"
AdminKeyPrefix = "sk_"
UserKeyPrefix = "pk_"
AuthHeader = "Authorization"
ApiKeyHeader = "UserHub-Api-Key"

WebhookActionHeader = "UserHub-Action"
WebhookAgentHeader = "Webhook-Agent"
Expand Down
2 changes: 0 additions & 2 deletions userapi/userapi.go
Original file line number Diff line number Diff line change
Expand Up @@ -32,8 +32,6 @@ func New(userKey, accessToken string, opts ...option.ClientOption) (Client, erro
userKey = strings.TrimSpace(userKey)
if userKey == "" {
return nil, internal.CallErrorf(nil, nil, "userKey required")
} else if !strings.HasPrefix(userKey, internal.UserKeyPrefix) {
return nil, internal.CallErrorf(nil, nil, "userKey must start with `%s`", internal.UserKeyPrefix)
} else {
o.Headers.Set(internal.ApiKeyHeader, userKey)
}
Expand Down

0 comments on commit 0d3991d

Please sign in to comment.