studioauth

package
v1.2.0 Latest Latest
Warning

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

Go to latest
Published: Jun 28, 2026 License: MIT Imports: 10 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var DefaultAdminRoles = []string{"admin", "supatype_admin"}

DefaultAdminRoles are allowed Studio admin roles when config/env omit overrides.

Functions

func AdminRolesFromConfigFile

func AdminRolesFromConfigFile(path string) []string

AdminRolesFromConfigFile merges adminRoles from admin-config.json when present.

func AdminRolesFromEnv

func AdminRolesFromEnv() []string

AdminRolesFromEnv reads STUDIO_ADMIN_ROLES (comma-separated) or returns defaults.

func DevBypass

func DevBypass() bool

DevBypass is true when local open Studio is explicitly enabled (supatype dev docker only).

func ProxyHandler

func ProxyHandler(inner http.Handler, c Config) http.Handler

ProxyHandler forwards privileged API calls after admin JWT verification. inner must be the main service mux (without /studio routes).

func ReadAdminConfigFile

func ReadAdminConfigFile(path string) ([]byte, error)

ReadAdminConfigFile reads admin-config.json from a relative path under the working directory.

func RequireAdmin

func RequireAdmin(c Config, next http.Handler) http.Handler

RequireAdmin wraps a handler with studio admin JWT checks (skipped when DevBypass).

func VerifyHandler

func VerifyHandler(c Config) http.HandlerFunc

VerifyHandler serves GET /studio/auth/verify.

Types

type Config

type Config struct {
	JWTSecret      string
	ServiceRoleKey string
	AdminRoles     []string
	Mode           string
}

Config holds studio auth handler dependencies.

func ConfigFromServer

func ConfigFromServer(cfg *serverconf.ServerConfig) Config

ConfigFromServer builds handler config from ServerConfig and admin-config path.

type Result

type Result struct {
	Allowed bool
	Message string
	Role    string
	Sub     string
}

Result is the outcome of an admin JWT check.

func VerifyBearerToken

func VerifyBearerToken(token string, jwtSecret string, adminRoles []string) Result

VerifyBearerToken validates a user JWT and checks studio admin role membership. Role resolution: app_metadata.role first, then top-level role when it is an admin role.

func VerifyRequest

func VerifyRequest(req *http.Request, jwtSecret string, adminRoles []string) Result

VerifyRequest extracts Bearer token from req and verifies it.

Jump to

Keyboard shortcuts

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