とあるpayアプリで話題になってる二段階認証(二要素認証)今だからこそTwilioで試して見ようと思います。
AUTHY_API_KEYの調べ方
新規ユーザー登録
request
curl "https://api.authy.com/protected/json/users/new" \
-H "X-Authy-API-Key: [AUTHY_API_KEY]" \
-d user[email]=your email address \
-d user[cellphone]=90xxxxxxxx \
-d user[country_code]=81
response
{
"message": "ユーザーの作成に成功しました。",
"user": {
"id": <userId>
},
"success": true
}
ユーザー確認用SMS送信
request
curl https://api.authy.com/protected/json/sms/<userId>?force=true -H "X-Authy-API-Key: [AUTHY_API_KEY]"
response
{
"success": true,
"message": "SMS token was sent",
"cellphone": "+81-XXX-XXX-XXXX"
}
ユーザー確認
request
curl https://api.authy.com/protected/json/verify/<SMSで届いた認証コード>/<userId> -H "X-Authy-API-Key: [AUTHY_API_KEY]"
response
{
"message": "Token is valid.",
"token": "is valid",
"success": "true",
"device": {
"id": null,
"os_type": "sms",
"registration_date": 1562338290,
"registration_method": null,
"registration_country": null,
"registration_region": null,
"registration_city": null,
"country": null,
"region": null,
"city": null,
"ip": null,
"last_account_recovery_at": null,
"last_sync_date": null
}
}
まとめ
なんと3APIで二段階認証が実装できます!
今だからこそ導入を検討してみてください。
webアプリサンプル
node.jsで書かれたサンプルをdockerで動くように改良しました!
それ使えばすぐにAuthy試せるのでお試しください!