Skip to content

Commit

Permalink
update handwritten error codes to match auth OpenAPI schema
Browse files Browse the repository at this point in the history
  • Loading branch information
bertrmz committed Dec 11, 2024
1 parent e0bc485 commit b4ca0ae
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 10 deletions.
18 changes: 9 additions & 9 deletions lib/passageidentity/auth.rb
Original file line number Diff line number Diff line change
Expand Up @@ -35,10 +35,10 @@ def authenticate_request(request)
if @auth_strategy == Passage::COOKIE_STRATEGY
unless request.cookies.key?('psg_auth_token')
raise PassageError.new(
status_code: 400,
status_code: 401,
body: {
error: 'missing authentication token: expected "psg_auth_token" cookie',
code: 'missing_auth_token'
code: 'invalid_access_token'
}
)
end
Expand All @@ -47,10 +47,10 @@ def authenticate_request(request)
headers = request.headers
unless headers.key?('Authorization')
raise PassageError.new(
status_code: 400,
status_code: 401,
body: {
error: 'no authentication token in header',
code: 'missing_auth_token'
code: 'invalid_access_token'
}
)
end
Expand All @@ -68,8 +68,8 @@ def validate_jwt(token)
raise PassageError.new(
status_code: 401,
body: {
error: 'invalid authentication token',
code: 'invalid_jwks'
error: 'invalid JWKs',
code: 'invalid_access_token'
}
)
end
Expand All @@ -96,7 +96,7 @@ def validate_jwt(token)
status_code: 401,
body: {
error: e.message,
code: 'invalid_jwt'
code: 'invalid_access_token'
}
)
end
Expand Down Expand Up @@ -139,7 +139,7 @@ def create_magic_link(
status_code: 400,
body: {
error: 'channel: must be either Passage::EMAIL_CHANNEL or Passage::PHONE_CHANNEL',
code: 'bad_request_data'
code: 'invalid_request'
}
)
end
Expand Down Expand Up @@ -220,7 +220,7 @@ def user_exists?(user_id)
status_code: 400,
body: {
error: 'Must supply a valid user_id',
code: 'user_not_found'
code: 'invalid_request'
}
)
end
Expand Down
2 changes: 1 addition & 1 deletion lib/passageidentity/client.rb
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ def initialize(app_id:, api_key: '', auth_strategy: COOKIE_STRATEGY)
status_code: 400,
body: {
error: 'Invalid auth strategy',
code: 'invalid_auth_strategy'
code: 'invalid_argument'
}
)
end
Expand Down

0 comments on commit b4ca0ae

Please sign in to comment.