Struct Auth

Source
pub struct Auth { /* private fields */ }
Expand description

Auth クライアント

Implementations§

Source§

impl Auth

Source

pub fn new( url: &str, key: &str, http_client: Client, options: AuthOptions, ) -> Self

新しい Auth クライアントを作成

Source

pub fn init_admin(&mut self, service_role_key: &str) -> &Self

管理者用APIクライアントを初期化

§引数
  • service_role_key - サービスロールキー(重要: クライアント側では使用せず、サーバー側でのみ使用する)
§
let auth = auth.init_admin("your-service-role-key");
Source

pub fn admin(&self) -> Option<&AdminAuth>

管理者用APIクライアントを取得

§
if let Some(admin) = auth.admin() {
    // Use admin API here
    // let users = admin.list_users(None, None).await?;
}
Source

pub async fn sign_up( &self, email: &str, password: &str, ) -> Result<Session, AuthError>

ユーザー登録

Source

pub async fn sign_in_with_password( &self, email: &str, password: &str, ) -> Result<Session, AuthError>

メール・パスワードでログイン

Source

pub fn get_session(&self) -> Option<Session>

現在のセッションを取得

Source

pub async fn get_user(&self) -> Result<User, AuthError>

現在のユーザーを取得

Source

pub async fn refresh_session(&self) -> Result<Session, AuthError>

セッションをリフレッシュ

Source

pub async fn sign_out(&self) -> Result<(), AuthError>

サインアウト

Source

pub async fn reset_password_for_email( &self, email: &str, ) -> Result<(), AuthError>

パスワードリセットメールの送信

Source

pub fn get_oauth_sign_in_url( &self, provider: OAuthProvider, options: Option<OAuthSignInOptions>, ) -> String

OAuth プロバイダを通じたサインインのためのURL生成

Source

pub async fn sign_in_with_oauth( &self, provider: OAuthProvider, options: Option<OAuthSignInOptions>, ) -> Result<String, AuthError>

OAuthで認証をリクエスト

Source

pub async fn exchange_code_for_session( &self, code: &str, ) -> Result<Session, AuthError>

OAuthコールバックからのコードを処理してセッション取得

Source

pub async fn sign_in_with_password_mfa( &self, email: &str, password: &str, ) -> Result<Result<Session, MFAChallenge>, AuthError>

MFAで保護されたサインイン - 最初のステップ(パスワードでの認証)

このメソッドは通常のサインインプロセスと同様ですが、ユーザーが MFAを有効化している場合は、次のステップで検証が必要なチャレンジを返します。

Source

pub async fn verify_mfa_challenge( &self, challenge_id: &str, code: &str, ) -> Result<Session, AuthError>

MFAチャレンジの検証 - 第二ステップ(コードによる検証)

Source

pub async fn enroll_totp(&self) -> Result<TOTPSetupInfo, AuthError>

MFAファクターを登録する

Source

pub async fn verify_totp( &self, factor_id: &str, code: &str, ) -> Result<MFAFactor, AuthError>

TOTP MFAファクターを検証して有効化

Source

pub async fn list_factors(&self) -> Result<Vec<MFAFactor>, AuthError>

ユーザーの登録済みMFAファクター一覧を取得

Source

pub async fn unenroll_factor(&self, factor_id: &str) -> Result<(), AuthError>

MFAファクターを無効化(削除)

Source

pub async fn sign_in_anonymously(&self) -> Result<Session, AuthError>

匿名認証でサインイン

Source

pub async fn send_confirm_email_request( &self, email: &str, options: Option<EmailConfirmOptions>, ) -> Result<(), AuthError>

メール確認のリクエストを送信する

§Arguments
  • email - 確認メールを送信するメールアドレス
  • options - オプション設定(リダイレクトURLなど)
§Example
let options = EmailConfirmOptions {
    redirect_to: Some("https://example.com/confirm-success".to_string()),
};

auth.send_confirm_email_request("user@example.com", Some(options)).await?;
Source

pub async fn verify_email(&self, token: &str) -> Result<Session, AuthError>

メール確認トークンを検証する

§Arguments
  • token - メール確認用のトークン(確認リンクから取得)
§Example
let session = auth.verify_email("confirmation-token-from-email").await?;
println!("Email verified for user: {:?}", session.user.email);
Source

pub async fn verify_password_reset( &self, token: &str, new_password: &str, ) -> Result<Session, AuthError>

パスワードリセット後にリセットトークンを検証する

§Arguments
  • token - パスワードリセット用のトークン(リセットリンクから取得)
  • new_password - 新しいパスワード
§Example
let session = auth.verify_password_reset("reset-token-from-email", "new-secure-password").await?;
println!("Password reset for user: {:?}", session.user.email);
Source

pub async fn send_verification_code( &self, phone: &str, ) -> Result<PhoneVerificationResponse, AuthError>

Source

pub async fn verify_phone_code( &self, phone: &str, verification_id: &str, code: &str, ) -> Result<Session, AuthError>

電話番号と検証コードでサインイン

Auto Trait Implementations§

§

impl Freeze for Auth

§

impl !RefUnwindSafe for Auth

§

impl Send for Auth

§

impl Sync for Auth

§

impl Unpin for Auth

§

impl !UnwindSafe for Auth

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T> Instrument for T

Source§

fn instrument(self, span: Span) -> Instrumented<Self>

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
Source§

fn in_current_span(self) -> Instrumented<Self>

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
Source§

impl<T> WithSubscriber for T

Source§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

impl<T> ErasedDestructor for T
where T: 'static,

Source§

impl<T> MaybeSendSync for T