()
| 23 | ) |
| 24 | |
| 25 | func (c *Component) initRights() { |
| 26 | fetcher := rights.NewAccessFetcher(func(ctx context.Context) *grpc.ClientConn { |
| 27 | conn, err := c.GetPeerConn(ctx, ttnpb.ClusterRole_ACCESS, nil) |
| 28 | if err != nil { |
| 29 | return nil |
| 30 | } |
| 31 | return conn |
| 32 | }, c.config.GRPC.AllowInsecureForCredentials) |
| 33 | |
| 34 | if c.config.Rights.TTL > 0 { |
| 35 | fetcher = rights.NewInMemoryCache(fetcher, c.config.Rights.TTL, c.config.Rights.TTL) |
| 36 | } else { |
| 37 | c.Logger().Warn("No rights TTL configured") |
| 38 | } |
| 39 | |
| 40 | c.rightsFetcher = fetcher |
| 41 | c.AddContextFiller(func(ctx context.Context) context.Context { |
| 42 | return rights.NewContextWithFetcher(ctx, fetcher) |
| 43 | }) |
| 44 | } |
no test coverage detected