(update AuthUpdate)
| 78 | } |
| 79 | |
| 80 | func (w *Watcher) dispatchPersistedAuthUpdate(update AuthUpdate) bool { |
| 81 | if w == nil { |
| 82 | return false |
| 83 | } |
| 84 | if update.Auth == nil || update.Auth.ID == "" { |
| 85 | return false |
| 86 | } |
| 87 | path := "" |
| 88 | if update.Auth.Attributes != nil { |
| 89 | path = update.Auth.Attributes["path"] |
| 90 | if path == "" { |
| 91 | path = update.Auth.Attributes["source"] |
| 92 | } |
| 93 | } |
| 94 | normalized := w.normalizeAuthPath(path) |
| 95 | if normalized == "" { |
| 96 | return false |
| 97 | } |
| 98 | clone := update.Auth.Clone() |
| 99 | w.clientsMutex.Lock() |
| 100 | if w.fileAuthsByPath == nil { |
| 101 | w.fileAuthsByPath = make(map[string]map[string]*coreauth.Auth) |
| 102 | } |
| 103 | pathAuths := w.fileAuthsByPath[normalized] |
| 104 | if pathAuths == nil { |
| 105 | pathAuths = make(map[string]*coreauth.Auth) |
| 106 | w.fileAuthsByPath[normalized] = pathAuths |
| 107 | } |
| 108 | pathAuths[clone.ID] = nil |
| 109 | if w.currentAuths == nil { |
| 110 | w.currentAuths = make(map[string]*coreauth.Auth) |
| 111 | } |
| 112 | w.currentAuths[clone.ID] = clone |
| 113 | w.clientsMutex.Unlock() |
| 114 | if w.getAuthQueue() == nil { |
| 115 | return false |
| 116 | } |
| 117 | if update.ID == "" { |
| 118 | update.ID = clone.ID |
| 119 | } |
| 120 | update.Auth = clone.Clone() |
| 121 | w.dispatchAuthUpdates([]AuthUpdate{update}) |
| 122 | return true |
| 123 | } |
| 124 | |
| 125 | func (w *Watcher) refreshAuthState(force bool) { |
| 126 | w.clientsMutex.RLock() |
no test coverage detected