Documentation ¶
Index ¶
- func NewAuthFlowToken(redirectURI string, realm string, exp time.Time) *jwt.Token
- func NewAuthedTokenParser(key []byte) func(signedToken string) (*AuthenticatedClaims, error)
- func NewAuthenticatedToken(identity discord.User, realm string, exp time.Time) *jwt.Token
- func NewFlowTokenParser(key []byte) func(signedToken string) (*FlowTokenParser, error)
- func ResourceRequiresGuild(resource DiscordResource) bool
- func RoleChecker(desiredRoleID string, roles []string) string
- type AccessIdentifier
- type AuthedTokenParserSignature
- type AuthenticatedClaims
- type CustomClaim
- type DiscordAuthPlugin
- func (DiscordAuthPlugin) CaddyModule() caddy.ModuleInfo
- func (s *DiscordAuthPlugin) Provision(ctx caddy.Context) error
- func (d DiscordAuthPlugin) ServeHTTP(w http.ResponseWriter, r *http.Request, _ caddyhttp.Handler) error
- func (s *DiscordAuthPlugin) UnmarshalCaddyfile(d *caddyfile.Dispenser) error
- func (s *DiscordAuthPlugin) Validate() error
- type DiscordPortalApp
- type DiscordResource
- type FlowTokenParser
- type FlowTokenParserSignature
- type JWTManager
- type ProtectCfg
- type ProtectorPlugin
- func (e ProtectorPlugin) Authenticate(w http.ResponseWriter, r *http.Request) (caddyauth.User, bool, error)
- func (ProtectorPlugin) CaddyModule() caddy.ModuleInfo
- func (p *ProtectorPlugin) Provision(ctx caddy.Context) error
- func (p *ProtectorPlugin) UnmarshalCaddyfile(d *caddyfile.Dispenser) error
- func (p *ProtectorPlugin) Validate() error
- type Realm
- type RealmBuilder
- func (r RealmBuilder) AllowAllDiscordUsers()
- func (r RealmBuilder) AllowAllGuildMembers(guildID string)
- func (r RealmBuilder) AllowDiscordUser(userID string)
- func (r RealmBuilder) AllowGuildMember(guildID string, userID string)
- func (r RealmBuilder) AllowGuildRole(guildID string, roleID string)
- func (r RealmBuilder) Build() *Realm
- func (r RealmBuilder) Name(name string)
- type RealmRegistry
- type TokenSignerSignature
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func NewAuthFlowToken ¶
func NewAuthedTokenParser ¶
func NewAuthedTokenParser(key []byte) func(signedToken string) (*AuthenticatedClaims, error)
func NewAuthenticatedToken ¶
func NewFlowTokenParser ¶
func NewFlowTokenParser(key []byte) func(signedToken string) (*FlowTokenParser, error)
func ResourceRequiresGuild ¶
func ResourceRequiresGuild(resource DiscordResource) bool
func RoleChecker ¶ added in v1.1.1
Types ¶
type AccessIdentifier ¶
type AccessIdentifier struct { Resource DiscordResource `json:"Resource"` // role, user Identifier string `json:"Identifier,omitempty"` GuildID string `json:"GuildID,omitempty"` Wildcard bool `json:"Wildcard,omitempty"` }
type AuthedTokenParserSignature ¶
type AuthedTokenParserSignature = func(signedToken string) (*AuthenticatedClaims, error)
type AuthenticatedClaims ¶
type AuthenticatedClaims struct { Realm string `json:"realm,omitempty"` Username string `json:"user,omitempty"` Avatar string `json:"avatar,omitempty"` jwt.RegisteredClaims }
func (AuthenticatedClaims) GetAudience ¶
func (a AuthenticatedClaims) GetAudience() string
type CustomClaim ¶
type CustomClaim interface { jwt.Claims }
type DiscordAuthPlugin ¶
type DiscordAuthPlugin struct { Configuration []string OAuth *oauth2.Config Realms *RealmRegistry Key string // contains filtered or unexported fields }
func (DiscordAuthPlugin) CaddyModule ¶
func (DiscordAuthPlugin) CaddyModule() caddy.ModuleInfo
func (*DiscordAuthPlugin) Provision ¶
func (s *DiscordAuthPlugin) Provision(ctx caddy.Context) error
func (DiscordAuthPlugin) ServeHTTP ¶
func (d DiscordAuthPlugin) ServeHTTP(w http.ResponseWriter, r *http.Request, _ caddyhttp.Handler) error
ServeHTTP implements caddyhttp.MiddlewareHandler.
func (*DiscordAuthPlugin) UnmarshalCaddyfile ¶
func (s *DiscordAuthPlugin) UnmarshalCaddyfile(d *caddyfile.Dispenser) error
UnmarshalCaddyfile will extract discordauth directives on a server-level
route /some/path/callback { discordauth callback }
func (*DiscordAuthPlugin) Validate ¶
func (s *DiscordAuthPlugin) Validate() error
type DiscordPortalApp ¶
type DiscordPortalApp struct { ClientID string `json:"clientID"` ClientSecret string `json:"clientSecret"` RedirectURL string `json:"redirectURL"` Realms RealmRegistry `json:"realms"` Key string `json:"key,omitempty"` // contains filtered or unexported fields }
func (DiscordPortalApp) CaddyModule ¶
func (DiscordPortalApp) CaddyModule() caddy.ModuleInfo
CaddyModule returns the Caddy module information.
func (*DiscordPortalApp) Provision ¶
func (d *DiscordPortalApp) Provision(_ caddy.Context) error
func (DiscordPortalApp) Start ¶
func (d DiscordPortalApp) Start() error
func (DiscordPortalApp) Validate ¶
func (d DiscordPortalApp) Validate() error
type DiscordResource ¶
type DiscordResource int
const ( Unknown DiscordResource = 0 DiscordGuildRule DiscordResource = 1 DiscordRoleRule DiscordResource = 2 // DiscordMemberRule represents a specific Discord User within a specific guild DiscordMemberRule DiscordResource = 3 // DiscordUserRule represents a Discord User Snowflake ID DiscordUserRule DiscordResource = 4 )
type FlowTokenParser ¶
type FlowTokenParser struct { Realm string `json:"realm,omitempty"` RedirectURI string `json:"redirectURI,omitempty"` jwt.RegisteredClaims }
func (FlowTokenParser) GetAudience ¶
func (f FlowTokenParser) GetAudience() string
type FlowTokenParserSignature ¶
type FlowTokenParserSignature = func(signedToken string) (*FlowTokenParser, error)
type JWTManager ¶
type JWTManager struct {
// contains filtered or unexported fields
}
type ProtectCfg ¶
type ProtectorPlugin ¶
type ProtectorPlugin struct { OAuthConfig *oauth2.Config Realm string // contains filtered or unexported fields }
func (ProtectorPlugin) Authenticate ¶
func (e ProtectorPlugin) Authenticate(w http.ResponseWriter, r *http.Request) (caddyauth.User, bool, error)
Authenticate implements caddyhttp.MiddlewareHandler.
func (ProtectorPlugin) CaddyModule ¶
func (ProtectorPlugin) CaddyModule() caddy.ModuleInfo
func (*ProtectorPlugin) Provision ¶
func (p *ProtectorPlugin) Provision(ctx caddy.Context) error
func (*ProtectorPlugin) UnmarshalCaddyfile ¶
func (p *ProtectorPlugin) UnmarshalCaddyfile(d *caddyfile.Dispenser) error
func (*ProtectorPlugin) Validate ¶
func (p *ProtectorPlugin) Validate() error
type Realm ¶
type Realm struct { Ref string `json:"Ref"` Identifiers []*AccessIdentifier `json:"Identifiers"` }
func (Realm) GetAllGuilds ¶
type RealmBuilder ¶
type RealmBuilder struct {
// contains filtered or unexported fields
}
func NewRealmBuilder ¶
func NewRealmBuilder() RealmBuilder
func (RealmBuilder) AllowAllDiscordUsers ¶
func (r RealmBuilder) AllowAllDiscordUsers()
func (RealmBuilder) AllowAllGuildMembers ¶
func (r RealmBuilder) AllowAllGuildMembers(guildID string)
func (RealmBuilder) AllowDiscordUser ¶
func (r RealmBuilder) AllowDiscordUser(userID string)
func (RealmBuilder) AllowGuildMember ¶
func (r RealmBuilder) AllowGuildMember(guildID string, userID string)
func (RealmBuilder) AllowGuildRole ¶
func (r RealmBuilder) AllowGuildRole(guildID string, roleID string)
func (RealmBuilder) Build ¶
func (r RealmBuilder) Build() *Realm
func (RealmBuilder) Name ¶
func (r RealmBuilder) Name(name string)
type RealmRegistry ¶
type RealmRegistry []*Realm
func (RealmRegistry) ByName ¶
func (r RealmRegistry) ByName(name string) *Realm
type TokenSignerSignature ¶
func NewTokenSigner ¶
func NewTokenSigner(key []byte) TokenSignerSignature
Source Files ¶
Click to show internal directories.
Click to hide internal directories.