server
AstroAuth()
AstroAuth(config?): {
GET: handler;
POST: handler;
}Creates a set of Astro endpoints for authentication.
Parameters
| Parameter | Type | Description |
|---|---|---|
config? | AuthConfig | The configuration for authentication providers and other options. Providing this will override your auth config file. |
Returns
{
GET: handler;
POST: handler;
}An object with GET and POST methods that can be exported in an Astro endpoint.
GET()
GET: (ctx) => Promise<undefined | Response> = handler;Parameters
| Parameter | Type |
|---|---|
ctx | APIContext<Record<string, any>, Record<string, undefined | string>> |
Returns
POST()
POST: (ctx) => Promise<undefined | Response> = handler;Parameters
| Parameter | Type |
|---|---|
ctx | APIContext<Record<string, any>, Record<string, undefined | string>> |
Returns
Example
export const { GET, POST } = AstroAuth({
providers: [
GitHub({
clientId: process.env.GITHUB_ID!,
clientSecret: process.env.GITHUB_SECRET!,
}),
],
debug: false,
})auth()
auth(ctx, config?): Promise<Session | null>Fetches the current session.
Parameters
| Parameter | Type |
|---|---|
ctx | APIContext<Record<string, any>, Record<string, undefined | string>> |
config? | AuthConfig |
Returns
The current session, or null if there is no session.