前言介紹
- 這款 WordPress 外掛「GS JWT Authentication for WP REST API」是 2022-01-10 上架。
- 目前有 10 個安裝啟用數。
- 上一次更新是 2022-01-13,距離現在已有 1207 天。超過一年沒更新,安裝要確認版本是否可用。以及後續維護問題!
- 外掛最低要求 WordPress 4.2 以上版本才可以安裝。
- 外掛要求網站主機運作至少需要 PHP 版本 5.3.0 以上。
- 尚未有人給過這款外掛評分。
- 還沒有人在論壇上發問,可能目前使用數不多,還沒有什麼大問題。
外掛協作開發者
外掛標籤
jwt | otp | wp-api | wp-json | json web authentication |
內容簡介
:
{
"message": "OTP is Successfully Send to your Mobile Number."
}
Verify otp by billing mobile number
Request method:
POST /wp-json/gs-jwt/v1/verify-otp
Body{
"mobile": "enter mobile number",
"otp": "enter OTP from mobile"
}
Reponse
{
"code": "200",
"message": "OTP is validate"
}
Register user by email
Request method:
POST /wp-json/gs-jwt/v1/register_user
Body{
"username": "enter username",
"email": "enter email",
"password": "enter password",
"billing_first_name": "enter billing first name",
"billing_last_name": "enter billing last name",
"billing_company_name": "",
"billing_country": "enter billing country",
"billing_street_address": "enter billing street address",
"billing_city": "enter billing city",
"billing_state": "enter billing state",
"billing_postcode": "enter billing postcode",
"billing_phone": "enter billing phone"
}
Reponse
{
"code": "200",
"message": "User register successfully."
}
Register user by mobile
Request method:
POST /wp-json/gs-jwt/v1/register_userbymobile
Body{
"mobile": "enter mobile number",
"billing_first_name": "enter billing first name",
"billing_last_name": "enter billing last name",
"billing_company_name": "",
"billing_country": "enter billing country",
"billing_street_address": "enter billing street address",
"billing_city": "enter billing city",
"billing_state": "enter billing state",
"billing_postcode": "enter billing postcode",
"billing_email": "enter billing email"
}
Reponse
{
"code": "200",
"message": "User register successfully."
}
此外,此外掛還可擴展 WP REST API,使用 JSON Web Tokens 作為身分驗證方式。GS JWT 同時提供編碼和解碼 JSON Web Tokens (JWT) 的功能,符合RFC 7519 標準。
使用者可以透過簡訊或郵件服務取得 OTP,也可將此外掛用於使用者的註冊、登入及通行驗證等。使用前請確保已設定 WPENGINE 與常見的 PHP 設定,並在 wp-confige.php 檔案中添加常數。
如有任何支援或需求,請前往 Github: https://github.com/gauravin213/gs-jwt 查詢
原文外掛簡介
Extends the WP REST API using JSON Web Tokens as an authentication method.
GS JWT plugin provides to encode and decode JSON Web Tokens (JWT), conforming to RFC 7519.
GET OTP and send notification by mail or SMS service
Support and Requests please in Github: https://github.com/gauravin213/gs-jwt
REQUIREMENTS
PHP
Minimum PHP version: 5.3.0
PHP HTTP Authorization Header enable
Most of the shared hosting has disabled the HTTP Authorization Header by default.
To enable this option you’ll need to edit your .htaccess file adding the following
RewriteEngine on
RewriteCond %{HTTP:Authorization} ^(.*)
RewriteRule ^(.*) - [E=HTTP_AUTHORIZATION:%1]
WPENGINE
To enable this option you’ll need to edit your .htaccess file adding the following
SetEnvIf Authorization "(.*)" HTTP_AUTHORIZATION=$1
CONFIGURATION
The JWT needs to Add constant in the wp-confige.php file
define( 'GS_WP_JWT_SECRET_KEY', 'your-top-secret-key' );
define( 'GS_WP_JWT_ALGO', 'HS256' );
define( 'GS_WP_JWT_EXPIRY', (60 * 60) ); //seconds * minuts
define( 'GS_WP_OTP_EXPIRY', 10); //minuts
Namespace and Endpoints
When the plugin is activated, a new namespace is added
/gs-jwt/v1
Also, two new endpoints are added to this namespace
Endpoint | HTTP Verb
/wp-json/gs-jwt/v1/login | POST
/wp-json/gs-jwt/v1/token/validate | POST
/wp-json/gs-jwt/v1/get-otp | POST
/wp-json/gs-jwt/v1/verify-otp | POST
/wp-json/gs-jwt/v1/register_user | POST
/wp-json/gs-jwt/v1/register_userbymobile | POST
USAGE
Get JSON web token
Request method:
POST /wp-json/gs-jwt/v1/login
Body{
"username": "enter username",
"password": "enter password"
}
Reponse
{
"data": {
"id": "1",
"user_login": "admin",
"user_pass": null,
"user_nicename": "admin",
"user_email": "[email protected]",
"user_url": "",
"user_registered": "2020-08-11 07:35:37",
"user_activation_key": "",
"user_status": "0",
"display_name": "admin",
"roles": [
"administrator"
],
"token": "eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJpc3MiOiJodHRwOlwvXC8xMjcuMC4wLjFcL3dvcmRwcmVzcyIsImlhdCI6MTY0MTk3MDIwNSwibmJmIjoxNjQxOTcwMjA1LCJleHAiOjE2NDE5NzM4MDUsImRhdGEiOnsidXNlciI6eyJpZCI6IjEifX19.gRF_aNsmhQ8kqXYdKbm6dIA7zTlhcCU-e_cpP9pQDyM"
}
}
Validate JSON web token
Request method:
POST /wp-json/gs-jwt/v1/token/validate
Make a POST request sending the Authorization header
Authorization: Bearer eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJpc3MiOiJodHRwOlwvXC8xMjcuMC4wLjFcL3dvcmRwcmVzcyIsImlhdCI6MTY0MTk3MDIwNSwibmJmIjoxNjQxOTcwMjA1LCJleHAiOjE2NDE5NzM4MDUsImRhdGEiOnsidXNlciI6eyJpZCI6IjEifX19.gRF_aNsmhQ8kqXYdKbm6dIA7zTlhcCU-e_cpP9pQDyM
Reponse
{
"code": "jwt_auth_valid_token",
"data": {
"status": 200
}
}
Get otp by billing mobile number
Request method:
POST /wp-json/gs-jwt/v1/get-otp
Body{
"mobile": "enter mobile number"
}
Reponse
{
"data": {
"otp": 249225,
"message": "SUCCESS",
"otp_use_staus": "0",
"notification": {
"mail_send_status": 0,
"sms_send_status": 0
}
}
}
Verify otp and mobile number to login
Request method:
POST /wp-json/gs-jwt/v1/verify-otp
Body{
"otp": "enter otp",
"mobile": "enter mobile number"
}
Reponse
{
"data": {
"id": "1",
"user_login": "admin",
"user_pass": null,
"user_nicename": "admin",
"user_email": "[email protected]",
"user_url": "",
"user_registered": "2020-08-11 07:35:37",
"user_activation_key": "",
"user_status": "0",
"display_name": "admin",
"roles": [
"administrator"
],
"token": "eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJpc3MiOiJodHRwOlwvXC8xMjcuMC4wLjFcL3dvcmRwcmVzcyIsImlhdCI6MTY0MTk3MDIwNSwibmJmIjoxNjQxOTcwMjA1LCJleHAiOjE2NDE5NzM4MDUsImRhdGEiOnsidXNlciI6eyJpZCI6IjEifX19.gRF_aNsmhQ8kqXYdKbm6dIA7zTlhcCU-e_cpP9pQDyM"
}
}
Register user
Request method:
POST /wp-json/gs-jwt/v1/register_user
Body{
"username": "example",
"password": "example@123",
"email": "[email protected]",
"mobile": "1122336699"
}
Reponse
{
"data": {
"id": 29,
"user_login": "example",
"user_pass": null,
"user_nicename": "example",
"user_email": "[email protected]",
"user_url": "",
"user_registered": "2022-01-12 07:45:29",
"user_activation_key": "",
"user_status": "0",
"display_name": "example",
"roles": [
"customer"
],
"billing_phone": "1122336699"
},
"code": 200,
"message": "Registration was Successful"
}
Register user by mobile number
Request method:
POST /wp-json/gs-jwt/v1/register_userbymobile
Body{
"mobile": "1122336699"
}
Reponse
{
"data": {
"id": 32,
"user_login": "1144556638",
"user_nicename": "1144556638",
"user_registered": "2022-01-13 06:29:30",
"display_name": "1144556638",
"roles": [
"customer"
],
"billing_phone": "1144556638"
},
"code": 200,
"message": "Registration was Successful"
}
Sample add SMS and email notification
/*
* Send notification
* Default mail_send_status = 0, sms_send_status = 0
*/
function gs_wp_jwt_send_notification_fun( $data, $user_id, $otp, $mobile ) {
//Write mail send code here
$from = get_option('admin_email');
$to = get_user_meta($user_id, 'billing_email', true);
$subject = "OTP Verification";
$message = "OTP number: {$opt} will expire in 10 min";
$headers = "From: ".$from;
$result = wp_mail( $to, $subject, $message, $headers);
if ($result) {
$data['mail_send_status'] = 1;
} //end mail send
//Write sms send api code here
/*if ($sms_send_status) {
$data['sms_send_status'] = 1;
} //ens sms send*/
return $data;
}
add_filter( 'gs_wp_jwt_send_notification', 'gs_wp_jwt_send_notification_fun', 10, 4 );
各版本下載點
- 方法一:點下方版本號的連結下載 ZIP 檔案後,登入網站後台左側選單「外掛」的「安裝外掛」,然後選擇上方的「上傳外掛」,把下載回去的 ZIP 外掛打包檔案上傳上去安裝與啟用。
- 方法二:透過「安裝外掛」的畫面右方搜尋功能,搜尋外掛名稱「GS JWT Authentication for WP REST API」來進行安裝。
(建議使用方法二,確保安裝的版本符合當前運作的 WordPress 環境。
延伸相關外掛(你可能也想知道)
Google Authenticator 》WordPress 的 Google Authenticator 外掛使用 Google Authenticator App 為 Android/iPhone/Blackberry 手機提供雙因素驗證。, 如果您有安全意識,您可能已經...。
OTP Verification / Email Verification / SMS Verification / OTP Authentication / WooCommerce Notification 》SMS & EMAIL OTP VERIFICATION / WOOCOMMERCE SMS NOTIFICATION, OTP Verification 是一個 WordPress 外掛,它可以在註冊、登入和聯絡表單提交時,通過發送 O...。
WP SMS Plugin – WordPress SMS Two Factor Authentication – 2FA, Two Factor, OTP SMS and Email 》WordPress SMS Plugin: 如果你想在你的 WordPress 網站或應用程式中啟用簡訊(SMS)功能,這個外掛就是為此而創建的。它使用了市場上最好的簡訊解決方案之一 ...。
Login with phone number 》使用手機號碼註冊/登入, 新增功能:, 在手機號碼登入表單中新增了國旗圖示, 你可以自行免費添加幾乎所有的簡訊閘道(如果你有的話), 你可以更改表單的樣式和...。
Wawp – Order Notifications, OTP Login, Checkout Verifications and Country Code 》總結:使用WAWP.net Automation Web Platform外掛,可以透過WhatsApp或WhatsApp Business通知顧客有關訂單和遺棄購物車的資訊,還可以發送註冊新訂單的通知或...。
Two Factor Authentication (2FA , MFA, OTP SMS and Email) 》多因素驗證-雙重因素(2FA/OTP)-可以為任何基於 TOTP 的驗證方法(例如谷歌驗證器、Microsoft驗證器等)配置多因素驗證來保護您的WordPress網站。它還支持OTP通...。
Miniorange OTP Verification with Firebase 》SMS OTP 驗證 / Firebase 網關整合, 外掛程序允許用戶使用一次性密碼(OTP)進行登錄/註冊。此外掛使用Firebase 網關發送和驗證 OTP。通過啟用 OTP 驗證以消...。
WP-OTP 》使用 WP-OTP 外掛您可以輕鬆地為 WordPress 登入啟用一次性密碼的雙因素驗證。, 這額外的安全層可提高您的 WordPress 網站安全性。, 新的隱形模式允許您在輸...。
OTP Authenticator 》此外掛可在 WordPress 網站中加入雙因子認證、無密碼認證和帳戶驗證等重要功能。其主要特色包括:, , , 三種一次性密碼模式:雙因子認證、無密碼認證和帳戶驗...。
OTP by Email for Contact Form 7 》使用這個 CF7 外掛擴充功能,可讓 OTP 連結被插入至發送到 CF7 表單提交的電子郵件地址的確認/通知電子郵件中。 OTP 是電子郵件收件者需要點擊以確認他們的地...。
Akay Digits Add-on 》افزونه مکمل دیجیتس آکای یک ابزار حرفهای و پیشرفته برای ارتقای عملکرد افزونه اورجینال Digits است که با اکثر سامانههای پیامکی ایرانی کاملاً سازگار ...。
WooCommerce Advanced Accounts – Email / Phone Verification / OTP Login 》**總結:** , Advanced Accounts – Email / Phone Verifications / OTP Login for WooCommerce 是一個強大的 WooCommerce 擴充功能,旨在通過添加...。
VinCSS FIDO2 Login 》VinCSS FIDO2登錄能幫助您使用設備如USB安全鍵、指紋、Windows Hello、FaceID/TouchID等來替代您的密碼。插件也支援2FA和OAuth2協議。, 啟用插件後,您即可在...。
WP Verify API 》注意:這個外掛是專為 WordPress 開發人員設計,對於初學者可能會有些困惑。, 此外掛透過 WordPress API 生成驗證碼並發送至指定電子郵件信箱。, 然後您可以...。
Token2 Hardware Tokens 》這款 WordPress Token2 硬體令牌外掛可以使用 Token2 硬體令牌實現雙重認證。, 站點管理員可以根據用戶的需要,啟用逐用戶的雙重認證需求。。