Documentation ¶
Overview ¶
Package indieauth implements an IndieAuth (an identity layer on top of OAuth 2.0)] client/authentication middleware.
Index ¶
- Constants
- Variables
- func ClientID(clientID string) func(*http.Request) string
- type IndieAuth
- func (ia *IndieAuth) Check(r *http.Request) bool
- func (ia *IndieAuth) Logout(w http.ResponseWriter, r *http.Request)
- func (ia *IndieAuth) Middleware() func(http.Handler) http.Handler
- func (ia *IndieAuth) Redirect(w http.ResponseWriter, r *http.Request) error
- func (ia *IndieAuth) RedirectHandler(w http.ResponseWriter, r *http.Request)
Constants ¶
View Source
const (
// DefaultRedirectPath is default path where the RedirectHandler should be served
DefaultRedirectPath = "/indieauth-redirect"
)
Variables ¶
View Source
var ( // ErrForbidden is returned when the authorization endpoint answered a 403 ErrForbidden = errors.New("authorization endpoint answered with forbidden") // ErrAuthorizationEndointNotFound is returned when the authorization_endpoint could not be discovered for the given URL ErrAuthorizationEndpointNotFound = errors.New("authorization_endpoint not found") // UserAgent is the User Agent used for the requests performed as an "IndieAuth Client" UserAgent = "IndieAuth client (+https://a4.io/go/indieauth)" // SessionName is the name of the Gorilla session SessionName = "indieauth" )
Functions ¶
Types ¶
type IndieAuth ¶
type IndieAuth struct { // ClientID will try to guess the client ID from the request by default ClientID func(r *http.Request) string // RedirectPath will default to `/indieauth-redirect` RedirectPath string // contains filtered or unexported fields }
IndieAuth holds the auth manager
func New ¶
func New(store *sessions.CookieStore, me string) (*IndieAuth, error)
New initializes an IndieAuth auth manager, the `Middleware` shortcut is the preferred API unless you want fine-grained configuration.
func (*IndieAuth) Logout ¶
func (ia *IndieAuth) Logout(w http.ResponseWriter, r *http.Request)
Logout logs out the current user
func (*IndieAuth) Middleware ¶
Middleware provides a middleware that will only allow user authenticated against the given IndiAuth endpoint
func (*IndieAuth) Redirect ¶
Redirect responds to the request by redirecting to the authorization endpoint
func (*IndieAuth) RedirectHandler ¶
func (ia *IndieAuth) RedirectHandler(w http.ResponseWriter, r *http.Request)
RedirectHandler is a HTTP handler that must be registered on the app at `/indieauth-redirect`
Click to show internal directories.
Click to hide internal directories.