Class AuthBackendAbstract

Backend that supports authentication.

Hierarchy (view full)

Constructors

Properties

data: any
options: any
permissions: any
rawData: string
ref: any
source: string
user: any
_all: any[] = []
api: {
    user: {
        get: string;
    };
} = ...

Type declaration

  • user: {
        get: string;
    }
    • get: string
authProvider: string = "https://auth.madata.dev"

Auth Provider to use. This is only relevant for OAuthBackend, but specifying here as Backend is the only class users import.

capabilities: {
    auth: boolean;
} = ...

Type declaration

  • auth: boolean
defaultFormat: string = "JSON"
defaultPermissions: {
    login: boolean;
} = ...

Type declaration

  • login: boolean
hooks: Hooks = hooks
phrases: {
    authentication_error: string;
} = ...

Type declaration

  • authentication_error: string

Accessors

  • get authProviderServices(): Promise<any>
  • services.json from the auth provider will be cached here. You could also set this manually to avoid the network request.

    Returns Promise<any>

    Member

  • get host(): any
  • Return the hostname of the first URL pattern in the urls array, if not variable. This is used to facilitate relative URLs when constructing Backends directly. Subclasses with variable hostnames can override this.

    Returns any

  • get title(): string
  • Returns string

Methods

  • Abstract

    Show authentication UI to the user. Must be implemented by subclasses.

    Returns Promise<void>

  • Abstract

    Delete any info used to log users in passively.

    Returns void

  • Low-level method to fetch data from the backend. Subclasses should override this method. Clients should not call this method directly, but use load() instead.

    Parameters

    • ref: any = ...

      reference to data to fetch, if different from that provided in the constructor

    Returns string

    • Data from the backend as a string, null if not found
  • Get info about the current user, if logged in. Subclasses are generally expected to override this.

    Returns Promise<any>

    • User info
  • Is current user authenticated? Synchronous because it must not trigger any API calls, use passiveLogin() for that

    Returns boolean

  • Higher-level method for reading data from the backend. Subclasses should usually NOT override this method.

    Parameters

    • url: string

      URL to fetch, if different from that provided in the constructor

    • Rest ...args: any[]

    Returns any

    • Data from the backend as a JSON object, null if not found
  • Log a user in, either passively (without triggering any login UI) or actively (with login UI)

    Parameters

    • Optional options: {
          passive: boolean;
      } = {}

      {object}

      • passive: boolean

        {boolean} - Do not trigger any login UI, just return the current user if already logged in

    Returns Promise<any>

  • Parameters

    • data: any
    • __namedParameters: {
          ref: any;
      } = {}
      • ref: any

    Returns Promise<any>

  • Abstract

    Try to authenticate a previously authenticated user (i.e. without showing any login UI).

    Returns Promise<void>

  • Parameters

    • data: any
    • options: any

    Returns Promise<void>

  • Helper for making HTTP requests with JSON-based APIs.

    Parameters

    • call: string

      API endpoint

    • Optional data: any

      Data to send with the request

    • Optional method: string = "GET"

      HTTP method

    • Optional req: {
          headers: any;
          responseType: string;
      }

      Extra request options

      • headers: any

        Extra headers

      • responseType: string

        Response type

    Returns Promise<any>

    • JSON response
  • Higher-level method for writing data to the backend. Subclasses should usually NOT override this method.

    Parameters

    • data: any

      Data to write to the backend

    • Optional o: any = {}

      Options object

    Returns any

    • If successful, info about the stored data
  • Abstract

    Store info that can be used to log users in passively.

    Parameters

    • o: {} = {}

      Returns Promise<void>

    • Parameters

      • data: any
      • __namedParameters: {
            ref: any;
        } = {}
        • ref: any

      Returns Promise<any>

    • Sync the logged in user, i.e. log in passively when another backend has logged in and log out when another backend has logged out. Generally intended to be used for backends with the same authentication mechanism. Syncing is not two-way, you need to call this on the other backend as well to make it so.

      Parameters

      Returns void

    • Update an existing backend instance with new parameters

      Parameters

      • source: string

        Same as constructor

      • o: any = {}

        Same as constructor

      Returns void

    • Return the appropriate backend(s) for this url

      Parameters

      • url: string

        URL describing the storage location

      • Optional o: {
            existing: Backend | Backend[];
        } = {}

        Options object to be passed to the backend

        • existing: Backend | Backend[]

          Existing backend object(s) to re-use if possible

      Returns any

    Generated using TypeDoc