2010-08-09 5 views
3

애플리케이션 용 Google Federated Login (OpenID) 만 사용하도록 앱을 이동 중입니다. Google은 모든 용도로 Google 앱을 사용하며 사용자 관리를 더 쉽게 결합 할 수 있다고 생각합니다. . 성공적으로 로그인하여 사용자를 만들 수 있지만 내 생각은 이제 보안에 달려 있습니다 ...Google Apps 및 Open ID 인증 - 보안

사용자가 로그인하면 "로그인"버튼 만 있습니다. 사이트 도메인은 하드 코딩되어 있으며 (SITE_DOMAIN이 아래에 표시됨) 일반적인 Google 로그인 페이지로 리디렉션됩니다. ...

def create 
    open_id_authentication 
    end 

    protected 

    def open_id_authentication 
    openid_url = 'https://www.google.com/accounts/o8/site-xrds?hd=SITE_DOMAIN' 
    authenticate_with_open_id(openid_url, 
           :required => ['http://axschema.org/contact/email', 
              'http://axschema.org/namePerson/first', 
              'http://axschema.org/namePerson/last']) do |result, identity_url, registration| 
     case result.status 
     when :missing 
     failed_login "Sorry, the OpenID server couldn't be found" 
     when :invalid 
     failed_login "Sorry, but this does not appear to be a valid OpenID" 
     when :canceled 
     failed_login "OpenID verification was canceled" 
     when :failed 
     failed_login "Sorry, the OpenID verification failed" 
     when :successful 
     if @current_user = User.find_by_id_url(identity_url) 
      if @current_user.login_from(request.env['REMOTE_ADDR']) 
      successful_login 
      else 
      failed_login "Your OpenID profile registration failed: " + @current_user.errors.full_messages.to_sentence 
      end 
     else 
      ax_response = OpenID::AX::FetchResponse.from_success_response(request.env[Rack::OpenID::RESPONSE]) 
      @current_user = User.login_create(ax_response, identity_url, request.env['REMOTE_ADDR']) 
      successful_login 
     end 
     end 
    end 
    end 

단순히 세션에 사용자를 저장 성공적으로 로그인하면

session[:current_user] = @current_user 

... 그리고 응용 프로그램 컨트롤러에 간단한 CURRENT_USER 방법을 사용 : 여기

코드입니다 ...

def current_user 
    return session[:current_user] if defined?(session[:current_user]) 
    end 

내 관심사는 보안에 관한 것입니다. OpenIDAuthentication은 메모리 내장 저장소를 사용하고 있으며 전반적으로 구현하기가 너무 쉬워 보였습니다 (여러 문서를 읽은 후). 기본 테스트는 이것이 잘 작동하는 것을 보여 주지만 긴장됩니다. :)

의견이 있으십니까?

나는 open_id_authentication 플러그인 및

답변

1

이 지금 omniauth에 훨씬 쉽게 덕분에 (구글 애플 리케이션을위한 루비 오픈 ID-앱을 발견 보석과) 기본 루비 오픈 ID 보석을 사용하고 있습니다.