| 1088 | } |
| 1089 | |
| 1090 | func (h *Host) RegisterFrontendAuthProviders() { |
| 1091 | if h == nil { |
| 1092 | return |
| 1093 | } |
| 1094 | |
| 1095 | type exclusiveFrontendAuthCandidate struct { |
| 1096 | key string |
| 1097 | pluginID string |
| 1098 | priority int |
| 1099 | } |
| 1100 | |
| 1101 | nextKeys := make(map[string]struct{}) |
| 1102 | var bestExclusive exclusiveFrontendAuthCandidate |
| 1103 | for _, record := range h.activeRecords() { |
| 1104 | provider := record.plugin.Capabilities.FrontendAuthProvider |
| 1105 | if provider == nil || h.isPluginFused(record.id) { |
| 1106 | continue |
| 1107 | } |
| 1108 | adapter := &accessAdapter{ |
| 1109 | host: h, |
| 1110 | pluginID: record.id, |
| 1111 | path: record.path, |
| 1112 | version: record.version, |
| 1113 | provider: provider, |
| 1114 | } |
| 1115 | key := strings.TrimSpace(adapter.Identifier()) |
| 1116 | if key == "" { |
| 1117 | continue |
| 1118 | } |
| 1119 | sdkaccess.RegisterProvider(key, adapter) |
| 1120 | nextKeys[key] = struct{}{} |
| 1121 | if record.plugin.Capabilities.FrontendAuthProviderExclusive { |
| 1122 | candidate := exclusiveFrontendAuthCandidate{ |
| 1123 | key: key, |
| 1124 | pluginID: record.id, |
| 1125 | priority: record.priority, |
| 1126 | } |
| 1127 | if bestExclusive.key == "" || |
| 1128 | candidate.priority > bestExclusive.priority || |
| 1129 | (candidate.priority == bestExclusive.priority && candidate.pluginID < bestExclusive.pluginID) { |
| 1130 | bestExclusive = candidate |
| 1131 | } |
| 1132 | } |
| 1133 | } |
| 1134 | |
| 1135 | if bestExclusive.key != "" { |
| 1136 | sdkaccess.SetExclusiveProvider(bestExclusive.key) |
| 1137 | } else { |
| 1138 | sdkaccess.ClearExclusiveProvider() |
| 1139 | } |
| 1140 | h.pruneStaleAccessProviders(nextKeys) |
| 1141 | } |
| 1142 | |
| 1143 | func (h *Host) pruneStaleAccessProviders(nextKeys map[string]struct{}) { |
| 1144 | if h == nil { |