node.js 中間件
Hi! Welcome to Node.js Authentication Series, where we'll study and program the passport module or middleware.
嗨! 歡迎使用Node.js身份驗證系列 ,我們將在其中研究和編程通行證模塊或中間件 。
Nowadays, an important tool in modern web applications is authentication. In the context of computing, authentications talk about security.
如今,現代Web應用程序中的一個重要工具是身份驗證。 在計算的上下文中,身份驗證涉及安全性。
Authentication is also the verification of the identity or process which is very important in applications.
身份驗證也是對身份或過程的驗證,這在應用程序中非常重要。
Note: You should have a basic understanding of Node.js, Express, and HTML.
注意:您應該對Node.js,Express和HTML有基本的了解。
護照簡介 (Introduction to passport)
What is Passport?
什么是護照?
Just like any other npm module, the passport is a node module or also called middleware.
就像任何其他npm模塊一樣 , 護照是節點模塊或也稱為中間件。
Hey..!!! I got you there!!! It's not the passport for traveling, but yeah it can still be understood that way based on its function. We all know without a passport, one can't travel out of the country.
嘿..!!! 我送你到那里! 它不是旅行的護照,但是是的,根據其功能仍然可以這樣理解。 眾所周知,沒有護照就無法出國旅行。
Here is what the developers of the passport module say about passport:
這是護照模塊的開發人員對護照的評價:
Passport is soo flexible because it has many types of authentication methods which could be local authentication (username or email and password), google, twitter or facebook authentication depending on the application.
Passport非常靈活,因為它具有多種類型的身份驗證方法,這可以是本地身份驗證(用戶名或電子郵件和密碼),google,twitter或facebook身份驗證,具體取決于應用程序。
So, some applications have their own unique authentication requirement and the passport developers call then strategies.
因此,某些應用程序具有其自己獨特的身份驗證要求,并且通行證開發人員會調用隨后的策略。
For example, the authentication that involves signup, login, log out the form can be built using the passport local-strategy.
例如,可以使用護照本地策略構建涉及注冊,登錄和注銷表單的身份驗證。
Other authentication methods which involve log in with google account, facebook or twitter account is called passport OAuth strategies which could then be passport-facebook which is authentication using facebook.
涉及使用Google帳戶,Facebook或Twitter帳戶登錄的其他身份驗證方法稱為通行證OAuth策略 ,然后可以是使用Facebook進行身份驗證的通行證-facebook。
Well, I know you may not be familiar with them at the beginning but they're easy to understand as you work with them.
好吧,我知道您一開始可能并不熟悉它們,但是當您與他們一起工作時,它們很容易理解。
There are other hundreds of strategies which are very useful.
還有其他數百種非常有用的策略。
In my upcoming articles, we will explore several strategies and study them.
在我即將發表的文章中,我們將探討幾種策略并進行研究。
如何安裝護照? (How to install passport?)
Just like any other npm module, the passport is also installed by running a command at the command line.
與其他npm模塊一樣,也可以通過在命令行中運行命令來安裝通行證。
Open your node project directory at the command line and run the command: npm install passport
在命令行中打開節點項目目錄,然后運行以下命令: npm install password
Wait for a while as npm downloads the package for you.
等待一會兒,因為npm為您下載了軟件包。
Note: You can use either command prompt or PowerShell as terminal.
注意:您可以使用命令提示符或PowerShell作為終端。
Thanks for coding with me! See you @ the next article. Feel free to drop a comment or question.
感謝您與我編碼! 下次見。 隨意發表評論或問題。
翻譯自: https://www.includehelp.com/node-js/passport-middleware-module-in-node-js.aspx
node.js 中間件