ソースを参照

Add yahoo and google shortcuts in basic example

tags/0.5
Chris Smith 15年前
コミット
0c30c67a0b
4個のファイルの変更19行の追加1行の削除
  1. バイナリ
      examples/basic/google.png
  2. 18
    1
      examples/basic/index.php
  3. バイナリ
      examples/basic/yahoo.png
  4. 1
    0
      processor.php

バイナリ
examples/basic/google.png ファイルの表示


+ 18
- 1
examples/basic/index.php ファイルの表示

47
   // Secondly, if the user is being redirected back from their provider, the
47
   // Secondly, if the user is being redirected back from their provider, the
48
   // openid.mode parameter will be present (which PHP translates to openid_mode)
48
   // openid.mode parameter will be present (which PHP translates to openid_mode)
49
 
49
 
50
+  if (isset($_POST['openid_type']) && $_POST['openid_type'] != 'openid_url') {
51
+   // This allows users to select one of the pre-defined identity providers
52
+   // using the provided radio buttons. The values of the radio buttons specify
53
+   // an URL on which we can perform Yadis discovery to find the OpenID
54
+   // endpoint.
55
+   define('OPENID_URL', $_POST['openid_type']);
56
+  }
57
+
50
   require('../../processor.php');
58
   require('../../processor.php');
51
 
59
 
52
  } else {
60
  } else {
62
   <style type="text/css">
70
   <style type="text/css">
63
    input#openid_url {
71
    input#openid_url {
64
     background: url('../../openid.gif') no-repeat; padding-left: 20px;
72
     background: url('../../openid.gif') no-repeat; padding-left: 20px;
73
+    margin: 5px 0px 0px 40px;
65
    }
74
    }
66
 
75
 
67
    p { padding-left: 10px; }
76
    p { padding-left: 10px; }
69
    p.succ { border-left: 10px solid #0f0; }
78
    p.succ { border-left: 10px solid #0f0; }
70
    caption { text-align: left; } 
79
    caption { text-align: left; } 
71
    table { margin: 10px; }
80
    table { margin: 10px; }
81
+
82
+   ul { list-style-type: none; }
83
+   input[type="radio"] { width: 20px; }
72
   </style>
84
   </style>
73
  </head>
85
  </head>
74
  <body>
86
  <body>
118
 ?>
130
 ?>
119
   <form action="<?PHP echo htmlentities($_SERVER['REQUEST_URI']); ?>"
131
   <form action="<?PHP echo htmlentities($_SERVER['REQUEST_URI']); ?>"
120
 	method="post">
132
 	method="post">
121
-   <input type="text" name="openid_url" id="openid_url">
133
+   <ul>
134
+    <li><label><input type="radio" name="openid_type" value="gmail.com"> <img src="google.png" alt="Google"> Log in with my Google account</label></li>
135
+    <li><label><input type="radio" name="openid_type" value="yahoo.com"> <img src="yahoo.png" alt="Yahoo!"> Log in with my Yahoo! account</label></li>
136
+    <li><label><input type="radio" name="openid_type" value="openid_url" checked="checked"> Log in with another OpenID identity:</label> <br>
137
+        <input type="text" name="openid_url" id="openid_url"></li>
138
+   </ul>
122
    <input type="submit" value="Login">
139
    <input type="submit" value="Login">
123
   </form>
140
   </form>
124
  </body>
141
  </body>

バイナリ
examples/basic/yahoo.png ファイルの表示


+ 1
- 0
processor.php ファイルの表示

246
    if ($_SESSION['openid']['delegate'] == 'http://specs.openid.net/auth/2.0/identifier_select') {
246
    if ($_SESSION['openid']['delegate'] == 'http://specs.openid.net/auth/2.0/identifier_select') {
247
     $_SESSION['openid']['identity'] = $_REQUEST['openid_identity']; 
247
     $_SESSION['openid']['identity'] = $_REQUEST['openid_identity']; 
248
     $_SESSION['openid']['delegate'] = $_REQUEST['openid_claimed_id'];
248
     $_SESSION['openid']['delegate'] = $_REQUEST['openid_claimed_id'];
249
+    // TODO: This needs to be verified by perfoming discovery on the url
249
    } else {
250
    } else {
250
      error('diffid', 'Identity provider validated wrong identity. Expected it to '
251
      error('diffid', 'Identity provider validated wrong identity. Expected it to '
251
   	             . 'validate ' . $_SESSION['openid']['delegate'] . ' but it '
252
   	             . 'validate ' . $_SESSION['openid']['delegate'] . ' but it '

読み込み中…
キャンセル
保存