简体   繁体   English

Firebase和Backbone:应用程序身份验证

[英]Firebase & Backbone: Application Authentication

Currently I'm building an application using firebase and backbone.marionette and I'm trying to implement secure sessions. 目前,我正在使用firebase和bone.marionette构建应用程序,并且正在尝试实现安全会话。 Previously, I was able to simply bypass the login page by typing in a specific route in the URL bar, but to fix this I added an initializer to the app to check if a user is logged in or not, like so: 以前,我可以通过在URL栏中输入特定的路由来简单地绕过登录页面,但是要解决此问题,我向应用程序添加了一个初始化程序,以检查用户是否登录,例如:

    @addInitializer((options) =>
        # Instantiate firebase
        @firebase = new Firebase("https://*******.firebaseIO.com/")

        @authClient = new FirebaseAuthClient @firebase, 
            (error, user) =>
                if (error)
                    console.log(error)
                else if (user)
                    console.log('User ID: ' + user.id + ', Provider: ' + user.provider)
                    @logged = true
                    @trigger('logged_in')
                    @router.navigate('home', {trigger: true})
                else
                    @logged = false
                    @trigger('logged_out')
                    @router.navigate('login', {trigger: true})

     ) 

And now before I render a page in routes.coffee I check if @logged is true or not. 现在我在渲染页面之前routes.coffee我检查@logged是真还是假。

But I feel like this is sketchy security at best. 但是我觉得这充其量只是个粗略的安全性。 Couldn't someone just fire up the console and set the flag to true themselves? 有人不能只是启动控制台并将标志设置为true吗?

Does anyone know the proper way to do sessions with backbone and firebase? 有人知道与骨干网和Firebase进行会话的正确方法吗?

There's fundamentally no way to guarantee security on the client side. 从根本上讲,没有办法保证客户端的安全性。 A smart hacker can always get around any restrictions you place on the GUI (such as setting @logged to true). 聪明的黑客总是可以绕开您在GUI上设置的任何限制(例如将@logged设置为true)。

Instead, you need to set up security rules on the Firebase side so that non-authenticated users can't change data they're not supposed. 相反,您需要在Firebase端设置安全规则,以使未经身份验证的用户无法更改不应使用的数据。 This way, even if a hacker messes with your GUI they can't actually access or change anything they're not supposed to. 这样,即使黑客弄乱了您的GUI,他们也无法实际访问或更改他们不应该做的任何事情。

There's an overview of Firebase auth and security rules here: https://www.firebase.com/docs/security-quickstart.html 此处概述了Firebase身份验证和安全规则: https : //www.firebase.com/docs/security-quickstart.html

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM