logologo
スタート
マニュアル
開発
プラグイン
API
English
简体中文
日本語
한국어
Deutsch
Français
Español
Português
Русский
Italiano
Türkçe
Українська
Tiếng Việt
Bahasa Indonesia
ไทย
Polski
Nederlands
Čeština
العربية
עברית
हिन्दी
Svenska
スタート
マニュアル
開発
プラグイン
API
logologo

ユーザー認証

概要
認証器管理

認証タイプ

パスワード
SMS

OIDC

設定

サンプル

Google ログイン
Microsoft ログイン

SAML

設定

サンプル

Google ログイン
LDAP
CAS
企業微信
DingTalk
API キー

開発ガイド

拡張認証タイプ
API リファレンス

検証

概要

検証タイプ

SMS
TOTP 認証器

開発ガイド

拡張検証タイプ
拡張検証シナリオ
拡張SMSプロバイダー
API リファレンス
2要素認証 (2FA)
Previous Page拡張認証タイプ
Next Page概要
TIP

このドキュメントはAIによって翻訳されました。不正確な情報については、英語版をご参照ください

#API リファレンス

#サーバーサイド

#Auth

コア API です。詳細は Auth を参照してください。

#BaseAuth

コア API です。詳細は BaseAuth を参照してください。

#AuthModel

#概要

AuthModel は NocoBase アプリケーションで利用される認証器 (Authenticator、詳細は AuthManager - setStorer および Auth - constructor を参照) のデータモデルです。ユーザーデータ コレクションとやり取りするためのいくつかのメソッドを提供します。これに加えて、Sequelize Model が提供するメソッドも利用できます。

import { AuthModel } from '@nocobase/plugin-auth';

class CustomAuth extends BaseAuth {
  async validate() {
    // ...
    const authenticator = this.authenticator as AuthModel;
    this.authenticator.findUser();
    this.authenticator.newUser();
    this.authenticator.findOrCreateUser();
    // ...
  }
}

#クラスメソッド

  • findUser(uuid: string): UserModel - uuid を使ってユーザーを検索します。

    • uuid - 現在の認証タイプに紐づくユーザーの一意な識別子
  • newUser(uuid: string, userValues?: any): UserModel - 新しいユーザーを作成し、uuid を使ってユーザーを現在の認証器に紐付けます。

    • uuid - 現在の認証タイプに紐づくユーザーの一意な識別子
    • userValues - オプション。その他のユーザー情報です。渡されない場合、uuid がユーザーのニックネームとして使用されます。
  • findOrCreateUser(uuid: string, userValues?: any): UserModel - ユーザーを検索するか、新しいユーザーを作成します。作成ルールは上記と同じです。

    • uuid - 現在の認証タイプに紐づくユーザーの一意な識別子
    • userValues - オプション。その他のユーザー情報です。

#クライアントサイド

#plugin.registerType()

認証タイプのクライアントを登録します。

import AuthPlugin from '@nocobase/plugin-auth/client';

class CustomAuthPlugin extends Plugin {
  async load() {
    const auth = this.app.pm.get(AuthPlugin);
    auth.registerType('custom-auth-type', {
      components: {
        SignInForm,
        // SignInButton
        SignUpForm,
        AdminSettingsForm,
      },
    });
  }
}

#シグネチャ

  • registerType(authType: string, options: AuthOptions)

#型

export type AuthOptions = {
  components: Partial<{
    SignInForm: ComponentType<{ authenticator: AuthenticatorType }>;
    SignInButton: ComponentType<{ authenticator: AuthenticatorType }>;
    SignUpForm: ComponentType<{ authenticatorName: string }>;
    AdminSettingsForm: ComponentType;
  }>;
};

#詳細

  • SignInForm - サインインフォーム
  • SignInButton - サインイン(サードパーティ)ボタン。サインインフォームの代替として利用できます。
  • SignUpForm - サインアップフォーム
  • AdminSettingsForm - 管理者設定フォーム

#ルート

Auth プラグインが登録するフロントエンドのルートは以下の通りです。

  • Auth レイアウト

    • name: auth
    • path: -
    • component: AuthLayout
  • サインインページ

    • name: auth.signin
    • path: /signin
    • component: SignInPage
  • サインアップページ

    • name: auth.signup
    • path: /signup
    • component: SignUpPage