Authdog

RedwoodJS

Authentication for RedwoodJS, web and api

Add auth with a web-side React provider and api-side helpers for Redwood functions and services. Sessions use the same cookie and OIDC flow as every other Authdog SDK, so one environment spans both sides.

One provider
AuthdogProvider in web/src/App.tsx is all it takes to make session state available across pages, cells, and components.
One SDK, both sides
The same package ships a web-side provider and api-side helpers, so auth is consistent across your Redwood workspaces.
HttpOnly session cookie
Tokens are validated against the trusted identity host and sessions ride secure, HttpOnly cookies read on the server.
Users in services
authdog.getUser(context.event) resolves the current user inside any Redwood service.

Web-side provider

// web/src/App.tsx
import { AuthdogProvider } from "@authdog/redwood/web"

const App = () => (
  <AuthdogProvider>
    <RedwoodProvider><Routes /></RedwoodProvider>
  </AuthdogProvider>
)

Protect a Redwood function

// api/src/functions/me.ts
import { createAuthdog } from "@authdog/redwood/api"

const authdog = createAuthdog({ publicKey: process.env.PK_AUTHDOG! })

export const handler = authdog.requireAuth(async (event) => ({
  statusCode: 200,
  body: JSON.stringify(event.authdog.user),
}))

Web provider meets api helpers

Everything Redwood apps need

A provider for the web side and typed helpers for the api side: session state in the UI, real enforcement in your functions and services.

01

Web-side provider

Wrap AuthdogProvider around your app in web/src/App.tsx and session state is available across every page and cell.

  • Pages and cells
  • One-time setup
02

API-side helpers

createAuthdog() gives you getSession, getUser, requireAuth, and logout for Redwood functions and services.

  • Functions and services
  • Four helpers
03

Real server enforcement

requireAuth wraps your function handler and validates the session before it runs. This is the true enforcement point.

  • Validated before your handler
  • Server-side only
04

Resolve users in services

Inside a Redwood service, authdog.getUser(context.event) resolves the current user straight from the incoming request.

  • Straight from the event
  • No extra plumbing
05

One shared session

Uses the same authdog-session cookie and OIDC userinfo flow as every other @authdog/* package, so one environment spans web and api.

  • Same cookie everywhere
  • One environment
06

Fully typed

event.authdog.user is typed end to end on the api side, and the web-side hooks are typed for your components.

  • Typed api events
  • Typed web hooks
01

Install

Add @authdog/redwood to the web and api sides.

02

Wrap the app

Add AuthdogProvider in web/src/App.tsx.

03

Protect functions

Wrap api handlers in requireAuth.

Add auth to your RedwoodJS app.

Install the SDK on both sides, wrap your app, and protect your functions today. Free to start, with secure defaults built in.