Ich benutze das Knock Juwel, um JWT-Authentifizierung zu implementieren. Wenn ich beim Testen die Benutzeranmeldeinformationen an die richtige URL sende, wird das JWT wie erwartet zurückgegeben, aber in der Produktion gibt derselbe Code eine 400-Antwort zurück, wenn Anmeldeinformationen gesendet werden. Ich habe die Anmeldeinformationen des Benutzers in der Produktionsdatenbank mit den gesendeten Daten überprüft. Authentifizierung mit Knock funktioniert im Test, aber nicht Produktion
Dies sind die Durchgangsprüfungen:
test 'get authentication token' do
post '/knock/auth_token', {auth: {phone: @user.phone, password: 'password'}}
response = ActiveSupport::JSON.decode @response.body
assert_match /.*\..*\..*/, response['jwt']
end
test 'no authentication on bad credentials' do
post '/knock/auth_token', {auth: {phone: @user.phone, password: 'invalid'}}
assert_response :missing
end
Dies ist die curl Befehl, der einen 400-Fehler bekommt:
curl -v --data "{\"auth\":{\"phone\":\"my_phone_number\",\"password\":\"my_password\"}}" https://production.server.com/knock/auth_token
Was hier los?
EDIT Hier ist, was ich in der Produktion log gefunden (Ich denke, das die entsprechenden Bits):
2016-06-16T07:28:23.906814+00:00 heroku[router]: at=info method=POST path="/knock/auth_token?auth={%22phone%22=%3E%22my_phone_number%22,%20%22password%22=%3E%22my_password%22}" host=production.server.com request_id=33e6189c-bccb-432a-af64-78ef890fbb4f fwd="110.175.125.233" dyno=web.1 connect=0ms service=14ms status=500 bytes=1714
2016-06-16T07:28:56.429852+00:00 heroku[router]: at=info method=POST path="/knock/auth_token" host=production.server.com request_id=86f182b9-c1a9-40c0-abaa-30d488194cb8 fwd="110.175.125.233" dyno=web.1 connect=0ms service=33ms status=400 bytes=224
2016-06-16T07:28:56.406561+00:00 app[web.1]: Started POST "/knock/auth_token" for 110.175.125.233 at 2016-06-16 07:28:56 +0000
2016-06-16T07:28:56.415192+00:00 app[web.1]: Processing by Knock::AuthTokenController#create as /
2016-06-16T07:28:56.415960+00:00 app[web.1]: Completed 400 Bad Request in 1ms (ActiveRecord: 0.0ms) 2016-06-16T07:28:56.418134+00:00 app[web.1]: 2016-06-16T07:28:56.418141+00:00 app[web.1]: ActionController::ParameterMissing (param is missing or the value is empty: auth):
Was sagt das Produktionsprotokoll? – devanand
@devanand danke, gib das einfach rein. Lass es mich wissen, wenn du mehr brauchst. –