Repository: authelia/authelia (go)

Issue:
'scheme_basic_cache_lifespan' can't be configured unless the 'basic' scheme is configured but only the 'Basic' schemes are configured
### Version


v4.39.0

### Deployment Method


Docker

### Reverse Proxy


Caddy

### Reverse Proxy Version


2.8.0

### Description


It seems that the authn_strategies scheme has to be 'basic' instead of 'Basic'.

### Reproduction

Run authelia using the configuration listed below.


### Expectations
Authelia is able to start. 

### Configuration (Authelia)


```yaml
server:
  address: 'tcp://:9091/auth'
  # disable_healthcheck: false
  endpoints:
    authz:
      forward-auth:
        implementation: 'ForwardAuth'
        authn_strategies:
          - name: 'CookieSession'
      basic-auth:
        implementation: 'ForwardAuth'
        authn_strategies:
          - name: 'HeaderAuthorization'
            schemes:
              - 'Basic'
            scheme_basic_cache_lifespan: 1h
```

### Build Information


```shell
Last Tag: v4.39.0
State: tagged clean
Branch: v4.39.0
Commit: bbfa41712ce1b3e39b4798b18bd5f78e68470720
Build Number: 41111
Build OS: linux
Build Arch: amd64
Build Compiler: gc
Build Date: Sun, 16 Mar 2025 21:05:57 +1100
Extra:

Go:
    Version: go1.24.1
    Module Path: github.com/authelia/authelia/v4
    Executable Path: github.com/authelia/authelia/v4/cmd/authelia
```

### Logs (Authelia)


```shell
time="2025-03-16T14:29:54-07:00" level=error msg="Configuration: server: endpoints: authz: basic-auth: authn_strategies: strategy #1: option 'scheme_basic_cache_lifespan' can't be configured unless the 'basic' scheme is configured but only the 'Basic' schemes are configured"
time="2025-03-16T14:29:54-07:00" level=fatal msg="Can't continue due to the errors loading the configuration" stack="github.com/authelia/authelia/v4/internal/commands/context.go:157 NewRootCmd.(*CmdCtx).ChainRunE.func1\ngithub.com/spf13/cobra@v1.9.1/command.go:1000                    (*Command).execute\ngithub.com/spf13/cobra@v1.9.1/command.go:1148                    (*Command).ExecuteC\ngithub.com/spf13/cobra@v1.9.1/command.go:1071                    (*Command).Execute\ngithub.com/authelia/authelia/v4/cmd/authelia/main.go:10          main\ninternal/runtime/atomic/types.go:194                             (*Uint32).Load\nruntime/asm_amd64.s:1700                                         goexit"
time="2025-03-16T14:29:54-07:00" level=error msg="Configuration: server: endpoints: authz: basic-auth: authn_strategies: strategy #1: option 'scheme_basic_cache_lifespan' can't be configured unless the 'basic' scheme is configured but only the 'Basic' schemes are configured"
time="2025-03-16T14:29:54-07:00" level=fatal msg="Can't continue due to the errors loading the configuration" stack="github.com/authelia/authelia/v4/internal/commands/context.go:157 NewRootCmd.(*CmdCtx).ChainRunE.func1\ngithub.com/spf13/cobra@v1.9.1/command.go:1000                    (*Command).execute\ngithub.com/spf13/cobra@v1.9.1/command.go:1148                    (*Command).ExecuteC\ngithub.com/spf13/cobra@v1.9.1/command.go:1071                    (*Command).Execute\ngithub.com/authelia/authelia/v4/cmd/authelia/main.go:10          main\ninternal/runtime/atomic/types.go:194                             (*Uint32).Load\nruntime/asm_amd64.s:1700                                         goexit"
time="2025-03-16T14:29:55-07:00" level=error msg="Configuration: server: endpoints: authz: basic-auth: authn_strategies: strategy #1: option 'scheme_basic_cache_lifespan' can't be configured unless the 'basic' scheme is configured but only the 'Basic' schemes are configured"
time="2025-03-16T14:29:55-07:00" level=fatal msg="Can't continue due to the errors loading the configuration" stack="github.com/authelia/authelia/v4/internal/commands/context.go:157 NewRootCmd.(*CmdCtx).ChainRunE.func1\ngithub.com/spf13/cobra@v1.9.1/command.go:1000                    (*Command).execute\ngithub.com/spf13/cobra@v1.9.1/command.go:1148                    (*Command).ExecuteC\ngithub.com/spf13/cobra@v1.9.1/command.go:1071                    (*Command).Execute\ngithub.com/authelia/authelia/v4/cmd/authelia/main.go:10          main\ninternal/runtime/atomic/types.go:194                             (*Uint32).Load\nruntime/asm_amd64.s:1700                                         goexit"
time="2025-03-16T14:29:55-07:00" level=error msg="Configuration: server: endpoints: authz: basic-auth: authn_strategies: strategy #1: option 'scheme_basic_cache_lifespan' can't be configured unless the 'basic' scheme is configured but only the 'Basic' schemes are configured"
time="2025-03-16T14:29:55-07:00" level=fatal msg="Can't continue due to the errors loading the configuration" stack="github.com/authelia/authelia/v4/internal/commands/context.go:157 NewRootCmd.(*CmdCtx).ChainRunE.func1\ngithub.com/spf13/cobra@v1.9.1/command.go:1000                    (*Command).execute\ngithub.com/spf13/cobra@v1.9.1/command.go:1148                    (*Command).ExecuteC\ngithub.com/spf13/cobra@v1.9.1/command.go:1071                    (*Command).Execute\ngithub.com/authelia/authelia/v4/cmd/authelia/main.go:10          main\ninternal/runtime/atomic/types.go:194                             (*Uint32).Load\nruntime/asm_amd64.s:1700                                         goexit"
time="2025-03-16T14:29:56-07:00" level=error msg="Configuration: server: endpoints: authz: basic-auth: authn_strategies: strategy #1: option 'scheme_basic_cache_lifespan' can't be configured unless the 'basic' scheme is configured but only the 'Basic' schemes are configured"
time="2025-03-16T14:29:56-07:00" level=fatal msg="Can't continue due to the errors loading the configuration" stack="github.com/authelia/authelia/v4/internal/commands/context.go:157 NewRootCmd.(*CmdCtx).ChainRunE.func1\ngithub.com/spf13/cobra@v1.9.1/command.go:1000                    (*Command).execute\ngithub.com/spf13/cobra@v1.9.1/command.go:1148                    (*Command).ExecuteC\ngithub.com/spf13/cobra@v1.9.1/command.go:1071                    (*Command).Execute\ngithub.com/authelia/authelia/v4/cmd/authelia/main.go:10          main\ninternal/runtime/atomic/types.go:194                             (*Uint32).Load\nruntime/asm_amd64.s:1700                                         goexit"
```

### Logs (Proxy / Application)


There is no related proxy logs because authelia simply refuse to start. 

### Documentation


_No response_

### Generative AI


No

### Pre-Submission Checklist


- [x] I agree to follow the [Code of Conduct](http://www.authelia.com/code-of-conduct)

- [x] This is a bug report and not a support request

- [x] I have read the security policy and this bug report is not a security issue or security related issue

- [x] I have either included the complete configuration file or I am sure it's unrelated to the configuration

- [x] I have either included the complete debug / trace logs or the output of the build-info command if the logs are not relevant

- [x] I have provided all of the required information in full with the only alteration being reasonable sanitization in accordance with the [Troubleshooting Sanitization](https://www.authelia.com/r/sanitize) reference guide

- [x] I have checked for related proxy or application logs and included them if available

- [x] I have checked for related issues and checked the documentation


Pull request description:
fix(configuration): cache lifespan scheme case
Fix the comparison between the 'basic' scheme and the configured schemes when validating if scheme_basic_cache_lifespan is configured.

Fixes #8981

<!-- This is an auto-generated comment: release notes by coderabbit.ai -->

## Summary by CodeRabbit

- **Bug Fixes**
  - Improved authentication configuration validation by making scheme checks case-insensitive, ensuring that valid strategies are recognized consistently.
- **Tests**
  - Introduced a new test case to verify that valid authentication configurations pass without errors.

<!-- end of auto-generated comment: release notes by coderabbit.ai -->

Patch:
diff --git a/internal/configuration/validator/server.go b/internal/configuration/validator/server.go
index 6919edcc9..7cc895d09 100644
--- a/internal/configuration/validator/server.go
+++ b/internal/configuration/validator/server.go
@@ -383,7 +383,7 @@ func validateServerEndpointsAuthzStrategies(name, implementation string, strateg
 
 		names = append(names, strategy.Name)
 
-		if strategy.SchemeBasicCacheLifespan > 0 && !utils.IsStringInSlice(schema.SchemeBasic, strategy.Schemes) {
+		if strategy.SchemeBasicCacheLifespan > 0 && !utils.IsStringInSliceFold(schema.SchemeBasic, strategy.Schemes) {
 			validator.Push(fmt.Errorf(errFmtServerEndpointsAuthzStrategySchemeOnlyOption, name, i+1, "scheme_basic_cache_lifespan", schema.SchemeBasic, utils.StringJoinAnd(strategy.Schemes)))
 		}
 


Test patch:
diff --git a/internal/configuration/validator/server_test.go b/internal/configuration/validator/server_test.go
index 9950769fe..7c9183333 100644
--- a/internal/configuration/validator/server_test.go
+++ b/internal/configuration/validator/server_test.go
@@ -564,6 +564,13 @@ func TestServerAuthzEndpointErrors(t *testing.T) {
 				"server: endpoints: authz: example: authn_strategies: strategy #1: option 'scheme_basic_cache_lifespan' can't be configured unless the 'basic' scheme is configured but only the 'bearer' schemes are configured",
 			},
 		},
+		{
+			"ShouldNotErrorOnValidSchemeCase",
+			map[string]schema.ServerEndpointsAuthz{
+				"example": {Implementation: "ForwardAuth", AuthnStrategies: []schema.ServerEndpointsAuthzAuthnStrategy{{Name: "HeaderAuthorization", SchemeBasicCacheLifespan: time.Minute, Schemes: []string{"BASIC"}}}},
+			},
+			[]string{},
+		},
 		{
 			"ShouldErrorOnInvalidChars",
 			map[string]schema.ServerEndpointsAuthz{