Repository: authelia/authelia (go)

Issue:
Remember me checkbox if duration equal 0
Hi there,

It seemed to me that if option `remember_me_duration` was set to 0, the "Remember me" checkbox was not visible on the login screen. Did I dream of this ?

Currently, it is visible
![image](https://user-images.githubusercontent.com/43962716/157240368-6f097fd4-9127-4d13-8ec6-d3f82dea3151.png)

![image](https://user-images.githubusercontent.com/43962716/157240413-d7ec5fa3-02a9-4cdf-bc52-d290320df853.png)

As always, thank you for your hard work.

Pull request description:
fix(configuration): cannot disable remember me
This allows users to disable remember me again.

Fixes #2978

Patch:
diff --git a/config.template.yml b/config.template.yml
index 95c16da83..e03bbf241 100644
--- a/config.template.yml
+++ b/config.template.yml
@@ -461,7 +461,7 @@ session:
   inactivity: 5m
 
   ## The time before the cookie expires and the session is destroyed if remember me IS selected.
-  ## Value of 0 disables remember me.
+  ## Value of -1 disables remember me.
   remember_me_duration: 1M
 
   ##
diff --git a/internal/configuration/config.template.yml b/internal/configuration/config.template.yml
index 95c16da83..e03bbf241 100644
--- a/internal/configuration/config.template.yml
+++ b/internal/configuration/config.template.yml
@@ -461,7 +461,7 @@ session:
   inactivity: 5m
 
   ## The time before the cookie expires and the session is destroyed if remember me IS selected.
-  ## Value of 0 disables remember me.
+  ## Value of -1 disables remember me.
   remember_me_duration: 1M
 
   ##
diff --git a/internal/configuration/validator/session.go b/internal/configuration/validator/session.go
index 7286eb6a0..ddc076891 100644
--- a/internal/configuration/validator/session.go
+++ b/internal/configuration/validator/session.go
@@ -35,7 +35,7 @@ func validateSession(config *schema.SessionConfiguration, validator *schema.Stru
 		config.Inactivity = schema.DefaultSessionConfiguration.Inactivity // 5 min.
 	}
 
-	if config.RememberMeDuration <= 0 {
+	if config.RememberMeDuration <= 0 && config.RememberMeDuration != -1 {
 		config.RememberMeDuration = schema.DefaultSessionConfiguration.RememberMeDuration // 1 month.
 	}
 


Test patch:
diff --git a/internal/configuration/validator/session_test.go b/internal/configuration/validator/session_test.go
index 37588ae5f..b09f155a3 100644
--- a/internal/configuration/validator/session_test.go
+++ b/internal/configuration/validator/session_test.go
@@ -3,6 +3,7 @@ package validator
 import (
 	"fmt"
 	"testing"
+	"time"
 
 	"github.com/stretchr/testify/assert"
 	"github.com/stretchr/testify/require"
@@ -37,12 +38,12 @@ func TestShouldSetDefaultSessionValuesWhenNegative(t *testing.T) {
 	validator := schema.NewStructValidator()
 	config := newDefaultSessionConfig()
 
-	config.Expiration, config.Inactivity, config.RememberMeDuration = -1, -1, -1
+	config.Expiration, config.Inactivity, config.RememberMeDuration = -1, -1, -2
 
 	ValidateSession(&config, validator)
 
-	assert.False(t, validator.HasWarnings())
-	assert.False(t, validator.HasErrors())
+	assert.Len(t, validator.Warnings(), 0)
+	assert.Len(t, validator.Errors(), 0)
 	assert.Equal(t, schema.DefaultSessionConfiguration.Inactivity, config.Inactivity)
 	assert.Equal(t, schema.DefaultSessionConfiguration.Expiration, config.Expiration)
 	assert.Equal(t, schema.DefaultSessionConfiguration.RememberMeDuration, config.RememberMeDuration)
@@ -406,7 +407,7 @@ func TestShouldNotRaiseErrorWhenSameSiteSetCorrectly(t *testing.T) {
 	}
 }
 
-func TestShouldSetDefaultWhenNegativeInactivityAndExpirationSet(t *testing.T) {
+func TestShouldSetDefaultWhenNegativeAndNotOverrideDisabledRememberMe(t *testing.T) {
 	validator := schema.NewStructValidator()
 	config := newDefaultSessionConfig()
 	config.Inactivity = -1
@@ -420,7 +421,7 @@ func TestShouldSetDefaultWhenNegativeInactivityAndExpirationSet(t *testing.T) {
 
 	assert.Equal(t, schema.DefaultSessionConfiguration.Inactivity, config.Inactivity)
 	assert.Equal(t, schema.DefaultSessionConfiguration.Expiration, config.Expiration)
-	assert.Equal(t, schema.DefaultSessionConfiguration.RememberMeDuration, config.RememberMeDuration)
+	assert.Equal(t, time.Duration(-1), config.RememberMeDuration)
 }
 
 func TestShouldSetDefaultRememberMeDuration(t *testing.T) {