4.0.0-alpha.0 • Published 2 days ago

@magda/authentication-plugin-sdk v4.0.0-alpha.0

Weekly downloads
1
License
Apache-2.0
Repository
-
Last release
2 days ago

MAGDA Authentication Plugin SDK

Please information please refer to the Authentication Plugin Spec

Existing Magda Authentication Plugins can be found from here.

You can use this repo as a template to create your own magda authentication plugin.

/**
 * Create an express router that can be used to enable session on an express application.
 *
 * @export
 * @param {MagdaSessionRouterOptions} options
 * @returns {Router}
 */
export declare function createMagdaSessionRouter(
  options: MagdaSessionRouterOptions
): Router;

/**
 * Complete destroy Magda session and remove session cookie from the user agent
 *
 * @export
 * @param {Request} req
 * @param {Response} res
 * @param {SessionCookieOptions} cookieOptions
 * @return {*}  {Promise<void>}
 */
export declare async function destroyMagdaSession(
  req: Request,
  res: Response,
  cookieOptions: SessionCookieOptions
): Promise<void>;

/**
 * Verify the user using the user profile received during the authentication.
 * If a user can be located, return UserToken type data.
 * Otherwise, create a new user and return UserToken type data .
 *
 * @export
 * @param {AuthApiClient} authApi
 * @param {passport.Profile} profile
 * @param {string} source
 * @param {(
 *         authApiClient: AuthApiClient,
 *         userData: User,
 *         profile: passport.Profile
 *     ) => Promise<User>} [beforeUserCreated] an optional handler that will be called just before a user is created.
 * The user data returned by this handler will be used to create a user record. The following parameters will be provided to the handler:
 * - authApiClient: Auth API Client. You can use it to add a role to the user.
 * - userData: the user data that is converted from the user profile received using the default conversion logic.
 * - profile: the user profile received
 *
 * @param {(
 *         authApiClient: AuthApiClient,
 *         user: User,
 *         profile: passport.Profile
 *     ) => Promise<void>} [afterUserCreated] an optional call that will be called when a user has just been created.
 * The following parameters will be provided to the handler:
 * - authApiClient: Auth API Client. You can use it to add a role to the user.
 * - user: the user data of the magda user that is just created.
 * - profile: the user profile received
 *
 * @returns {Promise<UserToken>}
 */
export declare function createOrGetUserToken(
  authApi: AuthApiClient,
  profile: passport.Profile,
  source: string,
  beforeUserCreated?: (
    authApiClient: AuthApiClient,
    userData: User,
    profile: passport.Profile
  ) => Promise<User>,
  afterUserCreated?: (
    authApiClient: AuthApiClient,
    user: User,
    profile: passport.Profile
  ) => Promise<void>
): Promise<UserToken>;

/**
 * Join `url` with `baseUrl` if `url` is not an absolute (full) url string
 *
 * @export
 * @param {string} url A full url string or a url path string (/a/b/c).
 * @param {string} baseUrl A baseUrl used to generate a full url when a url path string is supplied via the `url` parameter.
 * @param {{ [key: string]: string }} [optionalQueries]
 * @param {string[]} [allowedUrlHosts] Optional; when specify, the host of `url` parameter will only be used if it is included by this list.
 * @returns
 */
export declare function getAbsoluteUrl(
  url: string,
  baseUrl: string,
  optionalQueries?: {
    [key: string]: string;
  },
  allowedUrlHosts?: string[]
): string;

export declare function redirectOnSuccess(
  toURL: string,
  req: Request,
  res: Response
): void;

export declare function redirectOnError(
  err: any,
  toURL: string,
  req: Request,
  res: Response
): void;
4.0.0-alpha.0

2 days ago

3.0.2

20 days ago

3.0.2-alpha.1

23 days ago

3.0.2-alpha.0

24 days ago

3.0.1

1 month ago

3.0.1-alpha.0

1 month ago

3.0.0

2 months ago

3.0.0-alpha.2

3 months ago

3.0.0-alpha.1

3 months ago

3.0.0-alpha.0

4 months ago

2.3.0-alpha.0

9 months ago

2.3.0

8 months ago

2.3.2

7 months ago

2.3.1

8 months ago

2.3.3

6 months ago

2.2.5-alpha.1

10 months ago

2.2.5

9 months ago

2.2.6

9 months ago

2.3.2-alpha.1

7 months ago

2.3.2-alpha.0

8 months ago

2.3.2-alpha.2

7 months ago

2.2.5-alpha.0

11 months ago

2.2.4

12 months ago

2.2.4-alpha.0

1 year ago

2.2.4-alpha.1

1 year ago

2.2.3-alpha.3

1 year ago

2.2.3

1 year ago

2.2.3-alpha.1

1 year ago

2.2.3-alpha.0

1 year ago

2.2.3-alpha.2

1 year ago

2.2.2-alpha.1

1 year ago

2.2.2-alpha.0

1 year ago

2.2.2

1 year ago

2.2.2-rc.0

1 year ago

2.2.1

1 year ago

2.2.0

1 year ago

2.2.0-alpha.0

2 years ago

2.2.0-alpha.3

1 year ago

2.2.0-alpha.2

1 year ago

2.2.0-alpha.1

1 year ago

2.1.1-alpha.0

2 years ago

2.1.1

2 years ago

2.1.0

2 years ago

2.1.2-alpha.0

2 years ago

2.0.1

2 years ago

2.1.0-alpha.1

2 years ago

2.1.0-alpha.0

2 years ago

2.0.0-alpha.7

2 years ago

2.0.0-alpha.8

2 years ago

2.0.0-alpha.4

2 years ago

2.0.0-alpha.5

2 years ago

2.0.0-alpha.6

2 years ago

1.3.1-rc.2

2 years ago

1.3.1-rc.1

2 years ago

1.3.1-rc.0

2 years ago

2.0.0

2 years ago

1.3.1

2 years ago

0.0.60-dt.2

2 years ago

2.0.0-alpha.3

2 years ago

2.0.0-alpha.2

2 years ago

1.3.0

2 years ago

1.2.1

2 years ago

2.0.0-alpha.1

2 years ago

1.3.0-rc.0

2 years ago

1.2.2-alpha.0

2 years ago

1.2.1-rc.0

2 years ago

2.0.0-alpha.0

2 years ago

1.2.0

2 years ago

1.2.1-alpha.0

2 years ago

1.2.0-rc.0

2 years ago

1.2.0-alpha.1

2 years ago

1.0.1

2 years ago

1.1.0-arm64.0

3 years ago

1.1.0-rc.1

2 years ago

1.1.0-rc.0

2 years ago

1.1.0

2 years ago

1.2.0-alpha.0

2 years ago

1.1.0-alpha.2

2 years ago

0.0.60-dt.1

2 years ago

1.1.0-alpha.3

2 years ago

0.0.60-dt.0

2 years ago

1.1.0-alpha.4

2 years ago

1.1.0-alpha.1

3 years ago

1.0.0

3 years ago

1.0.0-alpha.5

3 years ago

1.0.0-alpha.4

3 years ago

1.1.0-alpha.0

3 years ago

1.0.0-alpha.3

3 years ago

1.0.0-alpha.2

3 years ago

1.0.0-alpha.1

3 years ago

0.0.60

3 years ago

1.0.0-alpha.0

3 years ago

0.0.60-rc.5

3 years ago

0.0.60-alpha.18

3 years ago

0.0.60-alpha.17

3 years ago

0.0.60-alpha.16

3 years ago

0.0.60-alpha.15

3 years ago

0.0.60-rc.4

3 years ago

0.0.60-alpha.14

3 years ago

0.0.60-alpha.13

3 years ago

0.0.60-rc.3

3 years ago

0.0.60-alpha.12

3 years ago

0.0.60-alpha.11

3 years ago

0.0.60-alpha.10

3 years ago

0.0.60-rc.2

3 years ago

0.0.60-alpha.9

3 years ago

0.0.60-alpha.8

3 years ago

0.0.60-alpha.7

3 years ago

0.0.60-alpha.6

3 years ago

0.0.60-rc.1

3 years ago

0.0.60-alpha.5

3 years ago

0.0.60-rc.0

3 years ago

0.0.60-alpha.4

3 years ago

0.0.60-alpha.3

3 years ago

0.0.60-alpha.2

3 years ago

0.0.60-alpha.1

3 years ago

0.0.60-alpha.0

3 years ago

0.0.59

3 years ago

0.0.59-alpha.3

3 years ago

0.0.59-alpha.2

3 years ago

0.0.59-alpha.1

3 years ago

0.0.59-alpha.0

3 years ago

0.0.58

3 years ago

0.0.58-rc.5

3 years ago

0.0.58-rc.4

3 years ago

0.0.58-alpha.2

4 years ago

0.0.58-alpha.1

4 years ago

0.0.58-alpha.0

4 years ago