Documentation
¶
Index ¶
- Variables
- func AppendWebConfigCookie(ctx *context.Context) error
- func AuthzRuleToSlice(rule AuthzRule) []string
- func BoolToString(b bool) string
- func CamelToSnakeCase(camel string) string
- func DeleteVal(values []string, val string) []string
- func FileExist(path string) bool
- func FilterField(field string) bool
- func FilterQuery(urlString string, blackList []string) string
- func GenerateClientId() string
- func GenerateClientSecret() string
- func GenerateId() string
- func GeneratePasswordSalt() string
- func GenerateSimpleTimeId() string
- func GenerateTimeId() string
- func GenerateTwoUniqueRandomStrings() (string, string, error)
- func GenerateVerboseReason(ruleId string, expressionReason string, customReason string) string
- func GetBaseDomain(domain string) (string, error)
- func GetCertExpireTime(s string) (string, error)
- func GetClientIp(r *http.Request) string
- func GetClientIpFromRequest(req *http.Request) string
- func GetCountryCode(prefix string, phone string) (string, error)
- func GetCurrentTime() string
- func GetCurrentTimeEx(timestamp string) string
- func GetCurrentUnixTime() string
- func GetE164Number(phone string, countryCode string) (string, bool)
- func GetEndPoint(endpoint string) string
- func GetHmacSha1(keyStr, value string) string
- func GetHmacSha256(key string, data string) string
- func GetHostname() string
- func GetId(owner, name string) string
- func GetMaskedEmail(email string) string
- func GetMaskedPhone(phone string) string
- func GetMd5Hash(text string) string
- func GetOwnerAndNameAndOtherFromId(id string) (string, string, string)
- func GetOwnerAndNameFromIdNoCheck(id string) (string, string)
- func GetOwnerAndNameFromIdWithError(id string) (string, string, error)
- func GetOwnerFromId(id string) string
- func GetPath(path string) string
- func GetRandomName() string
- func GetSeperatedPhone(phone string) string
- func GetSessionId(owner, name, application string) string
- func GetSharedOrgFromApp(rawName string) (name string, organization string)
- func GetUnobfuscatedPassword(passwordObfuscatorType string, passwordObfuscatorKey string, ...) (string, error)
- func GetUploadXlsxPath(fileId string) string
- func GetUrlHost(urlString string) string
- func GetUrlPath(urlString string) string
- func GetUsernameFromEmail(email string) string
- func GetValueFromDataSourceName(key string, dataSourceName string) string
- func HasString(strs []string, str string) bool
- func HasTagInSlice(slice []string, userTag string) bool
- func HaveIntersection(arr1 []string, arr2 []string) bool
- func InSlice(slice []string, elem string) bool
- func IsChinese(str string) bool
- func IsEmailValid(email string) bool
- func IsHostIntranet(ip string) bool
- func IsInternetIp(ip string) bool
- func IsIntranetIp(ip string) bool
- func IsInvitationCodeMatch(pattern string, invitationCode string) (bool, error)
- func IsPhoneAllowInRegin(countryCode string, allowRegions []string) bool
- func IsPhoneValid(phone string, countryCode string) bool
- func IsRegexp(s string) (bool, error)
- func IsStringsEmpty(strs ...string) bool
- func IsTokenExpired(createdTime string, expiresIn int) (bool, string)
- func IsValidOrigin(origin string) (bool, error)
- func JsonToStruct(data string, v interface{}) error
- func ListFiles(path string) []string
- func LoadCACertPool(cert string) (*x509.CertPool, error)
- func LogInfo(ctx *context.Context, f string, v ...interface{})
- func LogWarning(ctx *context.Context, f string, v ...interface{})
- func ParseBool(s string) bool
- func ParseFloat(s string) float64
- func ParseIdToString(input interface{}) (string, error)
- func ParseInt(s string) int
- func ParseIntWithError(s string) (int, error)
- func PingUrl(url string) (bool, string)
- func ReadStringFromPath(path string) string
- func RemoveExt(filename string) string
- func ReplaceVal(values []string, oldVal string, newVal string) []string
- func ResolveDomainToIp(domain string) string
- func ReturnAnyNotEmpty(strs ...string) string
- func SafeGoroutine(fn func())
- func SnakeString(s string) string
- func SnakeToCamel(snake string) string
- func SpaceToCamel(name string) string
- func StopOldInstance(port int) error
- func String2Time(timestamp string) time.Time
- func StringToInterfaceArray(array []string) []interface{}
- func StringToInterfaceArray2d(arrays [][]string) [][]interface{}
- func StructToJson(v interface{}) string
- func StructToJsonFormatted(v interface{}) string
- func Time2String(timestamp time.Time) string
- func TryJsonToAnonymousStruct(j string) (interface{}, error)
- func UrlJoin(base string, path string) string
- func WriteStringToPath(s string, path string)
- type AuthzRule
- type SignupRateLimiter
- type Stack
- type SystemInfo
- type VersionInfo
Constants ¶
This section is empty.
Variables ¶
var ( // IPSignupLimiter: max 3 signups per hour per IP address. IPSignupLimiter = NewSignupRateLimiter(3, 1*time.Hour) // DomainSignupLimiter: max 10 signups per hour per email domain. DomainSignupLimiter = NewSignupRateLimiter(10, 1*time.Hour) )
Global signup rate limiters.
var ( ReWhiteSpace *regexp.Regexp ReFieldWhiteList *regexp.Regexp ReUserName *regexp.Regexp ReUserNameWithEmail *regexp.Regexp )
var ( Version = "v1.0.2" CommitId = "80e0b132b78c33ee01c599c83c938860d8eb5767" CommitOffset = 3 )
Functions ¶
func AppendWebConfigCookie ¶
func AuthzRuleToSlice ¶
func BoolToString ¶
func CamelToSnakeCase ¶
CamelToSnakeCase This function transform camelcase in snakecase LoremIpsum in lorem_ipsum
func FilterField ¶
func FilterQuery ¶
func GenerateClientId ¶
func GenerateClientId() string
func GenerateClientSecret ¶
func GenerateClientSecret() string
func GenerateId ¶
func GenerateId() string
func GeneratePasswordSalt ¶
func GeneratePasswordSalt() string
func GenerateSimpleTimeId ¶
func GenerateSimpleTimeId() string
func GenerateTimeId ¶
func GenerateTimeId() string
func GenerateVerboseReason ¶
GenerateVerboseReason creates a detailed reason message for verbose mode
func GetBaseDomain ¶
func GetCertExpireTime ¶
func GetClientIp ¶
func GetClientIpFromRequest ¶
func GetCurrentTime ¶
func GetCurrentTime() string
func GetCurrentTimeEx ¶
func GetCurrentUnixTime ¶
func GetCurrentUnixTime() string
func GetHmacSha1 ¶
func GetHmacSha256 ¶
func GetHostname ¶
func GetHostname() string
func GetMaskedEmail ¶
func GetMaskedPhone ¶
func GetMd5Hash ¶
func GetOwnerFromId ¶
func GetRandomName ¶
func GetRandomName() string
func GetSeperatedPhone ¶
func GetSessionId ¶
func GetSharedOrgFromApp ¶
func GetUnobfuscatedPassword ¶
func GetUploadXlsxPath ¶
func GetUrlHost ¶
func GetUrlPath ¶
func GetUsernameFromEmail ¶
func HasTagInSlice ¶
HasTagInSlice checks if a comma-separated tag string contains any tag that matches the slice. For example, if userTag is "default-policy,project-admin" and slice is ["default-policy", "project-admin"], it will return true because "default-policy" and "project-admin" are both in the slice.
func HaveIntersection ¶
func IsEmailValid ¶
func IsHostIntranet ¶
func IsInternetIp ¶
func IsIntranetIp ¶
func IsInvitationCodeMatch ¶
func IsPhoneAllowInRegin ¶
func IsPhoneValid ¶
func IsStringsEmpty ¶
func IsValidOrigin ¶
func JsonToStruct ¶
func LoadCACertPool ¶
LoadCACertPool loads a CA certificate pool from either a file path or a PEM-encoded string. The cert parameter can be: - A file path to a PEM-encoded certificate file - A PEM-encoded certificate string (starts with "-----BEGIN") Returns nil pool and nil error if the cert is empty.
func LogWarning ¶
func ParseFloat ¶
func ParseIdToString ¶
func ParseIntWithError ¶
func ReadStringFromPath ¶
func ResolveDomainToIp ¶
func ReturnAnyNotEmpty ¶
func SafeGoroutine ¶
func SafeGoroutine(fn func())
func SnakeToCamel ¶
func SpaceToCamel ¶
func StopOldInstance ¶
func String2Time ¶
func StringToInterfaceArray ¶
func StringToInterfaceArray(array []string) []interface{}
func StringToInterfaceArray2d ¶
func StringToInterfaceArray2d(arrays [][]string) [][]interface{}
func StructToJson ¶
func StructToJson(v interface{}) string
func StructToJsonFormatted ¶
func StructToJsonFormatted(v interface{}) string
func Time2String ¶
func WriteStringToPath ¶
Types ¶
type AuthzRule ¶ added in v1.14.21
type AuthzRule = authzstore.AuthzRule
AuthzRule is the canonical Hanzo name for a policy row. It aliases the row type owned by the object/authzstore package so callers in util and controllers can manipulate policies without importing the adapter implementation directly.
func MatrixToAuthzRules ¶
type SignupRateLimiter ¶
type SignupRateLimiter struct {
// contains filtered or unexported fields
}
SignupRateLimiter enforces per-key sliding-window rate limits for signups.
func NewSignupRateLimiter ¶
func NewSignupRateLimiter(limit int, window time.Duration) *SignupRateLimiter
NewSignupRateLimiter creates a rate limiter that allows at most limit events per window duration for each key.
func (*SignupRateLimiter) Allow ¶
func (r *SignupRateLimiter) Allow(key string) error
Allow checks whether the given key is within the rate limit. Returns nil if allowed, or an error describing the limit.
func (*SignupRateLimiter) Cleanup ¶
func (r *SignupRateLimiter) Cleanup()
Cleanup removes stale entries older than the window. Call periodically to prevent memory growth in long-running processes.
type Stack ¶
type Stack struct {
// contains filtered or unexported fields
}
Stack is a stack data structure implemented using a slice
func (*Stack) Peek ¶
func (s *Stack) Peek() interface{}
Peek returns the last item from the stack without removing it
type SystemInfo ¶
type SystemInfo struct {
CpuUsage []float64 `json:"cpuUsage"`
MemoryUsed uint64 `json:"memoryUsed"`
MemoryTotal uint64 `json:"memoryTotal"`
}
func GetSystemInfo ¶
func GetSystemInfo() (*SystemInfo, error)
type VersionInfo ¶
type VersionInfo struct {
Version string `json:"version"`
CommitId string `json:"commitId"`
CommitOffset int `json:"commitOffset"`
}
func GetBuiltInVersionInfo ¶
func GetBuiltInVersionInfo() *VersionInfo
func GetVersionInfo ¶
func GetVersionInfo() (*VersionInfo, error)
GetVersionInfo get git current commit and repo release version Falls back to built-in values when .git is not available (e.g., in Docker)