diff options
author | Neil Alexander <neilalexander@users.noreply.github.com> | 2020-06-10 11:02:03 +0100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2020-06-10 11:02:03 +0100 |
commit | d9d6f4568ce891ae0ae9d2a3449974d3777bd21d (patch) | |
tree | 4271cca1f56ae36b9fbb3beba20fa55f89896202 /serverkeyapi | |
parent | 464718c3e60cd4c095357bd8b80859eab9cb3b2d (diff) |
Use ServerKeyAPI as keyring (#1110)
* Use ServerKeyAPI as keyring
* Update fetcher name for debug logs
Diffstat (limited to 'serverkeyapi')
-rw-r--r-- | serverkeyapi/internal/api.go | 12 |
1 files changed, 8 insertions, 4 deletions
diff --git a/serverkeyapi/internal/api.go b/serverkeyapi/internal/api.go index 176983c8..92d6a70b 100644 --- a/serverkeyapi/internal/api.go +++ b/serverkeyapi/internal/api.go @@ -17,9 +17,13 @@ type ServerKeyAPI struct { } func (s *ServerKeyAPI) KeyRing() *gomatrixserverlib.KeyRing { - // Return a real keyring - one that has the real database and real - // fetchers. - return &s.OurKeyRing + // Return a keyring that forces requests to be proxied through the + // below functions. That way we can enforce things like validity + // and keeping the cache up-to-date. + return &gomatrixserverlib.KeyRing{ + KeyDatabase: s, + KeyFetchers: []gomatrixserverlib.KeyFetcher{s}, + } } func (s *ServerKeyAPI) StoreKeys( @@ -84,5 +88,5 @@ func (s *ServerKeyAPI) FetchKeys( } func (s *ServerKeyAPI) FetcherName() string { - return s.OurKeyRing.KeyDatabase.FetcherName() + return fmt.Sprintf("ServerKeyAPI (wrapping %q)", s.OurKeyRing.KeyDatabase.FetcherName()) } |