auth

package module
v0.0.0-...-7b70def Latest Latest
Warning

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

Go to latest
Published: Apr 8, 2024 License: MIT Imports: 19 Imported by: 2

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 AnonymousActor = vocab.Actor{
	ID:   vocab.PublicNS,
	Type: vocab.ActorType,
	Name: vocab.NaturalLanguageValues{
		vocab.LangRefValue{
			Ref:   vocab.NilLangRef,
			Value: vocab.Content("Anonymous"),
		},
	},
}
View Source
var EmptyLogFn = func(log.Ctx, string, ...interface{}) {}

Functions

func ErrFn

func ErrFn(logFn LoggerFn) optionFn

func LogFn

func LogFn(logFn LoggerFn) optionFn

func NewLogger

func NewLogger(opt ...optionFn) (*logger, error)

func NewServer

func NewServer(store osin.Storage, l log.Logger) (*osin.Server, error)

Types

type Account

type Account vocab.Actor

func (*Account) IsLogged

func (a *Account) IsLogged() bool

type LoggerFn

type LoggerFn func(log.Ctx, string, ...interface{})

type OptionFn

type OptionFn func(s *Server) error

func WithClient

func WithClient(cl client.Basic) OptionFn

func WithLogger

func WithLogger(l log.Logger) OptionFn

func WithStorage

func WithStorage(st ReadStore) OptionFn

func WithURL

func WithURL(u string) OptionFn

type ReadStore

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

ReadStore

type Server

type Server struct {
	*osin.Server
	// contains filtered or unexported fields
}

func New

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

func (*Server) Authorize

func (s *Server) Authorize(w http.ResponseWriter, r *http.Request)

func (*Server) LoadActorFromAuthHeader

func (s *Server) LoadActorFromAuthHeader(r *http.Request) (vocab.Actor, error)

LoadActorFromAuthHeader reads the Authorization header of an HTTP request and tries to decode it either an OAuth2 or HTTP Signatures:

* For OAuth2 it tries to load the matching local actor and use it further in the processing logic. * For HTTP Signatures it tries to load the federated actor and use it further in the processing logic.

func (*Server) Redirect

func (s *Server) Redirect(w http.ResponseWriter, r *http.Request, url string, status int)

func (Server) Routes

func (s Server) Routes(r chi.Router) chi.Routes

func (*Server) Token

func (s *Server) Token(w http.ResponseWriter, r *http.Request)

Token

func (*Server) ValidateLoggedIn

func (s *Server) ValidateLoggedIn() func(next http.Handler) http.Handler

Jump to

Keyboard shortcuts

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