Download this file
| 1 | package home |
| 2 | |
| 3 | import ( |
| 4 | "context" |
| 5 | "strings" |
| 6 | "time" |
| 7 | |
| 8 | "github.com/keymaildev/signin" |
| 9 | ) |
| 10 | |
| 11 | // Keep Flow's address budget without retaining its readable key. IP keys stay |
| 12 | // shared with /resolve's budget. The upstream blind-auth-store adapter can use |
| 13 | // this same Limiter seam without changing the stored person identity. |
| 14 | type blindSigninLimiter struct { |
| 15 | next signin.Limiter |
| 16 | pepper []byte |
| 17 | } |
| 18 | |
| 19 | func (l blindSigninLimiter) Allow(ctx context.Context, key string, now time.Time, budget int) (bool, error) { |
| 20 | if address, ok := strings.CutPrefix(key, "addr:"); ok { |
| 21 | key = "addr:" + blindIndex(l.pepper, address) |
| 22 | } |
| 23 | return l.next.Allow(ctx, key, now, budget) |
| 24 | } |
| 25 | |