magiclink

package
v0.4.0 Latest Latest
Warning

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

Go to latest
Published: Sep 11, 2026 License: MIT Imports: 12 Imported by: 0

Documentation

Overview

Package magiclink implements sign-in through an emailed one-time link.

The plugin uses only the public plugin package. It receives no privileged access to Auth-All internals, so a third-party plugin can do the same work.

Index

Constants

View Source
const DefaultTTL = 15 * time.Minute

DefaultTTL is the default lifetime of a sign-in link.

View Source
const ID = "magic-link"

ID is the stable plugin identifier.

View Source
const TokenKind = "magic-link"

TokenKind is the one-time token namespace of this plugin.

Variables

This section is empty.

Functions

This section is empty.

Types

type Option

type Option func(*Plugin)

Option configures the plugin.

func WithCallbackURL

func WithCallbackURL(v string) Option

WithCallbackURL sets where the browser goes after a successful sign-in. The default is the configured base URL.

func WithCreateUser

func WithCreateUser(v bool) Option

WithCreateUser controls whether an unknown address creates an account. It is enabled by default, because a magic link proves ownership of the address.

func WithTTL

func WithTTL(d time.Duration) Option

WithTTL sets the lifetime of a sign-in link.

func WithVerifyURL

func WithVerifyURL(v string) Option

WithVerifyURL overrides the absolute link that the email carries. The default is the verify endpoint of this plugin.

func WithoutConfirmation

func WithoutConfirmation() Option

WithoutConfirmation lets GET /magic-link/verify complete the sign-in on its own. The default needs the confirmation step.

Do not use this option unless you accept three risks. An attacker can make the browser of another person open a link and sign that person in to the account of the attacker. The token reaches the callback host through the Referer header. A mail scanner that pre-fetches the link consumes the token, so the person can no longer sign in.

type Plugin

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

Plugin is the Magic Link plugin.

func New

func New(opts ...Option) *Plugin

New returns the Magic Link plugin.

func (*Plugin) ID

func (p *Plugin) ID() string

ID implements plugin.Plugin.

func (*Plugin) Register

func (p *Plugin) Register(r *plugin.Registry) error

Register implements plugin.Plugin.

Jump to

Keyboard shortcuts

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