| 146 | return self._on_authentication_verified(resp) |
| 147 | |
| 148 | def _openid_args( |
| 149 | self, |
| 150 | callback_uri: str, |
| 151 | ax_attrs: Iterable[str] = [], |
| 152 | oauth_scope: Optional[str] = None, |
| 153 | ) -> Dict[str, str]: |
| 154 | handler = cast(RequestHandler, self) |
| 155 | url = urllib.parse.urljoin(handler.request.full_url(), callback_uri) |
| 156 | args = { |
| 157 | "openid.ns": "http://specs.openid.net/auth/2.0", |
| 158 | "openid.claimed_id": "http://specs.openid.net/auth/2.0/identifier_select", |
| 159 | "openid.identity": "http://specs.openid.net/auth/2.0/identifier_select", |
| 160 | "openid.return_to": url, |
| 161 | "openid.realm": urllib.parse.urljoin(url, "/"), |
| 162 | "openid.mode": "checkid_setup", |
| 163 | } |
| 164 | if ax_attrs: |
| 165 | args.update( |
| 166 | { |
| 167 | "openid.ns.ax": "http://openid.net/srv/ax/1.0", |
| 168 | "openid.ax.mode": "fetch_request", |
| 169 | } |
| 170 | ) |
| 171 | ax_attrs = set(ax_attrs) |
| 172 | required = [] # type: List[str] |
| 173 | if "name" in ax_attrs: |
| 174 | ax_attrs -= set(["name", "firstname", "fullname", "lastname"]) |
| 175 | required += ["firstname", "fullname", "lastname"] |
| 176 | args.update( |
| 177 | { |
| 178 | "openid.ax.type.firstname": "http://axschema.org/namePerson/first", |
| 179 | "openid.ax.type.fullname": "http://axschema.org/namePerson", |
| 180 | "openid.ax.type.lastname": "http://axschema.org/namePerson/last", |
| 181 | } |
| 182 | ) |
| 183 | known_attrs = { |
| 184 | "email": "http://axschema.org/contact/email", |
| 185 | "language": "http://axschema.org/pref/language", |
| 186 | "username": "http://axschema.org/namePerson/friendly", |
| 187 | } |
| 188 | for name in ax_attrs: |
| 189 | args["openid.ax.type." + name] = known_attrs[name] |
| 190 | required.append(name) |
| 191 | args["openid.ax.required"] = ",".join(required) |
| 192 | if oauth_scope: |
| 193 | args.update( |
| 194 | { |
| 195 | "openid.ns.oauth": "http://specs.openid.net/extensions/oauth/1.0", |
| 196 | "openid.oauth.consumer": handler.request.host.split(":")[0], |
| 197 | "openid.oauth.scope": oauth_scope, |
| 198 | } |
| 199 | ) |
| 200 | return args |
| 201 | |
| 202 | def _on_authentication_verified( |
| 203 | self, response: httpclient.HTTPResponse |