-
Notifications
You must be signed in to change notification settings - Fork 1.1k
/
Copy pathsession_state.go
57 lines (52 loc) · 2.25 KB
/
session_state.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
package main
type HashType string
const (
HASH_PlainText HashType = ""
HASH_BCrypt HashType = "bcrypt"
)
// AccessSpecs define what URLS a user has access to an what methods are enabled
type AccessSpec struct {
URL string `json:"url"`
Methods []string `json:"methods"`
}
// AccessDefinition defines which versions of an API a key has access to
type AccessDefinition struct {
APIName string `json:"api_name"`
APIID string `json:"api_id"`
Versions []string `json:"versions"`
AllowedURLs []AccessSpec `bson:"allowed_urls" json:"allowed_urls"` // mapped string MUST be a valid regex
}
// SessionState objects represent a current API session, mainly used for rate limiting.
type SessionState struct {
LastCheck int64 `json:"last_check"`
Allowance float64 `json:"allowance"`
Rate float64 `json:"rate"`
Per float64 `json:"per"`
Expires int64 `json:"expires"`
QuotaMax int64 `json:"quota_max"`
QuotaRenews int64 `json:"quota_renews"`
QuotaRemaining int64 `json:"quota_remaining"`
QuotaRenewalRate int64 `json:"quota_renewal_rate"`
AccessRights map[string]AccessDefinition `json:"access_rights"`
OrgID string `json:"org_id"`
OauthClientID string `json:"oauth_client_id"`
OauthKeys map[string]string `json:"oauth_keys"`
BasicAuthData struct {
Password string `json:"password"`
Hash HashType `json:"hash_type"`
} `json:"basic_auth_data"`
JWTData struct {
Secret string `json:"secret"`
} `json:"jwt_data"`
HMACEnabled bool `json:"hmac_enabled"`
HmacSecret string `json:"hmac_string"`
IsInactive bool `json:"is_inactive"`
ApplyPolicyID string `json:"apply_policy_id"`
DataExpires int64 `json:"data_expires"`
Monitor struct {
TriggerLimits []float64 `json:"trigger_limits"`
} `json:"monitor"`
EnableDetailedRecording bool `json:"enable_detail_recording"`
MetaData interface{} `json:"meta_data"`
Tags []string `json:"tags"`
}