core

package
v0.1.0 Latest Latest
Warning

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

Go to latest
Published: Oct 16, 2026 License: MIT Imports: 4 Imported by: 0

Documentation

Overview

Package core holds what both the admin and the auth package need, so neither imports the other for it: auth registers its pages on a Site, and the Site takes an Authenticator. The public names are aliases of these (jetadmin.Authenticator, auth.User).

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func SafeNext

func SafeNext(base, next string) string

SafeNext is where to go after signing in: next when it is a path under base, else base's index. Never another host.

func WithChrome

func WithChrome(ctx context.Context, c Chrome) context.Context

WithChrome returns ctx carrying c.

Types

type Authenticator

type Authenticator interface {
	// Authenticate returns the admin user signed in on r.
	Authenticate(r *http.Request) (User, bool)
}

Authenticator tells who is signed in on a request.

type Chrome

type Chrome struct {
	Title    string
	BasePath string
}

Chrome is what a page outside the Site's own handlers (the login page of an Authenticator) needs to look like the rest of the admin. The Site puts it in the request's context.

func ChromeFrom

func ChromeFrom(ctx context.Context) Chrome

ChromeFrom is the Chrome of ctx, or a plain one when the handler runs outside a Site (a test).

type LoginProvider

type LoginProvider interface {
	Authenticator
	LoginHandler() http.Handler
	LogoutHandler() http.Handler
}

LoginProvider is an Authenticator that also serves the sign-in and sign-out pages; the Site mounts them at BasePath/login and BasePath/logout.

type User

type User struct {
	ID       uuid.UUID
	Username string
}

User is the admin signed in on a request.

Jump to

Keyboard shortcuts

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