document loadUserAgent

This commit is contained in:
A.Unger
2020-12-03 12:03:59 +01:00
parent ef4e573e42
commit 8c83de7db2
4 changed files with 15 additions and 2 deletions

View File

@@ -321,6 +321,10 @@ func loadMiddlewares(ctx context.Context, l log.Logger, cfg *config.Config) alic
// "user-agent":"challenge" locks in for Reva.
// Modifies cfg. Spaces don't need to be trimmed as urfavecli takes care of it. User agents with spaces are valid. i.e:
// Mozilla/5.0 (Macintosh; Intel Mac OS X 10.15; rv:83.0) Gecko/20100101 Firefox/83.0
// This function works by relying in our format of specifying [user-agent:challenge] and the fact that the user agent
// might contain ":" (colon), so the original string is reversed, split in two parts, by the time it is split we
// have the indexes reversed and the tuple is in the format of [challenge:user-agent], then the same process is applied
// in reverse for each individual part
func loadUserAgent(c *cli.Context, cfg *config.Config) error {
cfg.Reva.Middleware.Auth.CredentialsByUserAgent = make(map[string]string, 0)
locks := c.StringSlice("proxy-user-agent-whitelist")