Skip to content

Commit 36983fb

Browse files
authored
Merge pull request #1386 from rrotter/cache_path_fix
expand `~` in saml_cache_file config field
2 parents 4f40aa6 + 958e9b1 commit 36983fb

File tree

1 file changed

+13
-3
lines changed

1 file changed

+13
-3
lines changed

pkg/samlcache/samlcache.go

+13-3
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,11 @@ func (p *SAMLCacheProvider) IsValid() bool {
6161
return false
6262
}
6363
} else {
64-
cache_path = p.Filename
64+
cache_path, err = homedir.Expand(p.Filename)
65+
if err != nil {
66+
logger.Debug("Could not retrieve cache file location", err)
67+
return false
68+
}
6569
}
6670
logger = logger.WithField("Cache_file", cache_path)
6771

@@ -126,7 +130,10 @@ func (p *SAMLCacheProvider) ReadRaw() (string, error) {
126130
return "", errors.Wrap(err, "Could not retrieve cache file path")
127131
}
128132
} else {
129-
cache_path = p.Filename
133+
cache_path, err = homedir.Expand(p.Filename)
134+
if err != nil {
135+
return "", errors.Wrap(err, "Could not retrieve cache file path")
136+
}
130137
}
131138

132139
content, err := os.ReadFile(cache_path)
@@ -147,7 +154,10 @@ func (p *SAMLCacheProvider) WriteRaw(samlAssertion string) error {
147154
return errors.Wrap(err, "Could not retrieve cache file path")
148155
}
149156
} else {
150-
cache_path = p.Filename
157+
cache_path, err = homedir.Expand(p.Filename)
158+
if err != nil {
159+
return errors.Wrap(err, "Could not retrieve cache file path")
160+
}
151161
}
152162

153163
// create the directory if it doesn't exist

0 commit comments

Comments
 (0)