Skip to main content

Auth

SST Auth is a lightweight authentication solution for your applications. With a simple set of configuration you can deploy a function attached to your API that can handle various authentication flows. Full documentation here

Constructor​

new Auth(scope, id, props)

Parameters

AuthProps​

authenticator​

Type : string | Function | FunctionProps

The function that will handle authentication

cdk?​

Type :

cdk.id?​

Type : string

Allows you to override default id for this construct.

Properties​

An instance of Auth has the following properties.

id​

Type : string

Methods​

An instance of Auth has the following methods.

attach​

attach(scope, props)

Parameters

Attaches auth construct to an API

const api = new Api(stack, "Api", {});
const auth = new Auth(stack, "Auth", {
authenticator: "functions/authenticator.handler"
})
auth.attach(stack, {
api
})

ApiAttachmentProps​

api​

Type : Api

The API to attach auth routes to

const api = new Api(stack, "Api", {});
const auth = new Auth(stack, "Auth", {
authenticator: "functions/authenticator.handler"
})
auth.attach(stack, {
api
})

prefix?​

Type : string

Default : "/auth"

Optionally specify the prefix to mount authentication routes

const api = new Api(stack, "Api", {});
const auth = new Auth(stack, "Auth", {
authenticator: "functions/authenticator.handler"
})
auth.attach(stack, {
api,
prefix: "/custom/prefix"
})