Gram z authlogic-example-app i nie udało mi się uzyskać adresu e-mail od dostawcy OpenID (w moim przypadku: Google i Yahoo) po zarejestrowaniu użytkownika, resp. Otrzymuję pustą odpowiedź zamiast adresu e-mail (sprawdź komentarze w kodzie poniżej).Ruby-OpenID: Wymagany adres e-mail od dostawcy OpenID
Tak wygląda mój model użytkownika (wszystko inne wygląda jak "z _openidem" - gałąź wspomnianej wyżej przykładowej aplikacji authlogic). Poza brakującą "wiadomością e-mail" proces uwierzytelniania typu openid działa zgodnie z oczekiwaniami:
class User < ActiveRecord::Base
acts_as_authentic do |c|
# not needed because I use OpenID
c.validate_login_field = false
# avoid failed validation before OpenID request
c.validate_email_field = false
# this one sets 'openid.sreg.required=email'
c.required_fields = [:email]
end
private
# overwriting the existing method in '/lib/authlogic_openid/acts_as_authentic.rb'
def map_openid_registration(registration)
# this is my problem: 'registration' is an empty hash
self.email ||= registration[:email] if respond_to?(:email) && !registration[:email].blank?
end
end
Każdy pomysł, jak rozwiązać ten problem? Czy ktoś tutaj zrobił to przed użyciem authlogic? Albo jeszcze lepiej: czy masz działający przykład?
Aktualizacja: Sprawdziłem Google Account Authentication API i porównano wniosek złożony przez authlogic (używając ruby-openid-gem i openid-authentication-plugin) z example requests na docs API uwierzytelniania konta Google:
Przykład żądanie uwierzytelnienia i pobrać adres e-mail od Google:
https://www.google.com/accounts/o8/ud
?openid.ns=http%3A%2F%2Fspecs.openid.net%2Fauth%2F2.0
&openid.claimed_id=http%3A%2F%2Fspecs.openid.net%2Fauth%2F2.0%2Fidentifier_select
&openid.identity=http%3A%2F%2Fspecs.openid.net%2Fauth%2F2.0%2Fidentifier_select
&openid.return_to=http%3A%2F%2Fwww.example.com%2Fcheckauth
&openid.realm=http%3A%2F%2Fwww.example.com%2F
&openid.assoc_handle=ABSmpf6DNMw
&openid.mode=checkid_setup
&openid.ns.ext1=http%3A%2F%2Fopenid.net%2Fsrv%2Fax%2F1.0
&openid.ext1.mode=fetch_request
&openid.ext1.type.email=http%3A%2F%2Faxschema.org%2Fcontact%2Femail
&openid.ext1.required=email
wniosek złożony przez mojego appliation:
https://www.google.com/accounts/o8/ud
?openid.assoc_handle=AOQobUcdICerEyK6SXJfukaz8ygXiBqF_gKXv68OBtPXmeafBSdZ6576
&openid.ax.mode=fetch_request
&openid.claimed_id=http%3A%2F%2Fspecs.openid.net%2Fauth%2F2.0%2Fidentifier_select
&openid.identity=http%3A%2F%2Fspecs.openid.net%2Fauth%2F2.0%2Fidentifier_select
&openid.mode=checkid_setup
&openid.ns=http%3A%2F%2Fspecs.openid.net%2Fauth%2F2.0
&openid.ns.ax=http%3A%2F%2Fopenid.net%2Fsrv%2Fax%2F1.0
&openid.ns.sreg=http%3A%2F%2Fopenid.net%2Fextensions%2Fsreg%2F1.1
&openid.realm=http%3A%2F%2Flocalhost%3A3000%2F
&openid.return_to=http%3A%2F%2Flocalhost%3A3000%2Faccount%3Ffor_model%3D1%26_method%3Dpost%26open_id_complete%3D1
&openid.sreg.required=email
Podczas debugowania całą konfigurację, Znalazłem, że openid-authentication-plugin nie otrzymuje e-mail w odpowiedzi otrzymuje od dostawcy OpenID, to przynajmniej wyjaśnia, dlaczego registration
hash w moim łatwość modelu jest pusty ...
UPDATE: Jeśli grasz wokół z Authlogic oraz OpenID, nie zapomnij o sprawdzeniu latest railscast on this subject!
Otrzymuję błędy, gdy te pola są włączone ... niezdefiniowana metoda 'required_fields = 'dla # ... bez nich: # c.required_fields = ["http://axschema.org/contact/email"] # pobierz e-mail przez sreg # c.optional_fields = ["email"] to działa. –
holden
@holden: Powiedziałem to jako odpowiedź na zgłoszony przez ciebie problem github. – Javier
Możesz być także zainteresowany tym widelcem, który (jak w README) ma na celu poradzenie sobie z niektórymi wariantami SReg i AX: https://github.com/binaryfeed/open_id_authentication - Nie jestem pewien, czy to rzeczywiście odpowiada pytanie, per se, po prostu wydaje się istotne dla tematu. – lindes