indieauth

package
v0.1.3 Latest Latest
Warning

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

Go to latest
Published: Apr 7, 2024 License: MIT Imports: 20 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func HandleCallbackCode

func HandleCallbackCode(code, state string) (*Request, *Response, error)

HandleCallbackCode will handle the callback from the IndieAuth server to continue the next step of the auth flow.

func StartAuthFlow

func StartAuthFlow(authHost, userID, accessToken, displayName string) (*url.URL, error)

StartAuthFlow will begin the IndieAuth flow by generating an auth request.

Types

type Profile

type Profile struct {
	Name  string `json:"name"`
	URL   string `json:"url"`
	Photo string `json:"photo"`
}

Profile represents optional profile data that is returned when completing the IndieAuth flow.

type Request

type Request struct {
	Timestamp          time.Time
	Endpoint           *url.URL
	Redirect           *url.URL // Outbound redirect URL to continue auth flow
	Callback           *url.URL // Inbound URL to get auth flow results
	Me                 *url.URL
	UserID             string
	DisplayName        string
	CurrentAccessToken string
	ClientID           string
	CodeVerifier       string
	CodeChallenge      string
	State              string
}

Request represents a single in-flight IndieAuth request.

type Response

type Response struct {
	Me               string  `json:"me,omitempty"`
	Profile          Profile `json:"profile,omitempty"`
	Error            string  `json:"error,omitempty"`
	ErrorDescription string  `json:"error_description,omitempty"`
}

Response the response returned when completing the IndieAuth flow.

type ServerAuthRequest

type ServerAuthRequest struct {
	Timestamp     time.Time
	ClientID      string
	RedirectURI   string
	CodeChallenge string
	State         string
	Me            string
	Code          string
}

ServerAuthRequest is n inbound request to authenticate against this Owncast instance.

func StartServerAuth

func StartServerAuth(clientID, redirectURI, codeChallenge, state, me string) (*ServerAuthRequest, error)

StartServerAuth will handle the authentication for the admin user of this Owncast server. Initiated via a GET of the auth endpoint. https://indieweb.org/authorization-endpoint

type ServerProfile

type ServerProfile struct {
	Name  string `json:"name"`
	URL   string `json:"url"`
	Photo string `json:"photo"`
}

ServerProfile represents basic user-provided data about this Owncast instance.

type ServerProfileResponse

type ServerProfileResponse struct {
	Me      string        `json:"me,omitempty"`
	Profile ServerProfile `json:"profile,omitempty"`
	// Error keys need to match the OAuth spec.
	Error            string `json:"error,omitempty"`
	ErrorDescription string `json:"error_description,omitempty"`
}

ServerProfileResponse is returned when an auth flow requests the final confirmation of the IndieAuth flow.

func CompleteServerAuth

func CompleteServerAuth(code, redirectURI, clientID string, codeVerifier string) (*ServerProfileResponse, error)

CompleteServerAuth will verify that the values provided in the final step of the IndieAuth flow are correct, and return some basic profile info.

Jump to

Keyboard shortcuts

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