AuthSourceKind returns where the Auth entry came from at runtime.
()
| 44 | |
| 45 | // AuthSourceKind returns where the Auth entry came from at runtime. |
| 46 | func (a *Auth) AuthSourceKind() string { |
| 47 | if a == nil { |
| 48 | return "" |
| 49 | } |
| 50 | if strings.EqualFold(authAttribute(a, AttributeRuntimeOnly), "true") { |
| 51 | return AuthSourceMemory |
| 52 | } |
| 53 | if source := normalizeAuthSourceKind(authAttribute(a, AttributeSourceBackend)); source != "" { |
| 54 | return source |
| 55 | } |
| 56 | source := authAttribute(a, AttributeSource) |
| 57 | if source != "" { |
| 58 | sourceLower := strings.ToLower(source) |
| 59 | if strings.HasPrefix(sourceLower, AuthSourceConfig+":") { |
| 60 | return AuthSourceConfig |
| 61 | } |
| 62 | if normalized := normalizeAuthSourceKind(source); normalized != "" { |
| 63 | return normalized |
| 64 | } |
| 65 | return AuthSourceFile |
| 66 | } |
| 67 | if authAttribute(a, AttributePath) != "" { |
| 68 | return AuthSourceFile |
| 69 | } |
| 70 | if strings.TrimSpace(a.FileName) != "" { |
| 71 | return AuthSourceFile |
| 72 | } |
| 73 | return "" |
| 74 | } |
| 75 | |
| 76 | func normalizeAuthKind(kind string) string { |
| 77 | switch strings.ToLower(strings.TrimSpace(kind)) { |