firebase - 阻止 Firebase 身份验证记住 Google 帐户?

标签 firebase firebase-authentication google-oauth google-authentication firebaseui

因此,我使用 Firebase-UI 来对用户进行身份验证和登录,我需要使用帐户选择器才能让他们登录到其他 Google 帐户(不使用帐户选择器会导致其自动签名) in),但是,我想阻止它显示 + 保存帐户,或者在注销时将其删除。

这是我正在使用的 Firebase-UI 网络:Firebase UI web

当应用程序在用户计算机上运行时,这不是一个大问题,但是,它也将在公共(public)计算机上运行,​​并且有许多用户登录和退出,并且我们无法将它们保存为简单的一键登录。最大的安全问题是,一旦他们通过 Google 身份验证,我也可以登录他们的电子邮件。我们希望他们退出后就忘记他们。

我的登录流程:

     <script type="text/javascript">
            // FirebaseUI config.
            var uiConfig = {
                callbacks: {
                    signInSuccess: function (user, credential, redirectUrl) {
                        var userSignIn = {
                            displayName: user.displayName,
                            email: user.email,
                            emailVerified: user.emailVerified,
                            photoURL: user.photoURL,
                            uid: user.uid,
                            phoneNumber: user.phoneNumber
                        };
                        /* POST signed in user to Login Controller*/
                        var csrfToken = $('input[name="csrfToken"]').attr('value');
                        $.ajaxSetup({
                            beforeSend: function(xhr) {
                                xhr.setRequestHeader('Csrf-Token', csrfToken);
                            }
                        });
                        $.ajax({
                           url: '/signedIn',
                           type: 'POST',
                           data: JSON.stringify(userSignIn),
                           contentType: 'application/json',
                           error: function(err) {
                               console.log(err);
                           }
                        });
                        return true;
                    }
                },
                signInSuccessUrl: '/Dashboard',
                signInOptions: [{
                    provider: firebase.auth.GoogleAuthProvider.PROVIDER_ID,
                    scopes: ['https://www.googleapis.com/auth/calendar']
                }],
                // Terms of service url.
                tosUrl: '/Terms'
            };

            // Initialize the FirebaseUI Widget using FirestoreDB.
            var ui = new firebaseui.auth.AuthUI(firebase.auth());
            // The start method will wait until the DOM is loaded.
            ui.start('#firebaseui-auth-container', uiConfig);
    </script>

注销流程:

initApp = function () {
firebase.auth().onAuthStateChanged(function (user) {
    if (user) {
        // User is signed in.
        if (window.location.pathname === "/Login" || window.location.pathname === "/") {
            window.location.href = '/Dashboard';
        }
        $('#sign-out').show();
    } else {
        // User is signed out.
        $('#sign-out').hide();
        disableLinks();
        switch(window.location.pathname){
            case "/Login":
            case "/Terms":
            case "/Help":
                break;
            default:
                window.location.href = '/Login';
        }
    }
}, function (error) {
    console.log(error);
});
};

window.addEventListener('load', function () {
initApp();
document.getElementById('sign-out').addEventListener('click', function () {
    firebase.auth().signOut().then(function() {
        sessionStorage.clear();
        localStorage.clear();
        window.location = "/Logout";
    }).catch(function(error) {
        console.log(error);
        });
    });
  });

最佳答案

从 Firebase Auth 注销后,重定向到 Google 单点注销网址:

firebase.auth().signOut()
  .then(function() {
    window.location.assign('https://accounts.google.com/Logout');
  })
  .catch(function(error) {
    console.log(error);
  });

关于firebase - 阻止 Firebase 身份验证记住 Google 帐户?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/47288086/

相关文章:

ios - 推送通知后台被用户杀死

ios Firebase 推送通知项目

firebase - 使用 Cloud Functions for Firebase 和节点邮件程序时创建用户事件的登录无效

android - 通过访问 token 创建 GoogleCredential

node.js - Firebase 云功能不发送异步推送通知

javascript - Firebase >> 用户收藏夹列表

swift - Firebase 身份验证电话号码

firebase - 如何从http ://localhost:3000访问Firebase

authentication - YouTube 直播 API 请求与 Api key

ios8 - GIDSignIn 返回 "Keychain error"