Skip to main content Link Search Menu Expand Document (external link)

HttpApiSecurity overview

Added in v1.0.0


Table of contents


annotations

annotate

Signature

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

Added in v1.0.0

annotateContext

Signature

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

Added in v1.0.0

constructors

apiKey

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.

Signature

export declare const apiKey: (options: {
  readonly key: string
  readonly in?: "header" | "query" | "cookie" | undefined
}) => ApiKey

Added in v1.0.0

basic

Signature

export declare const basic: Basic

Added in v1.0.0

bearer

Create an Bearer token security scheme.

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

Signature

export declare const bearer: Bearer

Added in v1.0.0

models

ApiKey (interface)

Signature

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

Added in v1.0.0

Basic (interface)

Signature

export interface Basic extends HttpApiSecurity.Proto<Credentials> {
  readonly _tag: "Basic"
}

Added in v1.0.0

Bearer (interface)

Signature

export interface Bearer extends HttpApiSecurity.Proto<Redacted> {
  readonly _tag: "Bearer"
}

Added in v1.0.0

Credentials (interface)

Signature

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

Added in v1.0.0

HttpApiSecurity (type alias)

Signature

export type HttpApiSecurity = Bearer | ApiKey | Basic

Added in v1.0.0

HttpApiSecurity (namespace)

Added in v1.0.0

Proto (interface)

Signature

export interface Proto<out A> extends Pipeable {
  readonly [TypeId]: {
    readonly _A: Covariant<A>
  }
  readonly annotations: Context.Context<never>
}

Added in v1.0.0

Type (type alias)

Signature

export type Type<A extends HttpApiSecurity> = A extends Proto<infer Out> ? Out : never

Added in v1.0.0

type ids

TypeId

Signature

export declare const TypeId: typeof TypeId

Added in v1.0.0

TypeId (type alias)

Signature

export type TypeId = typeof TypeId

Added in v1.0.0