authsupabase

package module
v0.2.1 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jun 22, 2026 License: MIT Imports: 7 Imported by: 0

README

plugin-auth-supabase

A togo plugin adding Supabase (GoTrue) JWT authentication: a /auth/me endpoint and reusable bearer-token middleware.

Install

togo install togo-framework/plugin-auth-supabase

Then blank-import it so the kernel auto-discovers it (the CLI wires this for you):

import _ "github.com/togo-framework/plugin-auth-supabase"

Set SUPABASE_JWT_SECRET in your .env. The plugin:

  • mounts GET /api/auth/me — validates the Authorization: Bearer <jwt> token and returns the claims;
  • exports Middleware to protect any route, and Claims(ctx) to read the user.
r.With(authPlugin.Middleware).Get("/api/secret", handler)

License

MIT

Documentation

Overview

Package authsupabase is a togo plugin that adds Supabase (GoTrue) JWT auth: a /auth/me endpoint and reusable middleware that validates the bearer token.

Blank-import it to auto-register with the kernel:

import _ "github.com/togo-framework/plugin-auth-supabase"

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Claims

func Claims(ctx context.Context) (jwt.MapClaims, bool)

Claims returns the validated JWT claims stored by Middleware, if any.

Types

type Plugin

type Plugin struct {
	// contains filtered or unexported fields
}

Plugin implements togo.Plugin.

func (*Plugin) Boot

func (p *Plugin) Boot(ctx context.Context, k *togo.Kernel) error

Boot mounts the /auth/me endpoint and fires an auth.ready hook.

func (*Plugin) Middleware

func (p *Plugin) Middleware(next http.Handler) http.Handler

Middleware protects handlers: it 401s unless a valid Supabase JWT is present, and stores the claims in the request context (use Claims(ctx) to read them).

func (*Plugin) Name

func (*Plugin) Name() string

Name identifies the plugin.

func (*Plugin) Priority

func (*Plugin) Priority() int

Priority boots auth early (after infra, before feature plugins).

func (*Plugin) Register

func (p *Plugin) Register(k *togo.Kernel) error

Register reads the Supabase JWT secret from the environment.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL