NewUserMap parses the authenticated emails file into a new UserMap TODO (@NickMeves): Audit usage of `unsafe.Pointer` and potentially refactor
(usersFile string, done <-chan bool, onUpdate func())
| 22 | // |
| 23 | // TODO (@NickMeves): Audit usage of `unsafe.Pointer` and potentially refactor |
| 24 | func NewUserMap(usersFile string, done <-chan bool, onUpdate func()) *UserMap { |
| 25 | um := &UserMap{usersFile: usersFile} |
| 26 | m := make(map[string]bool) |
| 27 | atomic.StorePointer(&um.m, unsafe.Pointer(&m)) // #nosec G103 |
| 28 | if usersFile != "" { |
| 29 | logger.Printf("using authenticated emails file %s", usersFile) |
| 30 | watcher.WatchFileForUpdates(usersFile, done, func() { |
| 31 | um.LoadAuthenticatedEmailsFile() |
| 32 | onUpdate() |
| 33 | }) |
| 34 | um.LoadAuthenticatedEmailsFile() |
| 35 | } |
| 36 | return um |
| 37 | } |
| 38 | |
| 39 | // IsValid checks if an email is allowed |
| 40 | func (um *UserMap) IsValid(email string) (result bool) { |
no test coverage detected