2015年4月21日 星期二

Firebase - User Authentication

Most applications need to know the identity of a user. Knowing a user's identity allows an app to provide a customized experience and grant them permissions to access their data. The process of proving a user's identity is called authentication. Firebase provides a full set of authentication options out-of-the-box.

大部份應用需要知道用戶識別,如此可以讓應用提供客製化體驗以及個人資料的存取許可,提供用戶識別的過程稱為authentication,Firebase可提供完全功能的authentication。

When a user authenticates to a Firebase app, two things happen:
當用戶開始對Firebase應用認證時會發生兩件事:
  • Information about the user is returned in callbacks on the client device. This allows you to customize your app's user experience for that specific user.
  • The user information returned contains a uid (a unique ID), which is guaranteed to be distinct across all providers, and to never change for a specific authenticated user.
  • The value of the auth variable in your app's Security and Firebase Rules becomes defined. This variable is nullfor unauthenticated users, but for authenticated users it is an object containing the user's unique (auth.uid) and potentially other data about the user. This allows you to securely control data access on a per-user basis.

  • 在用戶端的callback返回與用戶有關的資訊
  • 返回的資訊中包含uid (a unique ID),保證是唯一的,而且對特定認證用戶是不變的
  • 位於Security and Firebase Rules中auth變數的值成為已定義,對於未經認證的用戶此值是空的,經過認證用戶此變數代表一個含有auth.uid以及其他潛在資料的物件
Firebase has built-in support for logging in with email & password, social login providers such as Facebook, Google, Twitter, and GitHub, and single-session anonymous login. Apps that use Firebase's built-in auth services can handle user login entirely with client-side code, saving you time and the headache of operating your own backend.

Firebase提供email, password及社群網站的登入方式(如Facebook, Google, Twitter, and GitHub),或是單一session的匿名登入

If you have existing server-side authentication or single sign-on, you can also easily integrate it with Firebase. Download one of our helper libraries to generate authentication tokens on your own servers.

如果你已經有服務端的認證,也可以輕易整合至Firebase,下載幫助函式庫以便在服務器產生認證token

Here is a list of the providers that Firebase supports. Select the one that fits your needs, and follow the provider-specific steps to set it up.

這裡有一個Firebase的提供者的清單,選取你所需要的
PlatformDescription
CustomGenerate your own login tokens. Use this to integrate with existing authentication systems. You can also use this to authenticate server-side workers.
Email & PasswordLet Firebase manage passwords for you. Register and authenticate users by email & password.
AnonymousBuild user-centric functionality without requiring users to share their personal information. Anonymous authentication generates a unique identifier for each user that lasts as long as their session.
 FacebookAuthenticate users with Facebook by writing only client-side code.
 TwitterAuthenticate users with Twitter by writing only client-side code.
 GitHubAuthenticate users with GitHub by writing only client-side code.
 GoogleAuthenticate users with Google by writing only client-side code.



沒有留言:

張貼留言