mirror of
https://github.com/pomerium/pomerium.git
synced 2025-05-23 05:57:19 +02:00
tcptunnel: handle invalid http response codes (#1727)
This commit is contained in:
parent
e56e7e4b9e
commit
5b18527fee
2 changed files with 32 additions and 8 deletions
|
@ -25,6 +25,7 @@ var (
|
|||
|
||||
// A JWTCache loads and stores JWTs.
|
||||
type JWTCache interface {
|
||||
DeleteJWT(key string) error
|
||||
LoadJWT(key string) (rawJWT string, err error)
|
||||
StoreJWT(key string, rawJWT string) error
|
||||
}
|
||||
|
@ -53,6 +54,16 @@ func NewLocalJWTCache() (*LocalJWTCache, error) {
|
|||
}, nil
|
||||
}
|
||||
|
||||
// DeleteJWT deletes a raw JWT from the local cache.
|
||||
func (cache *LocalJWTCache) DeleteJWT(key string) error {
|
||||
path := filepath.Join(cache.dir, cache.fileName(key))
|
||||
err := os.Remove(path)
|
||||
if os.IsNotExist(err) {
|
||||
err = nil
|
||||
}
|
||||
return err
|
||||
}
|
||||
|
||||
// LoadJWT loads a raw JWT from the local cache.
|
||||
func (cache *LocalJWTCache) LoadJWT(key string) (rawJWT string, err error) {
|
||||
path := filepath.Join(cache.dir, cache.fileName(key))
|
||||
|
@ -98,6 +109,15 @@ func NewMemoryJWTCache() *MemoryJWTCache {
|
|||
return &MemoryJWTCache{entries: make(map[string]string)}
|
||||
}
|
||||
|
||||
// DeleteJWT deletes a JWT from the in-memory map.
|
||||
func (cache *MemoryJWTCache) DeleteJWT(key string) error {
|
||||
cache.mu.Lock()
|
||||
defer cache.mu.Unlock()
|
||||
|
||||
delete(cache.entries, key)
|
||||
return nil
|
||||
}
|
||||
|
||||
// LoadJWT loads a JWT from the in-memory map.
|
||||
func (cache *MemoryJWTCache) LoadJWT(key string) (rawJWT string, err error) {
|
||||
cache.mu.Lock()
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue