この記事の目次
2要素認証とは?

2要素認証設定時の注意点

Salesforceでの2要素認証設定方法

Salesforce Authenticatorを利用した2要素認証
Salesforce Authenticatorとは、モバイルデバイスのアプリで、このアプリを利用することで、モバイルデバイスを利用した2要素認証が可能になります。 新しくなったバージョンでは、より簡単に2要素認証が行えるようになり、利便性の向上が図られています。1.Salesforceで2要素認証を有効にする
Salesforceで2要素認証を有効にする手順を紹介します。 1.管理者としてログインし、[設定]から、[クイック検索]ボックスで「プロファイル」と検索し、[プロファイル]を選択します。 2.[セッションの設定]までスクロールし、[ログインに必要なセッションセキュリティレベル]という設定をクリックします。さらに、その中にある[編集]をクリックし、[高保証]を選択します。 3.[保存]をクリックします。その後、再び[設定]に戻り、[クイック検索]ボックスに「セッションの設定」と入力し、[セッションの設定」を選択します。 4.[セッションセキュリティレベル]で、[高保証]列が[多要素認証]となっていることを確認し、変更内容を保存します。2.Salesforce Authenticatorへのアカウント接続
Salesforce Authenticatorへのアカウント接続の手順を紹介します。 1.モバイルデバイスにSalesforce Authenticatorのアプリをダウンロード、インストールします。すでにインストールされている場合は、バージョンが最新のものになっているか確認し、最新のものでなければ、アップデートします。 2.ブラウザ上のSalesforceのページから、[個人設定]を探し、[クイック検索]ボックスに「高度なユーザーの詳細」と入力、選択します。もし見つからなければ、[クイック検索]検索ボックスに「個人情報」と入力し、[個人情報]を選択します。 3.[アプリケーション登録:Salesforce Authenticator]を探し、[接続]をクリックすると、アカウントへのログインを催促されるため、ここで一度ブラウザは止めておきます。 4.モバイルデバイスでSalesforce Authenticatorのアプリを開き、[アカウント追加]をクリックしてアカウントの追加を行います。すると、一意の2語の語句が生成されるため、止めておいたブラウザにこの語句を入力し、[接続]をクリックします。 5.モバイルデバイス上のSalesforce Authenticatorアプリに、接続したアカウントの詳細が表示されます。最後にアプリ側で[接続]をクリックして完了です。Apexを使用した2要素認証の設定
2要素認証プロセスを実装するには、System.UserManegement クラスでApexメソッドを使用します。 このメソッドでは、メール、電話(SMS)、Salesforce Authenticatorの検証方法をペアにして、一方で検証サービスを始めて、もう一方の検証サービスを終えることで完了します。 使用するApex設定は検証方法によって異なります。 メール、SMS、Salesforce Authenticatorの検証方法を使用する2要素認証サービスを実装する場合は、initVerificationMethodとverifyVerificationMethodを使用します。 パスワードまたはTOTP検証方法を使用する多要素認証サービスを実装する場合は、verifyVerificationMethodを使用して検証します。Apexコード例
以下がメールを使用した2要素認証のApexのコード例です。public void initVerification() {
// user will receive code on their registered verified email
identifier = UserManagement.initVerificationMethod(Auth.VerificationMethod.EMAIL);
}
public Auth.VerificationResult verifyVerification() {
// requiring identifier from the initVerification
// the code will need to be entered in this method
return UserManagement.verifyVerificationMethod(identifier, code , Auth.VerificationMethod.EMAIL);
}
以下がSMSを使用した2要素認証のコード例です。
public void initVerification() {
// user will receive code on their registered verified phone
identifier = UserManagement.initVerificationMethod(Auth.VerificationMethod.SMS);
}
public Auth.VerificationResult verifyVerification() {
// requiring identifier from the initVerification
// the code will need to be entered in this method
return UserManagement.verifyVerificationMethod(identifier, code , Auth.VerificationMethod.SMS);
}
以下がSalesforce Authenticatorを使用した2要素認証のコード例です。
public void initVerification() {
// user will receive push notification on mobile device where the app is registered for MFA
identifier = UserManagement.initVerificationMethod(Auth.VerificationMethod.SALESFORCE_AUTHENTICATOR);
}
public Auth.VerificationResult verifyVerification() {
// requiring identifier from the initVerification
// user will need to take the action on the mobile device where the app is registered for MFA
return UserManagement.verifyVerificationMethod(identifier, '' , Auth.VerificationMethod.SALESFORCE_AUTHENTICATOR);
}
以下の2つは、パスワード検証やTOTP検証にverifyVerificationMethodのみを使用する2要素認証のApexコード例です。
public Auth.VerificationResult verifyVerification() {
// user will enter their password as a param in the verifyVerificationMethod for password verification method
return UserManagement.verifyVerificationMethod('', password , Auth.VerificationMethod.PASSWORD);
}
public Auth.VerificationResult verifyVerification() {
// user will enter their registered time-based one-time password (TOTP) code (token)
return UserManagement.verifyVerificationMethod('', code , Auth.VerificationMethod.TOTP);
}