Providers

Creating a Provider

It's incredibly simple to create a custom provider!

We highly recommend you write your Provider in TypeScript to take advantage of our documentation!

// my-custom-provider.ts
import { OpenIDProvider } from '@salte-auth/salte-auth';

export class Auth0 extends OpenIDProvider {
  constructor(config: Auth0.Config) {
    super(config);
  }

  /**
   * This is the default name of the provider.
   */
  get name() {
    return 'auth0';
  }

  /**
   * This should use `this.config.url` to build the provider-specific login url.
   */
  get login() {
    // In this case Auth0's "/authorize" is right at the root and 
    // it supports a custom audience parameter.
    return this.url(`${this.config.url}/authorize`, {
      audience: this.config.audience
    });
  }

  /**
   * This should use `this.config.url` to build the provider-specific logout url.
   */
  get logout() {
    return this.url(`${this.config.url}/v2/logout`, {
      returnTo: this.config.redirectUrl,
      client_id: this.config.clientID
    });
  }
}

export interface Auth0 {
  config: Auth0.Config;
}

export declare namespace Auth0 {
  export interface Config extends OpenIDProvider.Config {
    audience?: string
  }
}

Using your Custom Provider

It's equally as easy to use a custom provider.

Last updated

Was this helpful?