diff --git a/lib/passageidentity/auth.rb b/lib/passageidentity/auth.rb index e000ac0..bebf8f2 100644 --- a/lib/passageidentity/auth.rb +++ b/lib/passageidentity/auth.rb @@ -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 @@ -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 @@ -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 @@ -96,7 +96,7 @@ def validate_jwt(token) status_code: 401, body: { error: e.message, - code: 'invalid_jwt' + code: 'invalid_access_token' } ) end @@ -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 @@ -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 diff --git a/lib/passageidentity/client.rb b/lib/passageidentity/client.rb index 5c31681..0ba2cde 100644 --- a/lib/passageidentity/client.rb +++ b/lib/passageidentity/client.rb @@ -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