Oauth2 限制使用 hd 的特定域名的电子邮件不起作用

Oauth2 restrict to emails with specific domain name using hd not working

我的应用程序通过在我的请求中的 hd 参数中指定 abc.com 来限制 Oauth2 登录到特定域,例如 abc.com。Restrict Login Email with Google OAuth2.0 to Specific Domain Name but since these past few days its allowing anyone with a Google account login.I am sure i didn't change the code and even verified the result uri has my domain name specified in its hd parameter following this link instruction https://developers.google.com/identity/protocols/OpenIDConnect#hd-param。所以任何人都可以告诉我我是什么我做错了吗?这是我的代码

     `redirect( uri : "https://accounts.google.com/o/oauth2/auth?" +
            "redirect_uri=${redirectUri}&" +
            "response_type=code&" +
            "client_id="${my_client_id}"& +
            "scope=https%3A%2F%2Fwww.googleapis.com%2Fauth%2Fuserinfo.email" +
            "+https%3A%2F%2Fwww.googleapis.com%2Fauth%2Fuserinfo.profile&" +
            "approval_prompt=auto&" +
            "hd=apposit.com")`

我不知道为什么会这样,但是您可以添加除 hd 之外的第二个安全机制,方法是使用 java 的 contains() 方法检查用户电子邮件是否包含 abc.comendsWith() 哪个更可靠 在你允许用户在你的应用程序中继续前进之前。

但这仍然是一个快速修复,其他有解决方案的人应该回答这个问题