Documentation
¶
Index ¶
- Constants
- Variables
- func MarshalJSONOptionStruct(s interface{}) ([]byte, error)
- type ChangeEmailRequest
- type CompleteRegistrationRequest
- type DeleteUserResponse
- type DeleteUsersRequest
- type Email
- type ExchangeSocialLoginRequest
- type ExchangeSocialLoginResponse
- type GetUsersRequest
- type GetUsersResponse
- type IdTokenClaims
- type InsertUsersRequest
- type InsertUsersResponse
- type InstructEmailChangeRequest
- type InstructPasswordResetRequest
- type LoginRequest
- type LoginResponse
- type LogoutRequest
- type NewUser
- type Option
- type RegistrationRequest
- type ResetPasswordRequest
- type Scopes
- type Selection
- type Server
- func (server *Server) CompleteRegistration(ctx context.Context, sub string, email string) (err error)
- func (server *Server) InstructEmailChange(ctx context.Context, sub string, email string) (err error)
- func (server *Server) Login(ctx context.Context, aud string, username string, password string, ...) (refreshToken string, accessToken string, grantedScopes []string, ...)
- func (server *Server) ServeHTTP(resp http.ResponseWriter, req *http.Request)
- func (server *Server) SocialLogin(iss string, redirectUri string) (redirectUri2 string, err error)
- type SessionSelection
- type SessionStore
- type Social
- type SocialLoginRequest
- type SocialLoginResponse
- type SocialProvider
- func (p SocialProvider) Exchange(ctx context.Context, server *Server, code string) (*openid.TokenResponse, error)
- func (p SocialProvider) OAuth2Config(server *Server) *oauth2.Config
- func (p SocialProvider) Token(ctx context.Context, server *Server, a *openid.AuthResponse) (t *openid.TokenResponse, err error)
- func (p SocialProvider) Userinfo(ctx context.Context, server *Server, t *openid.TokenResponse) (info *openid.Userinfo, err error)
- type Store
- type UpdateSessionRequest
- type UpdateSessionResponse
- type UpdateUserResponse
- type UpdateUsersRequest
- type User
- type UserStore
- type UserUpdate
- type Userinfo
Constants ¶
View Source
const AudChangeEmail = "_change_email"
View Source
const Audience = "aud"
View Source
const ExpiresAt = "exp"
View Source
const IdentAudience = "_ident"
View Source
const IssuedAt = "iat"
View Source
const Issuer = "iss"
View Source
const RegistrationAud = "_complete_registration"
View Source
const ResetPasswordAud = "_reset_password"
View Source
const Subject = "sub"
Variables ¶
View Source
var ErrInvalidCredentials = e("invalid_credentials")
View Source
var ErrNoUser = openid.ErrNoUser
View Source
var _, _, Module = module.New("ident", messages)
Functions ¶
func MarshalJSONOptionStruct ¶
Types ¶
type ChangeEmailRequest ¶
type ChangeEmailRequest struct {
ChangeEmailToken string `json:"changeEmailToken"`
}
type DeleteUserResponse ¶
type DeleteUserResponse struct {
NumDeleted int `json:"numDeleted"`
}
type DeleteUsersRequest ¶
type DeleteUsersRequest = Selection
type ExchangeSocialLoginRequest ¶
type ExchangeSocialLoginRequest struct {
Auth openid.AuthResponse `json:"auth"`
Scope string `json:"scope"`
Nonce string `json:"nonce"`
RedirectUri string `json:"redirectUri"`
}
type ExchangeSocialLoginResponse ¶
type ExchangeSocialLoginResponse = openid.TokenResponse
type GetUsersRequest ¶
type GetUsersResponse ¶
type IdTokenClaims ¶
func (IdTokenClaims) Valid ¶
func (claims IdTokenClaims) Valid() error
type InsertUsersRequest ¶
type InsertUsersResponse ¶
type InsertUsersResponse struct {
Ids []string `json:"ids"`
}
type InstructEmailChangeRequest ¶
type InstructEmailChangeRequest struct {
Email string `json:"email"`
}
type LoginRequest ¶
type LoginResponse ¶
type LoginResponse = openid.TokenResponse
type LogoutRequest ¶
type LogoutRequest struct {
RefreshToken string `json:"refreshToken"`
}
type Option ¶
type Option[T any] struct { // Value is the value of the option. Value T // Valid is true if the value is set. Valid bool }
func (Option[T]) MarshalJSON ¶
func (*Option[T]) UnmarshalJSON ¶
type RegistrationRequest ¶
type ResetPasswordRequest ¶
type Selection ¶
type Server ¶
type Server struct {
*openid.Server
Api map[string]http.Handler
ScopeAdmin string
SessionStore SessionStore
UserStore UserStore
EmailHost string
EmailHostPort int
EmailFrom string
EmailFromDisplayName string
EmailEnableTLS bool
EmailEnaleStartTLS bool
EmailEnableAuthentication bool
EmailUsername string
EmailPassword string
CompleteRegistrationTemplate *template.Template
CompleteRegistrationSubject string
ChangeEmailTemplate *template.Template
ChangeEmailSubject string
PasswordResetTemplate *template.Template
PasswordResetSubject string
PasswordResetDelay time.Duration
PasswordResetTokenExpiry time.Duration
SendMail func(addr string, a smtp.Auth, from string, to []string, msg []byte) error
// contains filtered or unexported fields
}
func NewServer ¶
func NewServer(addr string, sessionStore SessionStore, userStore UserStore, socials []*SocialProvider, next http.Handler) *Server
func (*Server) CompleteRegistration ¶
func (*Server) InstructEmailChange ¶
type SessionSelection ¶
type SessionStore ¶
type SocialLoginRequest ¶
type SocialLoginResponse ¶
type SocialLoginResponse struct {
RedirectUri string `json:"redirectUri"`
}
type SocialProvider ¶
type SocialProvider struct {
Scope string
ClientId string
ClientSecret string
Config *openid.Configuration
}
func (SocialProvider) Exchange ¶
func (p SocialProvider) Exchange(ctx context.Context, server *Server, code string) (*openid.TokenResponse, error)
func (SocialProvider) OAuth2Config ¶
func (p SocialProvider) OAuth2Config(server *Server) *oauth2.Config
func (SocialProvider) Token ¶
func (p SocialProvider) Token(ctx context.Context, server *Server, a *openid.AuthResponse) (t *openid.TokenResponse, err error)
type Store ¶
type Store interface {
UserStore
SessionStore
}
type UpdateSessionRequest ¶
type UpdateSessionRequest struct {
SessionSelection
AddScopes []string `json:"addScopes"`
RemoveScopes []string `json:"removeScopes"`
}
type UpdateSessionResponse ¶
type UpdateSessionResponse struct {
NumUpdated int `json:"numUpdated"`
}
type UpdateUserResponse ¶
type UpdateUserResponse struct {
NumUpdated int `json:"numUpdated"`
}
type UpdateUsersRequest ¶
type UpdateUsersRequest struct {
Selection Selection `json:"sel"`
UserUpdate UserUpdate `json:"update"`
}
type UserStore ¶
type UserStore interface {
openid.UserStore
LoginUser(ctx context.Context, username string, password string) (sub string, err error)
RegisterUsers(ctx context.Context, iss string, ignoreEmails bool, users []*NewUser) (ids []string, err error)
UpdateUsers(ctx context.Context, sel Selection, u *UserUpdate) (numUpdated int, err error)
DeleteUsers(ctx context.Context, sel Selection) (numDeleted int, err error)
FindUsers(ctx context.Context, sel Selection, pageToken string, pageSize int) (users []*User, nextPageToken string, err error)
CountUsers(ctx context.Context, sel Selection) (numSel int, numTotal int, err error)
}
type UserUpdate ¶
type UserUpdate struct {
Name Option[string] `json:"name,omitempty"`
GivenName Option[string] `json:"given_name,omitempty"`
FamilyName Option[string] `json:"family_name,omitempty"`
MiddleName Option[string] `json:"middle_name,omitempty"`
Nickname Option[string] `json:"nickname,omitempty"`
PreferredUsername Option[string] `json:"preferred_username,omitempty"`
// requires priviliged scope
PreferredUsernameVerified Option[bool] `json:"preferred_username_verified,omitempty"`
Email Option[string] `json:"email,omitempty"`
// requires priviliged scope
EmailVerified Option[bool] `json:"email_verified,omitempty"`
Gender Option[string] `json:"gender,omitempty"`
Birthdate Option[string] `json:"birthdat,omitempty"`
Zoneinfo Option[string] `json:"zoneinfo,omitempty"`
Locale Option[string] `json:"locale,omitempty"`
PhoneNumber Option[string] `json:"phone_number,omitempty"`
// requires priviliged scope
PhoneNumberVerified Option[bool] `json:"phone_number_verified,omitempty"`
Address *openid.Address `json:"address,omitempty"`
// requires priviliged scope
Suspended Option[bool] `json:"suspended,omitempty"`
NewPassword Option[string] `json:"new_password,omitempty"`
// omitting this field requires priviliged scope
OldPassword Option[string] `json:"old_password,omitempty"`
}
func (UserUpdate) MarshalJSON ¶
func (u UserUpdate) MarshalJSON() ([]byte, error)
Source Files
¶
Click to show internal directories.
Click to hide internal directories.