ctx=mcfg.WithRequiredJSON(ctx,"users",&userSecrets,"JSON object which maps usernames to their TOTP secret strings")
mcfg.JSON(cmp,"users",&userSecrets,
mcfg.ParamRequired(),
mcfg.ParamUsage("JSON object which maps usernames to their TOTP secret strings"))
varsecretmcrypto.Secret
ctx,secretStr:=mcfg.WithString(ctx,"secret","","String used to sign authentication tokens. If one isn't given a new one will be generated on each startup, invalidating all previous tokens.")
mcfg.ParamUsage("String used to sign authentication tokens. If one isn't given a new one will be generated on each startup, invalidating all previous tokens."))
mrun.InitHook(cmp,func(context.Context)error{
if*secretStr==""{
*secretStr=mrand.Hex(32)
}
mlog.Info("generating secret",ctx)
mlog.From(cmp).Info("generating secret")
secret=mcrypto.NewSecret([]byte(*secretStr))
returnnil
})
proxyHandler:=new(struct{http.Handler})
ctx,proxyURL:=mcfg.WithRequiredString(ctx,"dst-url","URL to proxy requests to. Only the scheme and host should be set.")