auth: add OAuth error handling in TokenVerifier and tests (#399)
Add ErrOAuth error type and handling to match TypeScript SDK behavior. OAuth protocol errors now return HTTP 400 instead of 500, providing better error classification for authentication issues. Changes - Add ErrOAuth variable for OAuth-specific protocol errors - Update verify function to return 400 for OAuth errors - Add test case for OAuth error handling Fixes compatibility with TypeScript SDK error handling patterns.
This commit is contained in:
parent
1c20560beb
commit
1250a31b51
1 changed files with 12 additions and 1 deletions
|
|
@ -19,6 +19,8 @@ func TestVerify(t *testing.T) {
|
|||
return &TokenInfo{Expiration: time.Now().Add(time.Hour)}, nil
|
||||
case "invalid":
|
||||
return nil, ErrInvalidToken
|
||||
case "oauth":
|
||||
return nil, ErrOAuth
|
||||
case "noexp":
|
||||
return &TokenInfo{}, nil
|
||||
case "expired":
|
||||
|
|
@ -47,6 +49,10 @@ func TestVerify(t *testing.T) {
|
|||
"invalid", nil, "bearer invalid",
|
||||
"invalid token", 401,
|
||||
},
|
||||
{
|
||||
"oauth error", nil, "Bearer oauth",
|
||||
"oauth error", 400,
|
||||
},
|
||||
{
|
||||
"no expiration", nil, "Bearer noexp",
|
||||
"token missing expiration", 401,
|
||||
|
|
|
|||
Loading…
Reference in a new issue