|
6 | 6 | "strings" |
7 | 7 |
|
8 | 8 | "github.com/caddyserver/caddy/v2" |
9 | | - "github.com/liujed/goutil/maps" |
10 | 9 | "github.com/liujed/goutil/optionals" |
11 | 10 | "github.com/smallstep/certificates/policy" |
12 | 11 | ) |
@@ -36,29 +35,29 @@ const challengeDomainPrefix = "_acme-challenge." |
36 | 35 | // A registry of known users and their corresponding policy configuration. |
37 | 36 | type ClientRegistry struct { |
38 | 37 | // Maps each client's user ID to its policy configuration. |
39 | | - Clients maps.Map[string, *ClientPolicy] |
| 38 | + clients map[string]*ClientPolicy |
40 | 39 | } |
41 | 40 |
|
42 | 41 | func (c *ClientRegistry) Provision( |
43 | 42 | ctx caddy.Context, |
44 | 43 | accountsRaw []RawAccount, |
45 | 44 | ) error { |
46 | 45 | // Convert accountsRaw into a map keyed on user ID. |
47 | | - c.Clients = maps.NewHashMap[string, *ClientPolicy]() |
| 46 | + c.clients = map[string]*ClientPolicy{} |
48 | 47 | for i, rawAccount := range accountsRaw { |
49 | | - if c.Clients.ContainsKey(rawAccount.UserID) { |
| 48 | + if _, containsKey := c.clients[rawAccount.UserID]; containsKey { |
50 | 49 | return fmt.Errorf( |
51 | 50 | "account %d: user ID is not unique: %q", |
52 | 51 | i, |
53 | 52 | rawAccount.UserID, |
54 | 53 | ) |
55 | 54 | } |
56 | 55 |
|
57 | | - c.Clients.Put(rawAccount.UserID, &rawAccount.ClientPolicy) |
| 56 | + c.clients[rawAccount.UserID] = &rawAccount.ClientPolicy |
58 | 57 | } |
59 | 58 |
|
60 | 59 | // Provision the ClientPolicy instances. |
61 | | - for userID, ca := range c.Clients.Entries() { |
| 60 | + for userID, ca := range c.clients { |
62 | 61 | err := ca.Provision(ctx) |
63 | 62 | if err != nil { |
64 | 63 | return fmt.Errorf( |
@@ -88,7 +87,7 @@ func (r *ClientRegistry) AuthorizeUserChallengeDomain( |
88 | 87 | fmt.Errorf("unable to determine user ID (is authentication configured?)") |
89 | 88 | } |
90 | 89 |
|
91 | | - config, exists := r.Clients.Get(userID).Get() |
| 90 | + config, exists := r.clients[userID] |
92 | 91 | if !exists { |
93 | 92 | return optionals.Some(DenyUnknownUser), nil |
94 | 93 | } |
|
0 commit comments