Documentation
¶
Index ¶
- Constants
- func FetchMetaProfile(ctx context.Context, username string, user *AuthContext) error
- func LegacyOAuth(bearer string, hash [64]byte, w http.ResponseWriter, r *http.Request, ...)
- func LookupTokenRevocation(ctx context.Context, username string, hash [64]byte, clientID string) (bool, error)
- func LookupUser(ctx context.Context, username string, user *AuthContext) error
- func Middleware(conf ini.File, apiconf string) func(http.Handler) http.Handler
- func OAuth2(token string, hash [64]byte, w http.ResponseWriter, r *http.Request, ...)
- type AuthContext
- type AuthCookie
- type InternalAuth
- type OAuth2Token
- type Timestamp
Constants ¶
View Source
const ( USER_UNCONFIRMED = "unconfirmed" USER_ACTIVE_NON_PAYING = "active_non_paying" USER_ACTIVE_FREE = "active_free" USER_ACTIVE_PAYING = "active_paying" USER_ACTIVE_DELINQUENT = "active_delinquent" USER_ADMIN = "admin" USER_UNKNOWN = "unknown" USER_SUSPENDED = "suspended" )
View Source
const ( AUTH_OAUTH_LEGACY = iota AUTH_OAUTH2 = iota AUTH_COOKIE = iota AUTH_INTERNAL = iota )
View Source
const TokenVersion uint = 0
Variables ¶
This section is empty.
Functions ¶
func FetchMetaProfile ¶
func FetchMetaProfile(ctx context.Context, username string, user *AuthContext) error
func LegacyOAuth ¶
func LegacyOAuth(bearer string, hash [64]byte, w http.ResponseWriter, r *http.Request, next http.Handler)
TODO: Remove legacy OAuth support
func LookupTokenRevocation ¶
func LookupTokenRevocation(ctx context.Context, username string, hash [64]byte, clientID string) (bool, error)
Returns true if this token or client ID has been revoked (and therefore should not be trusted)
func LookupUser ¶
func LookupUser(ctx context.Context, username string, user *AuthContext) error
Types ¶
type AuthContext ¶
type AuthContext struct { UserID int Created time.Time Updated time.Time Username string Email string UserType string URL *string Location *string Bio *string SuspensionNotice *string AuthMethod int // Only filled out if AuthMethod == AUTH_INTERNAL InternalAuth InternalAuth // Only filled out if AuthMethod == AUTH_OAUTH2 OAuth2Token *OAuth2Token Access map[string]string }
func ForContext ¶
func ForContext(ctx context.Context) *AuthContext
type AuthCookie ¶
type AuthCookie struct { // The username of the authenticated user Name string `json:"name"` }
type InternalAuth ¶
type InternalAuth struct { // The username of the authenticated user Name string `json:"name"` // An arbitrary identifier for this internal user, e.g. "git.sr.ht" ClientID string `json:"client_id"` // An arbitrary identifier for this internal node, e.g. "us-east-3.git.sr.ht" NodeID string `json:"node_id"` // Only used by specific meta.sr.ht routes OAuthClientUUID string `json:"oauth_client_id",omit-empty` }
type OAuth2Token ¶
type OAuth2Token struct { Version uint Expires Timestamp Grants string ClientID string Username string }
func DecodeToken ¶
func DecodeToken(token string) *OAuth2Token
func (*OAuth2Token) Encode ¶
func (ot *OAuth2Token) Encode() string
Click to show internal directories.
Click to hide internal directories.