auth

package module
v0.0.0-...-379ea06 Latest Latest
Warning

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

Go to latest
Published: Nov 7, 2026 License: MIT Imports: 23 Imported by: 4

README

About GoActivityPub: Authorization

MIT Licensed Build Status Test Coverage

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

It provides functionality for verifying incoming requests against local and remote actors by loading the information from OAuth2 tokens or HTTP-Signatures headers.

Extended documentation

For more information about how the module works in the scope of the GoActivityPub library, see the expanded documentation.

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

This section is empty.

Variables

View Source
var AnonymousActor = vocab.Actor{
	ID: vocab.PublicNS,

	Type: vocab.ActorType,
	Name: vocab.DefaultLangValue("Anonymous"),
}

Functions

func Config

func Config(initFns ...InitFn) config

func HTTPSigMsgFromRequest

func HTTPSigMsgFromRequest(req *http.Request) *httpsig.Message

func HTTPSignature

func HTTPSignature(initFns ...InitFn) httpSigVerifier

HTTPSignature returns an HTTP-Signature validator for loading f

func LoadRemoteKey

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

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

func OAuth2

func OAuth2(initFns ...InitFn) oauthVerifier

OAuth2

func Verifier

func Verifier(initFns ...InitFn) actorResolver

Types

type AccessStore

type AccessStore interface {
	ReadStore
	LoadAccess(string) (*osin.AccessData, error)
}

AccessStore is an ActivityPub storage implementation that can be used to retrieve actors and their generated OAuth2 access tokens. This functionality is used only by the client to server authorization mechanism.

type ActivityPubClient

type ActivityPubClient interface {
	Do(*http.Request) (*http.Response, error)
	CtxLoadIRI(context.Context, vocab.IRI) (vocab.Item, error)
}

ActivityPubClient is an ActivityPub client that can retrieve remote items based on their IRI. It gets used when trying to dereference remote Actors based on their key IDs, in the process of validating the HTTP-Signatures based authorization headers for server to server, or secure fetch requests.

type InitFn

type InitFn = func(*config)

func WithClient

func WithClient(cl ActivityPubClient) InitFn

func WithLogger

func WithLogger(l log.Logger) InitFn

func WithNonceChecker

func WithNonceChecker(nc httpsig.NonceGetter) InitFn

func WithOAuth2Storage

func WithOAuth2Storage(s AccessStore) InitFn

WithOAuth2Storage sets the storage for verifying OAuth Access tokens against the local actor storage.

func WithStorage

func WithStorage(s ReadStore) InitFn

WithStorage sets the storage for verifying actors in local storage.

type ReadStore

type ReadStore interface {
	// Load returns an Item or an ItemCollection from an IRI
	Load(vocab.IRI, ...filters.Check) (vocab.Item, error)
}

ReadStore is an ActivityPub storage implementation that can return a valid Item object based on its IRI. This functionality is used by both client to server and server to server authorization mechanisms.

Jump to

Keyboard shortcuts

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