mirror of
https://github.com/steveiliop56/tinyauth.git
synced 2025-10-28 12:45:47 +00:00
feat: custom cookie age
This commit is contained in:
@@ -140,6 +140,7 @@ func init() {
|
|||||||
rootCmd.Flags().String("generic-user-url", "", "Generic OAuth user info URL.")
|
rootCmd.Flags().String("generic-user-url", "", "Generic OAuth user info URL.")
|
||||||
rootCmd.Flags().Bool("disable-continue", false, "Disable continue screen and redirect to app directly.")
|
rootCmd.Flags().Bool("disable-continue", false, "Disable continue screen and redirect to app directly.")
|
||||||
rootCmd.Flags().String("whitelist", "", "Comma separated list of email addresses to whitelist (only for oauth).")
|
rootCmd.Flags().String("whitelist", "", "Comma separated list of email addresses to whitelist (only for oauth).")
|
||||||
|
rootCmd.Flags().Int("cookie-expiry", 86400, "Cookie expiration time in seconds.")
|
||||||
viper.BindEnv("port", "PORT")
|
viper.BindEnv("port", "PORT")
|
||||||
viper.BindEnv("address", "ADDRESS")
|
viper.BindEnv("address", "ADDRESS")
|
||||||
viper.BindEnv("secret", "SECRET")
|
viper.BindEnv("secret", "SECRET")
|
||||||
@@ -159,5 +160,6 @@ func init() {
|
|||||||
viper.BindEnv("generic-user-url", "GENERIC_USER_URL")
|
viper.BindEnv("generic-user-url", "GENERIC_USER_URL")
|
||||||
viper.BindEnv("disable-continue", "DISABLE_CONTINUE")
|
viper.BindEnv("disable-continue", "DISABLE_CONTINUE")
|
||||||
viper.BindEnv("whitelist", "WHITELIST")
|
viper.BindEnv("whitelist", "WHITELIST")
|
||||||
|
viper.BindEnv("cookie-expiry", "COOKIE_EXPIRY")
|
||||||
viper.BindPFlags(rootCmd.Flags())
|
viper.BindPFlags(rootCmd.Flags())
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -77,6 +77,7 @@ func (api *API) Init() {
|
|||||||
Path: "/",
|
Path: "/",
|
||||||
HttpOnly: true,
|
HttpOnly: true,
|
||||||
Secure: isSecure,
|
Secure: isSecure,
|
||||||
|
MaxAge: api.Config.CookieExpiry,
|
||||||
})
|
})
|
||||||
|
|
||||||
router.Use(sessions.Sessions("tinyauth", store))
|
router.Use(sessions.Sessions("tinyauth", store))
|
||||||
|
|||||||
@@ -38,6 +38,7 @@ type Config struct {
|
|||||||
GenericUserURL string `mapstructure:"generic-user-info-url"`
|
GenericUserURL string `mapstructure:"generic-user-info-url"`
|
||||||
DisableContinue bool `mapstructure:"disable-continue"`
|
DisableContinue bool `mapstructure:"disable-continue"`
|
||||||
Whitelist string `mapstructure:"whitelist"`
|
Whitelist string `mapstructure:"whitelist"`
|
||||||
|
CookieExpiry int `mapstructure:"cookie-expiry"`
|
||||||
}
|
}
|
||||||
|
|
||||||
type UserContext struct {
|
type UserContext struct {
|
||||||
@@ -53,6 +54,7 @@ type APIConfig struct {
|
|||||||
Secret string
|
Secret string
|
||||||
AppURL string
|
AppURL string
|
||||||
CookieSecure bool
|
CookieSecure bool
|
||||||
|
CookieExpiry int
|
||||||
DisableContinue bool
|
DisableContinue bool
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user