auth

package module
v0.0.0-...-5c1b7ee Latest Latest
Warning

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

Go to latest
Published: Apr 18, 2026 License: MIT Imports: 21 Imported by: 4

README

About GoActivityPub: Authorization

MIT Licensed Build Status Test Coverage Go Report Card

This project is part of the GoActivityPub library which helps with creating ActivityPub applications using the Go programming language.

It is a wrapper package around making compatible libraries as HTTP-Sig and OAuth2 interact with GoActiivtyPub.

It provides functions to append Authorization headers to requests made with the client module, and also middlewares for verifying incoming requests against remote actors.

You can find an expanded documentation about the whole library on SourceHut.

For discussions about the projects you can write to the discussions mailing list: ~mariusor/go-activitypub-discuss@lists.sr.ht

For patches and bug reports please use the dev mailing list: ~mariusor/go-activitypub-dev@lists.sr.ht

Documentation

Index

Constants

ID is the type of authorization that IndieAuth is using

Variables

View Source
var (
	DefaultAuthorizeTypes = osin.AllowedAuthorizeType{osin.CODE, osin.TOKEN, ID}
	DefaultAccessTypes    = osin.AllowedAccessType{osin.AUTHORIZATION_CODE, osin.REFRESH_TOKEN, osin.PASSWORD, osin.CLIENT_CREDENTIALS}

	DefaultConfig = osin.ServerConfig{
		AuthorizationExpiration:     86400,
		AccessExpiration:            2678400,
		TokenType:                   "Bearer",
		AllowedAuthorizeTypes:       DefaultAuthorizeTypes,
		AllowedAccessTypes:          DefaultAccessTypes,
		ErrorStatusCode:             http.StatusForbidden,
		AllowClientSecretInParams:   false,
		AllowGetAccessRequest:       false,
		RetainTokenAfterRefresh:     true,
		RedirectUriSeparator:        "\n",
		RequirePKCEForPublicClients: true,
	}
)
View Source
var AnonymousActor = vocab.Actor{
	ID:   vocab.PublicNS,
	Type: vocab.ActorType,
	Name: vocab.DefaultNaturalLanguage("Anonymous"),
}
View Source
var DefaultKeyWaitLoadTime = 2 * time.Second

Functions

func Config

func Config(cl Client, initFns ...ConfigInitFn) config

func HTTPSignature

func HTTPSignature(cl Client, initFns ...ConfigInitFn) *keyLoader

HTTPSignature returns a HTTP-Signature validator for loading f

func LoadRemoteKey

func LoadRemoteKey(ctx context.Context, c Client, iri vocab.IRI) (vocab.Actor, *vocab.PublicKey, error)

LoadRemoteKey fetches a remote Public Key and returns it's owner.

func OAuth2

func OAuth2(cl Client, initFns ...ConfigInitFn) *oauthLoader

OAuth2

func Resolver

func Resolver(cl Client, initFns ...ConfigInitFn) *actorResolver

Types

type ActorVerifier

type ActorVerifier interface {
	// Verify validates a request for the existence of an authorized ActivityPub [vocab.Actor] that has
	// operated it.
	Verify(*http.Request) (vocab.Actor, error)
}

ActorVerifier verifies if a http.Request contains information about an ActivityPub vocab.Actor that has operated it.

type Client

type Client interface {
	CtxLoadIRI(context.Context, vocab.IRI) (vocab.Item, error)
}

type ConfigInitFn

type ConfigInitFn = func(*config)

func ConfigWithIgnoreList

func ConfigWithIgnoreList(iris ...vocab.IRI) ConfigInitFn

func ConfigWithLocalIRIFn

func ConfigWithLocalIRIFn(fn func(vocab.IRI) bool) ConfigInitFn

func ConfigWithLogger

func ConfigWithLogger(l log.Logger) ConfigInitFn

func ConfigWithStorage

func ConfigWithStorage(s oauthStore) ConfigInitFn

type Metadata

type Metadata struct {
	Pw         []byte `jsonld:"pw,omitempty"`
	PrivateKey []byte `jsonld:"key,omitempty"`
}

type OptionFn

type OptionFn func(s *osin.Server) error

func WithLogger

func WithLogger(l lw.Logger) OptionFn

func WithStorage

func WithStorage(st oauthStore) OptionFn

type Server

type Server struct {
	*osin.Server
}

func New

func New(optFns ...OptionFn) (*Server, error)

Jump to

Keyboard shortcuts

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