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