Documentation
¶
Index ¶
- Constants
- Variables
- func NewGithubOAuthURI() (string, error)
- func NewPassword(pwd string) (password, error)
- func NewPasswordByBytes(bytes []byte) password
- func PublishUserCreatedEvent(userID int64)
- type Config
- type Error
- type Event
- type GithubOAuthToken
- type GithubUserPublicProfile
- type ThirdPartyOAuthToken
- func (token ThirdPartyOAuthToken) Active() bool
- func (token ThirdPartyOAuthToken) CreatedAt() time.Time
- func (token ThirdPartyOAuthToken) ID() int64
- func (token *ThirdPartyOAuthToken) Save() (err error)
- func (token ThirdPartyOAuthToken) Scope() string
- func (token ThirdPartyOAuthToken) SetID(id int64)
- func (token ThirdPartyOAuthToken) Token() string
- func (token ThirdPartyOAuthToken) Type() ThirdPartyTokenType
- func (token ThirdPartyOAuthToken) UpdatedAt() time.Time
- func (token ThirdPartyOAuthToken) UserID() int64
- type ThirdPartyTokenType
- type User
- func GetUserByGithubOAuth(code, state string) (User, error)
- func GetUserBySessionToken(tokenType sessionTokenType, token string) (User, error)
- func GetUserByUserName(userName string) (User, error)
- func NewUser(id int64, createdAt time.Time, updatedAt time.Time, name string, ...) User
- func RegisterUser(userName, nickname, pwd string) (User, error)
- func (user User) Avatar() string
- func (user User) CreatedAt() time.Time
- func (user User) Email() string
- func (user User) GithubId() int64
- func (user User) Id() int64
- func (user User) Name() string
- func (user User) Nickname() string
- func (user User) Password() password
- func (user *User) Session() session
- func (user *User) SetID(id int64)
- func (user User) Telephone() string
- func (user User) UpdatedAt() time.Time
- type UserInvalidRefreshToken
Constants ¶
View Source
const ( AccessToken sessionTokenType = iota RefreshToken )
View Source
const (
EventUserCreated = "UserCreated"
)
View Source
const OAuthStateLen = 10
Variables ¶
View Source
var EventPublisher interface { Publish(event string, payload []byte) Subscribe(event string, cb func([]byte)) func() }
View Source
var GithubAdapter interface { CreateOAuthURI(state string) (string, error) FetchOAuthToken(code string) (GithubOAuthToken, error) FetchUserPublicProfile(token string) (GithubUserPublicProfile, error) }
View Source
var InvalidCredential = fmt.Errorf("invalid credential.")
View Source
var InvalidPassword = fmt.Errorf("invalid password.")
View Source
var ThirdPartyOAuthTokenRepository interface { Save(entity *ThirdPartyOAuthToken) error SaveByUserIDAndType(entity *ThirdPartyOAuthToken) error ExistActiveOne(userID int64, tokenType ThirdPartyTokenType) (bool, error) }
View Source
var UserInvalidRefreshTokenRepository interface { Save(entity *UserInvalidRefreshToken) error Exist(userID int64, tokenID string) (bool, error) }
View Source
var UserNameDuplicate = fmt.Errorf("user name has been used.")
View Source
var UserNameTooShort = fmt.Errorf("user name too short.")
View Source
var UserRepository interface { Save(entity *User) error Find(id int64) (User, error) FindByUserName(username string) (User, error) FindByGithubID(githubID int64) (User, error) FindByTodo(todoID int64) (User, error) ExistByUserName(username string) (bool, error) ExistByGithubID(githubID int64) (bool, error) }
Functions ¶
func NewGithubOAuthURI ¶
func NewPassword ¶
func NewPasswordByBytes ¶
func NewPasswordByBytes(bytes []byte) password
func PublishUserCreatedEvent ¶
func PublishUserCreatedEvent(userID int64)
Types ¶
type Config ¶
type Config struct { AccessTokenExpiresIn int // second AccessTokenRefreshThreshold int // second RefreshTokenExpiresInDefault int // second RefreshTokenExpiresInMax int // second RefreshTokenExpiresInOAuth int // second OAuthStateExpiresIn int // second TokenIssuer string // secret PasswordNonce []byte TokenHmacSecret []byte }
type GithubOAuthToken ¶
type GithubUserPublicProfile ¶
type ThirdPartyOAuthToken ¶
type ThirdPartyOAuthToken struct {
// contains filtered or unexported fields
}
aggregate
func NewThirdPartyOAuthToken ¶
func (ThirdPartyOAuthToken) Active ¶
func (token ThirdPartyOAuthToken) Active() bool
func (ThirdPartyOAuthToken) CreatedAt ¶
func (token ThirdPartyOAuthToken) CreatedAt() time.Time
func (ThirdPartyOAuthToken) ID ¶
func (token ThirdPartyOAuthToken) ID() int64
func (*ThirdPartyOAuthToken) Save ¶
func (token *ThirdPartyOAuthToken) Save() (err error)
func (ThirdPartyOAuthToken) Scope ¶
func (token ThirdPartyOAuthToken) Scope() string
func (ThirdPartyOAuthToken) SetID ¶
func (token ThirdPartyOAuthToken) SetID(id int64)
func (ThirdPartyOAuthToken) Token ¶
func (token ThirdPartyOAuthToken) Token() string
func (ThirdPartyOAuthToken) Type ¶
func (token ThirdPartyOAuthToken) Type() ThirdPartyTokenType
func (ThirdPartyOAuthToken) UpdatedAt ¶
func (token ThirdPartyOAuthToken) UpdatedAt() time.Time
func (ThirdPartyOAuthToken) UserID ¶
func (token ThirdPartyOAuthToken) UserID() int64
type ThirdPartyTokenType ¶
type ThirdPartyTokenType int8
value object
const (
ThirdPartyTokenTypeGithubAccessToken ThirdPartyTokenType = 10*iota + 11
)
type User ¶
type User struct {
// contains filtered or unexported fields
}
func GetUserByGithubOAuth ¶
func GetUserBySessionToken ¶
func GetUserByUserName ¶
func RegisterUser ¶
Click to show internal directories.
Click to hide internal directories.