0

I'm probably missing something really silly, and missed it in the Google Federated Login documentation, but how is the Google OpenID login actually secure for the requesting site? How does the requesting site know the details are coming from Google and not just someone typing in query string parameters into the URL?

To illustrate, I'm implementing a basic OpenID login sequence in PHP, and all that seems to be returned is a bunch of query string parameters in the URL that I can use to get the OpenID details, which works great. The problem is, if I just typed those into the address bar manually without actually logging in with Google, how would my requesting site know the difference?

First, the form requesting the details:

<form method='post' action='https://www.google.com/accounts/o8/ud'>

    <input type='hidden' name='openid.return_to' value='http://www.example/com/logged-in' />

    <input type='hidden' name='openid.mode' value='checkid_setup' />
    <input type='hidden' name='openid.ns' value='http://specs.openid.net/auth/2.0' />
    <input type='hidden' name='openid.claimed_id' value='http://specs.openid.net/auth/2.0/identifier_select' />
    <input type='hidden' name='openid.identity' value='http://specs.openid.net/auth/2.0/identifier_select' />

    <input type='hidden' name='openid.ns.ax' value='http://openid.net/srv/ax/1.0' />
    <input type='hidden' name='openid.ax.mode' value='fetch_request' />
    <input type='hidden' name='openid.ax.required' value='email,firstname,lastname' />
    <input type='hidden' name='openid.ax.type.email' value='http://axschema.org/contact/email' />
    <input type='hidden' name='openid.ax.type.firstname' value='http://axschema.org/namePerson/first' />
    <input type='hidden' name='openid.ax.type.lastname' value='http://axschema.org/namePerson/last' />

    <input type='submit' value='Login With Google Account' />

</form>

...which works great, sending me back to the requesting site at http://www.example.com/logged-in with a whole bunch of URL parameters, illustrated below (from a PHP print_r call):

Array
(
    [openid_ns] => http://specs.openid.net/auth/2.0
    [openid_mode] => id_res
    [openid_return_to] => http://www.example.com/logged-in
    [openid_ext1_type_firstname] => http://axschema.org/namePerson/first
    [openid_ext1_value_firstname] => {user's first name}
    [openid_ext1_type_email] => http://axschema.org/contact/email
    [openid_ext1_value_email] => {user's e-mail address}
    [openid_ext1_type_lastname] => http://axschema.org/namePerson/last
    [openid_ext1_value_lastname] => {user's last name}
)

...which is awesome, but how do I know that this is in fact a legitimate request, and not someone typing in the above parameters into the address bar?

Thanks for any help, apologies if this has been asked already (couldn't find any replicas!) and if I'm missing something obvious!

4

1 に答える 1

1

あまり多くの詳細に立ち入ることなく(厄介な詳細が必要な場合はOpenID仕様を読んでください)、OpenIDプロトコルにはこのための安全策があります。返されるアサーションは署名されて検証可能であり、プロバイダーが互いのIDをスプーフィングするのを防ぐためにIDの名前空間を設定する方法には制限があります。確立されたライブラリを使用している場合(たとえば、php-openidで問題ありません)、通常はカバーの下で処理されるため、これについてあまり心配する必要はありません。独自の実装を展開しようとしている場合は、...まあ、しないでください...

とはいえ、プロトコルでカバーされていないことがいくつかあります。たとえば、属性は応答で署名されていますが、特定のプロバイダーを信頼しない限り、属性が正確であるとは限りません。一部のアプリは、(応答を検証した後)アサーションを行ったプロバイダーのURL /ホスト名をチェックし、適切な電子メール検証を行う既知のIDプロバイダーをホワイトリストに登録します。確認済みのメールが必要な場合は、これを行うとUXが向上します。ただし、アサーションが不明なIDプロバイダーからのものである場合は、自分で所有権を確認しない限り、電子メールアドレスが実際にユーザーのものであると想定しないでください。

于 2012-01-26T19:27:44.010 に答える