Skip to content

HttpApiSecurity

13 exports Added in v1.0.0 Source

Annotations

annotate

Added in v1.0.0 Source

Signature

declare const annotate: {
  <I, S>(tag: Tag<I, S>, value: S): <A extends HttpApiSecurity>(self: A) => A;
  <A extends HttpApiSecurity, I, S>(self: A, tag: Tag<I, S>, value: S): A;
};

Signature

declare const annotateContext: {
  <I>(context: Context<I>): <A extends HttpApiSecurity>(self: A) => A;
  <A extends HttpApiSecurity, I>(self: A, context: Context<I>): A;
};

Constructors

apiKey

Added in v1.0.0 Source

Create an API key security scheme.

You can implement some api middleware for this security scheme using HttpApiBuilder.middlewareSecurity.

To set the correct cookie in a handler, you can use HttpApiBuilder.securitySetCookie.

The default value for in is "header".

Signature

declare function apiKey(options: {
  readonly in?: "header" | "query" | "cookie";
  readonly key: string;
}): ApiKey;

basic

Added in v1.0.0 Source

Signature

declare const basic: Basic;

bearer

Added in v1.0.0 Source

Create an Bearer token security scheme.

You can implement some api middleware for this security scheme using HttpApiBuilder.middlewareSecurity.

Signature

declare const bearer: Bearer;

Models

ApiKey interface

Added in v1.0.0 Source

Signature

interface ApiKey extends Proto<Redacted> {
  readonly _tag: "ApiKey";
  readonly in: "header" | "query" | "cookie";
  readonly key: string;
}

Basic interface

Added in v1.0.0 Source

Signature

interface Basic extends Proto<Credentials> {
  readonly _tag: "Basic";
}

Bearer interface

Added in v1.0.0 Source

Signature

interface Bearer extends Proto<Redacted> {
  readonly _tag: "Bearer";
}

Credentials interface

Added in v1.0.0 Source

Signature

interface Credentials {
  readonly password: Redacted;
  readonly username: string;
}

HttpApiSecurity type

Added in v1.0.0 Source

Signature

type HttpApiSecurity = Bearer | ApiKey | Basic;

Type Ids

TypeId

Added in v1.0.0 Source

Signature

declare const TypeId: unique symbol;

TypeId type

Added in v1.0.0 Source

Signature

type TypeId = typeof TypeId;