unsafe.go 561 B

12345678910111213141516171819202122232425262728293031323334
  1. package security
  2. const (
  3. TokenSourceExec = "TokenSourceExec"
  4. )
  5. var (
  6. ClientUnsafeFeatures = []string{
  7. TokenSourceExec,
  8. }
  9. ServerUnsafeFeatures = []string{
  10. TokenSourceExec,
  11. }
  12. )
  13. type UnsafeFeatures struct {
  14. features map[string]bool
  15. }
  16. func NewUnsafeFeatures(allowed []string) *UnsafeFeatures {
  17. features := make(map[string]bool)
  18. for _, f := range allowed {
  19. features[f] = true
  20. }
  21. return &UnsafeFeatures{features: features}
  22. }
  23. func (u *UnsafeFeatures) IsEnabled(feature string) bool {
  24. if u == nil {
  25. return false
  26. }
  27. return u.features[feature]
  28. }