AuthAgent

モジュールパス: /alier_sys/Auth.js

--- config: class: hideEmptyMembersBox: true --- classDiagram direction LR IAuthAgent <|-- AuthAgent link IAuthAgent "./iauthagent"

概要


ログインなどの認証処理を行うクラスです。

コンストラクタ

構文

new AuthAgent(args)
new AuthAgent({ id, protocols })
new AuthAgent({ id, protocols, nextProtocol })
new AuthAgent({ id, protocols, selectProtocol })
new AuthAgent({ id, protocols, selectProtocol, nextProtocol })

引数

  • args: { id, protocols[, selectProtocol][, nextProtocol] }

    以下のプロパティを持つオブジェクトです。

    • id: string

    認証エージェントの保存、取得の際に使用される識別子です。

    • protocols: IAuthProtocol | [ ... ] | { ... }

      実行する認証プロトコルです。渡されるものの型によってどのように実行されるかが決まります。

      • IAuthProtocol

        渡されたプロトコルを実行します。

      • [IAuthProtocol, IAuthProtocol | { [name: string]: IAuthProtocol}]

        長さ2の配列の場合は2つのプロトコルを順番に実行します。2つ目はオブジェクトリテラルにして選択可能にすることもできます。

      • { [name: string]: IAuthProtocol | [IAuthProtocol, { [name: string]: IAuthProtocol }] }

        オブジェクトリテラルの場合は selectProtocol で決められたプロトコルが実行されます。プロパティはプロトコル単体か長さ2の配列になります。

    • selectProtocol: ((envelope: Envelope) => string)?

      protocols がオブジェクトだった時に実行するプロトコルを決定するコールバックです。envelope は選択したプロトコル名をエージェントに渡すための Envelope です。

    • nextProtocol: ((info: any) => string)?

      配列の2番目がオブジェクトだった時に実行するプロトコルを決定するコールバックです。info は1番目に実行したプロトコルで得られた情報です。

メソッド


login()

  • ログイン処理を実行します。

logout()

  • ログアウト処理を実行します。

refresh()

  • 可能であれば認証情報を再取得します。WebApi 内で使用されるもので、開発者はこのメソッドを呼ぶ必要はありません。

getHeaders()

  • リクエストから認証ヘッダを生成します。

プロパティ


id

このプロパティは読み取り専用です。

認証エージェントを保存、取得するときに使用される識別子です。

string


isLoggedIn

このプロパティは読み取り専用です。

ログインであるかどうかを表すゲッターです。

boolean