wso2 - 如何在谷歌oauth登录表单中显示预填的电子邮件
问题描述
我使用 WSO2 作为身份服务器,使用谷歌身份验证器作为身份提供者。登录工作正常。在我的网络应用程序中,我要求用户输入他的电子邮件,然后显示谷歌登录表单。我想显示这封电子邮件以预先填写此表格。谢谢。
解决方案
你能行的。为此,您需要自定义 OpenIDConnectAuthenticator.java 以将 login_hint 传递给 google。
建议检查到你服务器中的 org.wso2.carbon.identity.application.authenticator.oidc 版本(你可以在 IS_HOME/repository/components/dropins/ 中找到它)
response.sendRedirect(loginPage);
在 OpenIDConnectAuthenticator.java之前添加这些行String[] usernames = context.getAuthenticationRequest().getRequestQueryParam("username"); if (usernames != null && usernames.length > 0) { loginPage = loginPage + "&login_hint=" + usernames[0]; }
这些行将从身份验证启动请求中获取用户名,并将其作为 login_hint 发送给 google。
- 使用以下命令构建组件。
mvn clean install
这将在目标文件夹中创建 org.wso2.carbon.identity.application.authenticator.oidc-5.1.17.jar。
- 替换 IS_HOME/repository/components/dropins 文件夹中现有的 org.wso2.carbon.identity.application.authenticator.oidc-.jar。
- 重启 IS 服务器
- 向 IS 发送身份验证请求时附加
username=senthalank@gmail.com
为 url 参数
例如,
https://localhost:9443/oauth2/authorize?response_type=code&client_id=<cliend_id>&redirect_uri=http://localhost:8080/playground2/oauth2client&scope=openid&username=senthalank@gmail.com
推荐阅读
- c - 如何合并两个不重复的数组?
- c++ - system() 在 for 循环 c++ 中不起作用
- swift - Swift SpriteKit,不能多次发射子弹
- c# - 类的“搜索引擎”
- python - 在 isin() 中处理空字符串的 Pandaic 方法
- android - 如何在谷歌地图中显示谷歌卫星按钮?
- css - 图标题与图像边距对齐
- c++ - 如何更改 libstdc++.so.6 的版本?
- python - Pandas pd.Series.isin 性能与集合与数组
- c# - 是否可以从上次成功构建 IIS 服务器应用程序池(生产)运行 Asp.net Web 应用程序(Web 表单应用程序)