mirror of
https://github.com/fatedier/frp.git
synced 2026-01-11 22:23:12 +00:00
refactor: reorganize security policy into dedicated packag (#5088)
This commit is contained in:
34
pkg/policy/security/unsafe.go
Normal file
34
pkg/policy/security/unsafe.go
Normal file
@@ -0,0 +1,34 @@
|
||||
package security
|
||||
|
||||
const (
|
||||
TokenSourceExec = "TokenSourceExec"
|
||||
)
|
||||
|
||||
var (
|
||||
ClientUnsafeFeatures = []string{
|
||||
TokenSourceExec,
|
||||
}
|
||||
|
||||
ServerUnsafeFeatures = []string{
|
||||
TokenSourceExec,
|
||||
}
|
||||
)
|
||||
|
||||
type UnsafeFeatures struct {
|
||||
features map[string]bool
|
||||
}
|
||||
|
||||
func NewUnsafeFeatures(allowed []string) *UnsafeFeatures {
|
||||
features := make(map[string]bool)
|
||||
for _, f := range allowed {
|
||||
features[f] = true
|
||||
}
|
||||
return &UnsafeFeatures{features: features}
|
||||
}
|
||||
|
||||
func (u *UnsafeFeatures) IsEnabled(feature string) bool {
|
||||
if u == nil {
|
||||
return false
|
||||
}
|
||||
return u.features[feature]
|
||||
}
|
||||
Reference in New Issue
Block a user