MCPcopy
hub / github.com/oauth2-proxy/oauth2-proxy / NewUserMap

Function NewUserMap

validator.go:24–37  ·  view source on GitHub ↗

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())

Source from the content-addressed store, hash-verified

22//
23// TODO (@NickMeves): Audit usage of `unsafe.Pointer` and potentially refactor
24func 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
40func (um *UserMap) IsValid(email string) (result bool) {

Callers 1

newValidatorImplFunction · 0.85

Calls 3

PrintfFunction · 0.92
WatchFileForUpdatesFunction · 0.92

Tested by

no test coverage detected