Documentation ¶
Index ¶
Constants ¶
View Source
const ( //TokenTypeAccess is used to specify access token while validating token TokenTypeAccess = "access" //TokenTypeRefresh is used to specify refresh token while validating token TokenTypeRefresh = "refresh" //TokenTypeFresh is used to specify fresh token while validating token TokenTypeFresh = "fresh" )
View Source
const ( //ScopesConfigDivider is the character through which scope is divided ScopesConfigDivider = ":" //ScopesConfigAllTag is used to identify all entities except current ScopesConfigAllTag = "@ALL" //ScopesConfigMeTag is used to identify current entity ScopesConfigMeTag = "@ME" //ScopeConfigUserScope is the beginning of a user scope ScopeConfigUserScope = "user" )
View Source
const ( //UsersService is used to name and locate users service UsersService = "users-srv" //JWTService is used to name and locate jwt service JWTService = "jwt-srv" //EmailVerificationSrv is used to name and locate email verification service EmailVerificationSrv = "email-verification-srv" //AuthServerService is used to name and locate auth server service AuthServerService = "auth-server-srv" //ResourceServerService is iused to name and locate resource server service ResourceServerService = "resource-server-srv" )
View Source
const ( UserDataConfigGenderTypeMale = "male" UserDataConfigGenderTypeFemale = "female" UserDataConfigGenderTypeOther = "other" )
genderTypes
View Source
const ( //DebugMode is used to set if velocity is running in debug mode DebugMode = true )
View Source
const (
//InternalServerError Is when internal server error
InternalServerError = "Internal Server Error"
)
View Source
const (
//InvalidInputMsg is used when inputs are invalid
InvalidInputMsg = "Invalid Inputs"
)
Variables ¶
View Source
var ( //AuthServerConfigIPAddresses the ips where auth server will run AuthServerConfigIPAddresses = getStringSliceConfig("authServer.ipAddresses", authServerConfigManager) //AuthServerConfigPort is the port where auth server will run AuthServerConfigPort = getIntConfig("authServer.port", authServerConfigManager) //AuthServerConfigTokenField Is token field in request AuthServerConfigTokenField = getStringConfig("authServer.request.tokenField", authServerConfigManager) //AuthServerConfigScopesField Is scopes field in request AuthServerConfigScopesField = getStringConfig("authServer.request.scopesField", authServerConfigManager) //AuthServerConfigVerificationCodeField is verification code's field name AuthServerConfigVerificationCodeField = getStringConfig("authServer.request.verificationCodeField", authServerConfigManager) //AuthServerConfigErrField is err field of response AuthServerConfigErrField = getStringConfig("authServer.response.errField", authServerConfigManager) //AuthServerConfigAccessTokenField is field of access token AuthServerConfigAccessTokenField = getStringConfig("authServer.response.accessTokenField", authServerConfigManager) //AuthServerConfigRefreshTokenField is field of refresh token AuthServerConfigRefreshTokenField = getStringConfig("authServer.response.refreshTokenField", authServerConfigManager) //AuthServerConfigShowError should server show error AuthServerConfigShowError = getBoolConfig("authServer.response.showError", authServerConfigManager) )
View Source
var ( //DBConfigMongoDBAddress MongoDb Address DBConfigMongoDBAddress = getStringConfig("database.address", dbConfigManager) //DBConfigTimeout Is The Timeout While Connecting To MongoDB DBConfigTimeout = time.Duration(getIntConfig("database.timeoutSeconds", dbConfigManager)) * time.Second //DBConfigMainDB Is The ZeroTechhDB Name DBConfigMainDB = getStringConfig("database.zerotechhDB", dbConfigManager) //DBConfigUserMainDataCollection Is UserData Collection DBConfigUserMainDataCollection = getStringConfig("database.zerotechhDB.UserDataCollection", dbConfigManager) //DBConfigUserExtraDataCollection Is Where Extra Data Is Stored DBConfigUserExtraDataCollection = getStringConfig("database.zerotechhDB.UserExtraDataCollection", dbConfigManager) //DBConfigUserMetaDataCollection Is Where User's meta Data Is Stored DBConfigUserMetaDataCollection = getStringConfig("database.zerotechhDB.UserMetaDataCollection", dbConfigManager) )
View Source
var ( //VerificationMainCollection is the main collection where data will be stored VerificationMainCollection = getStringConfig("verificationCollection", verificationConfig) //VerificationExpirationTimeMinutes is time in which email verification code will expire VerificationExpirationTimeMinutes = time.Minute * time.Duration(getIntConfig("verificationExpirationTimeMinutes", verificationConfig)) //VerificationCleanerSleepTime is time after which cleaner runs VerificationCleanerSleepTime = time.Hour * time.Duration(getIntConfig("verificationCleanerSleepHour", verificationConfig)) //SMTPAddress is the smtp server address SMTPAddress = getStringConfig("smtp.Address", verificationConfig) //SMTPPort is the smtp server port SMTPPort = getIntConfig("smtp.Port", verificationConfig) //SMTPEmail is the smtp server's email SMTPEmail = getStringConfig("smtp.Email", verificationConfig) //SMTPPassword is the smtp server's password SMTPPassword = getStringConfig("smtp.Password", verificationConfig) )
View Source
var ( //JWTSecret is used sign jwts JWTSecret = []byte(getStringConfig("jwt.secret", jWTConfigManager)) //JWTAccessExpirationMinutes is used to add expiration time to access token JWTAccessExpirationMinutes = time.Minute * time.Duration(getIntConfig("jwt.accessTokenExpirationTimeMinutes", jWTConfigManager)) //JWTFreshAccessExpirationMinutes is used to add expiration time to fresh token JWTFreshAccessExpirationMinutes = time.Minute * time.Duration(getIntConfig("jwt.freshAccessTokenExpirationTimeMinutes", jWTConfigManager)) //JWTRefreshExpirationDays is used to add expiration time to refresh access token JWTRefreshExpirationDays = time.Hour * 24 * time.Duration(getIntConfig("jwt.refreshTokenExpirationTimeDays", jWTConfigManager)) )
View Source
var ( //InvalidTokenMsg is when token is invalid InvalidTokenMsg = "Invalid Token" //TokenExpiredMsg is when token has expired TokenExpiredMsg = "Token Has Expired" //InvalidScopesMsg is when scopes are invalid InvalidScopesMsg = "Invalid Scopes" )
View Source
var ( //ResourceSrvConfigJWTHeader is the key to jwt token header ResourceSrvConfigJWTHeader = resourceServerConfigManager.GetString("resourceServer.jwtHeader") //ResourceSrvConfigUserIDKey is the key to user id ResourceSrvConfigUserIDKey = resourceServerConfigManager.GetString("resourceServer.userIDKey") //ResourceSrvConfigScopesKey is the key to scopes ResourceSrvConfigScopesKey = resourceServerConfigManager.GetString("resourceServer.scopesKey") )
View Source
var ( //UserDataConfigAccountStatusActive Is Active Status UserDataConfigAccountStatusActive = getStringConfig("userData.userExtraData.accountStatus.Active", userDataConfigManager) //UserDataConfigAccountStatusUnactivated Is Unactivated Status UserDataConfigAccountStatusUnactivated = getStringConfig("userData.userExtraData.accountStatus.Unactivated", userDataConfigManager) //UserDataConfigAccountStatusDeleted Is Deleted Status UserDataConfigAccountStatusDeleted = getStringConfig("userData.userExtraData.accountStatus.Deleted", userDataConfigManager) //UserDataConfigUserIDCharset Is All Character Which Can Be Used In UserID UserDataConfigUserIDCharset = getStringConfig("userData.userID.charset", userDataConfigManager) //UserDataConfigUserIDLength Is Length Of UserID UserDataConfigUserIDLength = getIntConfig("userData.userID.length", userDataConfigManager) )
View Source
var ( //Main Data //UsernameLengthRange is username max and min len UserDataConfigUsernameLengthRange = [2]int{3, 16} //EmailLengthRange is email max and min len UserDataConfigEmailLengthRange = [2]int{5, 100} //PasswordLengthRange is password max and min len UserDataConfigPasswordLengthRange = [2]int{5, 100} //Extra Data //FirstNameLengthRange is First max and min len UserDataConfigFirstNameLengthRange = [2]int{5, 100} //LastNameLengthRange is Last max and min len UserDataConfigLastNameLengthRange = [2]int{5, 100} //MinimumAge is minimum age required to join UserDataConfigMinimumAge = 14 )
Length Ranges
View Source
var ( //UserDoesNotExistMsg is when user does not exists UserDoesNotExistMsg = "User Does Not Exists" //InvalidPasswordMsg is when password is invalid InvalidPasswordMsg = "Invalid Password" //UsernameExistMsg is when username is already taken UsernameExistMsg = "Username Already Exists" //EmailExistMsg is when email is already taken EmailExistMsg = "Email Already Exists" //InvalidUsernameAndEmailMsg is when username and email is invalid InvalidUsernameAndEmailMsg = "Invalid Username And Email" //InvalidAuthDataMsg is when auth data is incorrect InvalidAuthDataMsg = "Invalid Authentication Credentials" //InvalidUserDataMsg is when user data is not valid InvalidUserDataMsg = "Invalid User Data" //InvalidUsernameOrEmailMsg is when either username or email is invalid InvalidUsernameOrEmailMsg = "Invalid Username Or Email" )
View Source
var (
//LogConfigLogLevel is the logging level
LogConfigLogLevel = getStringConfig("loggingLevel", logConfigManager)
)
View Source
var UserDataConfigGenderTypes = []string{UserDataConfigGenderTypeMale, UserDataConfigGenderTypeFemale, UserDataConfigGenderTypeOther}
UserDataConfigGenderTypes is all gender types
Functions ¶
func DefaultErrorHandler ¶ added in v0.6.0
func DefaultErrorHandler(err error, data ...interface{}) interface{}
DefaultErrorHandler is used to log an error and then return a wrappeed version of that error
Types ¶
type CustomError ¶
type CustomError struct {
// contains filtered or unexported fields
}
CustomError is custom error type
func (CustomError) Error ¶
func (customError CustomError) Error() string
type JWTClaims ¶ added in v0.1.0
type JWTClaims struct { UserIdentity string `json:"UserIdentity"` IsFresh bool `json:"IsFresh"` IsRefresh bool `json:"IsRefresh"` Scopes []string `json:"Scopes"` CreationUTC int64 `json:"CreationUTC"` ExpirationUTC int64 `json:"ExpirationUTC"` jwt.StandardClaims }
JWTClaims is used to store jwt claims
type UserExtra ¶ added in v0.1.1
type UserExtra struct { UserID string `bson:"_id,omitempty,-" readScope:"user:read:user_id"` FirstName string `bson:"FirstName,omitempty,-" readScope:"user:read:first_name"` LastName string `bson:"LastName,omitempty,-" readScope:"user:read:last_name"` Gender string `bson:"Gender,omitempty,-" readScope:"user:read:gender"` BirthdayUTC int64 `bson:"BirthdayUTC,omitempty,-" readScope:"user:read:birthday_utc"` }
UserExtra is used to store user extra data
type UserMain ¶ added in v0.1.1
type UserMain struct { UserID string `bson:"_id,omitempty,-" isArg:"true" description:"Unique User Identity" readScope:"user:read:user_id"` Username string `bson:"Username,omitempty,-" isArg:"true" description:"Username of the user" readScope:"user:read:username"` Email string `bson:"Email,omitempty,-" isArg:"true" description:"Email of the user" readScope:"user:read:email"` Password string `bson:"Password,omitempty,-" exclude:"true"` }
UserMain is used to store user main data
type UserMeta ¶ added in v0.1.1
type UserMeta struct { UserID string `bson:"_id,omitempty,-"` AccountStatus string `bson:"AccountStatus,omitempty,-"` AccountCreationUTC int64 `bson:"AccountCreationUTC,omitempty,-"` }
UserMeta is used to store user meta data
type VerificationCode ¶ added in v0.3.0
type VerificationCode struct { ID string `bson:"_id,omitempty,-"` Code string `bson:"code,omitempty,-"` CreationUTC int64 `bson:"creationUTC,omitempty,-"` }
VerificationCode is used to store verification data into db
Source Files ¶
Click to show internal directories.
Click to hide internal directories.