将Meteor.js内置Google身份验证限制为域

ken*_*ong 8 meteor google-oauth

我想使用该Meteor.loginWithGoogle()工具对用户进行身份验证,但有没有办法将其限制为特定的(Google Apps)域?

我可以在使用返回的电子邮件对用户进行身份验证后进行检查,但是有没有办法在登录阶段使用一些参数进行Google登录?

Eri*_*sen 9

我现在不认为它可能.有一个pull resquest来部分添加该功能:https://github.com/meteor/meteor/pull/1332 该pull请求的问题似乎是它只修复了瘦身的客户端(即它只显示用户登录时来自所选域的帐户).但它不会添加任何服务器端检查.

我使用以下解决方法:在服务器文件夹中的.js文件中,我有以下代码:

Accounts.validateNewUser(function (user) {
    if(user.services.google.email.match(/example\.org$/)) {
        return true;
    }
    throw new Meteor.Error(403, "You must sign in using a example.org account");
});
Run Code Online (Sandbox Code Playgroud)

这可以防止为与example.org不同的域创建帐户.

  • 它的内置:`Accounts.config({restrictCreationByEmailDomain:'mydomain.com'})` (7认同)