Documentation Index
Fetch the complete documentation index at: https://auth0-feat-ionic-capacitor-quickstart-modernization.mintlify.app/llms.txt
Use this file to discover all available pages before exploring further.
Gigya、Okta、StormpathからAuth0にユーザーを移行するためのサンプルシナリオをいくつか示します。これらの各シナリオでは、それらのプラットフォームにアカウントがあることを前提としています。
前提条件
カスタムデータベース接続を構成します。
- Dashboard>Authentication>Databaseでデータベース接続を作成します。必ず [Custom Database(カスタムデータベース)] ビューを選択し、[Use my own database(独自のデータベース)] を使用するスイッチを有効にしてください。
- データベースをアプリケーションに接続します:データベース接続設定で、アプリケーション ビューを選択します。この接続を使用しているアプリケーション セクションを見つけて、各アプリケーションのデータベース接続を有効にします。
シナリオ1:GigyaからAuth0へのユーザー移行
-
Gigyaユーザーをエクスポート:GigyaのIdentitySyncを使用して、ユーザーデータを変換し、ターゲットスキーマに合わせてエクスポートします。このプロセスの詳細については、Gigya IdentitySync:Using IdentitySyncを参照してください。
指示に従って、Gigyaデータベースのユーザーデータを正しい[schema(スキーマ)]に変換し、変換されたデータをJSON形式でエクスポートします。
-
GigyaユーザーをAuth0にインポートします。ユーザーインポート/エクスポート拡張または[Management API]を使用してユーザーをインポートできます。
-
[User Import/Export Extension(ユーザーインポート/エクスポート拡張)]:Auth0 Dashboard>Extensionsへ移動し、[User Import / Export(ユーザーインポート/エクスポート)] 拡張を選択し、インストールします。拡張がインストールされたら、それをクリックしてインポート/エクスポートインターフェイスを開くことができます。
エクスポートしたGigyaユーザーのJSONファイルを指定されたアップロード領域にドラッグし、先ほど作成したデータベースを選択します。インポートを開始するには、ユーザーのインポートの開始 を選択します。詳細については、ユーザーのインポート/エクスポート拡張を参照してください。
-
Management API:ユーザーをAuth0にインポートするジョブを作成します。詳細な手順については、[一括ユーザーインポート]を参照してください。
シナリオ2:OktaからAuth0へのユーザー移行
-
ユーザーのインポートを有効にする:Auth0 Dashboard>Authentication>Databaseに移動し、データベース接続を選択します。[Settings(設定)] で、[Import Users to Auth0(Auth0 にユーザーをインポート)] オプションを有効にします。
-
ログインスクリプトを作成する:[Login(ログイン)] スクリプトは、ユーザーがログインしようとしたときに、そのアカウントがAuth0データベースに見つからない場合に実行されます。メールとパスワードを
usernameおよびpasswordのパラメータとして渡して、Oktaプライマリ認証エンドポイントを呼び出すスクリプトを作成する必要があります。認証が成功すると、Oktaは埋め込みリソース内のユーザーのプロファイルを含む認証トランザクションオブジェクトを返します。その後、ユーザーの情報を抽出し、コールバック関数でAuth0に渡すことができます。
データベース接続の [Custom Database(カスタムデータベース)] ビューで、 [Database Action Scripts(データベースアクションスクリプト)] を見つけて、Login(ログイン)] を選択します。
function login (email, password, callback) {
// Replace {yourOktaDomain} with your own Okta domain
var url = 'https:/{yourOktaDomain}/api/v1/authn';
// Make the POST request to authenticate a user
request({
url: url,
method: 'POST',
headers: {
'Content-Type': 'application/json',
'Accept': 'application/json'
},
body: {
username: email,
password: password,
options: {
multiOptionalFactorEnroll: false,
warnBeforePasswordExpired: false
}
},
json: true
}, function (error, response, body) {
// Ensure we have a successful response
if (response.statusCode !== 200) return callback();
// Get the user from the response body
var user = body._embedded.user;
// Set the data we want to store in Auth0 and migrate the user
return callback(null, {
user_id : user.id,
username: user.profile.login,
email: user.profile.login,
// We set the users email_verified to true as we assume if they were a valid
// user in Okta, they have already verified their email
// If this field is not set, the user will get an email asking them to verify
// their account
email_verified: true,
name: user.profile.firstName + ' ' + user.profile.lastName
});
});
}
スクリプトが機能するかどうかをテストするには、スクリプトの上にある**[Try(試す)]**ボタンをクリックします。
-
ユーザー取得スクリプトを作成します:[Get User(ユーザー取得)] スクリプトは、ユーザーがパスワードをリセットしようとしたが、Auth0データベースにそのアカウントが見つからない場合に実行されます。ユーザーのメールアドレスを
loginパラメータとして渡して、Oktaログインでユーザー取得エンドポイントを呼び出すスクリプトを作成する必要があります。また、Authorizationヘッダーでこのエンドポイントに渡す必要があるAPI トークンを作成する必要があります。成功した場合、Oktaはユーザーの情報を含むユーザーオブジェクトを返します。ここでも、ユーザーの情報を抽出し、コールバック関数でAuth0に渡すことができます。
データベース接続の [Custom Database(カスタムデータベース)] ビューで、[Database Action Scripts(データベースアクションスクリプト)] を見つけて、[Get User(ユーザーの取得)] を選択します。
function getByEmail(email, callback) {
// Replace {yourOktaDomain} with your own Okta domain
var url = 'https://{yourOktaDomain}/api/v1/users/' + encodeURIComponent(email);
// Make a GET request to find a user by email
// Replace {yourOktaApiToken} with an Okta API Token
// (see https://developer.okta.com/docs/api/getting_started/getting_a_token.html)
request({
url: url,
method: 'GET',
headers: {
'Content-Type': 'application/json',
'Accept': 'application/json',
'Authorization': 'SSWS ' + '{yourOktaApiToken}'
},
json: true
}, function (error, response, body) {
// Ensure we have a successful response
if (response.statusCode !== 200) return callback();
// Set the data we want to store in Auth0 and migrate the user
return callback(null, {
user_id: body.id,
username: body.profile.login,
email: body.profile.login,
email_verified: true,
name: body.profile.firstName + ' ' + body.profile.lastName
});
});
}
スクリプトが機能するかどうかをテストするには、スクリプトの上にある [Try(試す)] ボタンをクリックします。
-
カスタムデータベース接続をテストします:[Try connection(接続を試す)] をクリックします。Auth0 Lockウィジェットが表示されます。Oktaユーザーのメールアドレスとパスワードを入力し、(Log In(ログイン)] をクリックします。接続が機能していることを示すWebページと、ユーザーに関する情報が表示されます。
-
新しくインポートされたユーザーを確認するには、Auth0 Dashboard>User Management>Usersへ移動します。
シナリオ3:StormpathからAuth0にユーザーを移行する
-
ユーザーのインポートを有効にする:Auth0 Dashboard>Authentication>Databaseに移動し、データベース接続を選択します。[Settings(設定)] で、[Import Users to Auth0(Auth0 にユーザーをインポート)] オプションを有効にします。
-
接続用のアプリケーションを有効にします:[Applications(アプリケーション)] ビューを選択します。データベース接続を使用するアプリケーションを有効にします。
-
ログインスクリプトを作成する:[Login(ログイン)] スクリプトは、ユーザーがログインしようとしたときに、そのアカウントがAuth0データベースに見つからない場合に実行されます。ユーザーを認証するためにStormpathのAPIを呼び出すスクリプトを作成し、
usernameとpasswordのパラメータとしてユーザーの資格情報を渡す必要があります。
認証が成功すると、Stormpathからの応答にユーザーアカウントURLが含まれます。ユーザーの情報を取得するには、アカウントURLに対して2回目の要求を実行します。その後、ユーザーの情報を抽出し、コールバック関数でAuth0に渡すことができます。
function login(username, password, callback) {
// Replace the {yourStormpathClientId} attribute with your Stormpath ID
var url = 'https://api.stormpath.com/v1/applications/{yourStormpathClientId}/loginAttempts';
// Stormpath requires the user credentials be passed in as a base64 encoded message
var message = username + ':' + password;
var pass = new Buffer(message).toString('base64');
// Here we are making the POST request to authenticate a user
request({
url: url,
method: 'POST',
auth: {
// Your API Client ID
user: '{yourStormpathClientId}',
// Your API Client Secret
password: '{yourStormpathClientSecret}'
},
headers: {
'Content-Type': 'application/json'
},
json: {
type: 'basic',
// Passing in the base64 encoded credentials
value: pass
}
}, function (error, response, body) {
// If response is successful we'll continue
if (response.statusCode !== 200) return callback();
// A successful response will return a URL to get the user information
var accountUrl = body.account.href;
// We'll make a second request to get the user info. This time it will be a GET request
request({
url: accountUrl,
method: 'GET',
auth: {
// Your API Client ID
user: '{yourStormpathClientId}',
// YOUR API Client Secret
password: '{yourStormpathClientSecret}'
}
}, function (errorUserInfo, responseUserInfo, bodyUserInfo) {
// If we get a successful response, we'll process it
if (responseUserInfo.statusCode !== 200) return callback();
var parsedBody = JSON.parse(bodyUserInfo);
// To get the user identifier, we'll strip out the Stormpath API
var id = parsedBody.href.replace('https://api.stormpath.com/v1/accounts/', '');
// Finally, we'll set the data we want to store in Auth0 and migrate the user
return callback(null, {
user_id : id,
username: parsedBody.username,
email: parsedBody.email,
// We set the users email_verified to true as we assume if they were a valid
// user in Stormpath, they have already verified their email
// If this field is not set, the user will get an email asking them to verify
// their account
email_verified: true,
// Add any additional fields you would like to carry over from Stormpath
});
});
});
}
スクリプトの上にある [Try(試す)] ボタンをクリックして、スクリプトが機能するかどうかをテストして確認します。
-
ユーザー取得スクリプトを作成します:[Get User(ユーザー取得)] スクリプトは、ユーザーがパスワードのリセットを試みたものの、Auth0データベース内にそのアカウントが見つからない場合に実行されます。Stormpath APIの
/accountsエンドポイントを呼び出し、ユーザーのメールアドレスをemailパラメータとして渡すスクリプトを作成する必要があります。成功した場合、Stormpathはユーザーの情報を返します。ユーザーの情報を抽出し、コールバック関数でAuth0に渡すことができます。
function getByEmail(email, callback) {
// Replace the {yourStormpathClientId} attribute with your Stormpath ID
var url = 'https://api.stormpath.com/v1/applications/{yourStormpathClientId}/accounts';
request({
url: url,
method: 'GET',
auth: {
// Your API Client ID
user: '{yourStormpathClientId}',
// YOUR API Client Secret
password: '{yourStormpathClientSecret}'
},
qs: { q: email }
}, function (error, response, body) {
if (response.statusCode !== 200) return callback();
var parsedBody = JSON.parse(body);
var user = parsedBody.items[0];
if (!user) return callback();
var id = user.href.replace('https://api.stormpath.com/v1/accounts/', '');
return callback(null, {
user_id: id,
username: user.username,
email: user.email,
email_verified: true,
// Add any additional fields you would like to carry over from Stormpath
});
});
}
スクリプトの上にある [Try(試す)] ボタンをクリックして、スクリプトが機能するかどうかをテストして確認します。
-
カスタムデータベース接続をテストします:[Try connection(接続を試す)] をクリックします。Auth0 Lockウィジェットが表示されます。Stormpathユーザーのメールアドレスとパスワードを入力し、(Log In(ログイン)] をクリックします。接続が機能していることを示すWebページと、ユーザーに関する情報が表示されます。
-
新しくインポートされたユーザーを確認するには、Dashboard>User Management>Usersに移動します。