クイックスタート
-
招待を受け入れます。 Tenon IT が、組織の最初の管理者に
https://admin.glow-kin.com/console/invite/…のリンクを送ります。開いてパスワードを決め、ご自身の2段階認証を設定してください。リンクは72時間以内に1回だけ使えます。 -
アプリケーションと API キーを作成します。 管理コンソールで:
- アプリケーションからアプリケーションを追加します(例:「顧客ポータル」)。
- API キーを作成してコピーします。
tnk_で始まり、表示は1回だけです。
キーはサーバーのシークレット設定に保管し、ブラウザーやモバイルアプリには絶対に入れないでください。アプリケーションごとに別のキーを使い、いつでも新しいキーを作って古いキーを無効にできます。
-
サーバーの言語の SDK をインストールし(ダウンロード)、アドレスとキーでクライアントを1つ作ります:
TenonAuthClient tenonAuth = TenonAuthClient.builder().baseUrl("https://api.glow-kin.com").apiKey(System.getenv("TENON_AUTH_API_KEY")).build();import { TenonAuthClient } from '@tenon-auth/sdk';const tenonAuth = new TenonAuthClient({ baseUrl: 'https://api.glow-kin.com', apiKey: process.env.TENON_AUTH_API_KEY! });from tenon_auth import TenonAuthClienttenon_auth = TenonAuthClient("https://api.glow-kin.com", os.environ["TENON_AUTH_API_KEY"])var tenonAuth = new TenonAuthClient(new TenonAuthClientOptions{BaseUrl = "https://api.glow-kin.com",ApiKey = builder.Configuration["TenonAuth:ApiKey"],}); -
ユーザーが方法を設定できるようにします。 設定画面で、認証アプリのコード、ログイン承認、または(管理者が許可していれば)メールのコードを選べるようにし、設定後にリカバリーコードを1回だけ表示します。方法の設定を参照してください。
-
パスワードの確認の直後に、2段階目を追加します:
SecondStep step = tenonAuth.beginSecondStep(account.id(), new SignInContext(clientIp, userAgent));session.setAttribute("secondStep", step);// CODE_ENTRY:コード入力画面へ。PUSH_WAIT:step.number() を表示して待つ。// TRUSTED または NO_METHOD:ログイン(NO_METHOD は先に設定を求めてもかまいません)。// コード入力画面のフォーム:if (tenonAuth.completeWithCode(step, code).approved()) signIn(account);const step = await tenonAuth.beginSecondStep(account.id, { context: { ipAddress: req.ip, userAgent: req.get('user-agent') } });req.session.secondStep = step;// CODE_ENTRY:コード入力画面へ。PUSH_WAIT:step.number を表示して待つ。// コード入力画面のフォーム:if ((await tenonAuth.completeWithCode(req.session.secondStep, req.body.code)).approved) signIn(account);step = tenon_auth.begin_second_step(str(account.id), SignInContext(client_ip, user_agent))session["second_step"] = step.to_dict()# CODE_ENTRY:コード入力画面へ。PUSH_WAIT:step.number を表示して待つ。# コード入力画面のフォーム:if tenon_auth.complete_with_code(SecondStep.from_dict(session["second_step"]), form["code"]).approved:sign_in(account)var step = await tenonAuth.BeginSecondStepAsync(account.Id.ToString(), new SignInContext(ip, userAgent));HttpContext.Session.SetString("SecondStep", JsonSerializer.Serialize(step));// CodeEntry:コード入力画面へ。PushWait:step.Number を表示して待つ。// コード入力画面のフォーム:if ((await tenonAuth.CompleteWithCodeAsync(step, form.Code)).Approved) SignIn(account);
続けて、作る画面についてログインを、障害時の扱いについてTenon-Auth に接続できないときを読んでください。どのアプリケーションも、接続できないときはログインを拒否(フェイルクローズ)する必要があります。