Skip to content

Commit 258fb75

Browse files
committed
refactor(config): migrate @ConfigurationProperties from @component to @EnableConfigurationProperties
Remove @component and @propertysource from DevLoginConfigProperties and WebAuthnConfigProperties so they are passive data holders per Spring Boot convention. Registration is now handled by dedicated @configuration classes with @EnableConfigurationProperties: - DevLoginAutoConfiguration: guards with @Profile("local") and @ConditionalOnProperty, owns @propertysource - WebAuthnAutoConfiguration: always active (WebSecurityConfig requires the properties), owns @propertysource Closes #263
1 parent 99f00b1 commit 258fb75

4 files changed

Lines changed: 44 additions & 8 deletions

File tree

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
package com.digitalsanctuary.spring.user.dev;
2+
3+
import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty;
4+
import org.springframework.boot.context.properties.EnableConfigurationProperties;
5+
import org.springframework.context.annotation.Configuration;
6+
import org.springframework.context.annotation.Profile;
7+
import org.springframework.context.annotation.PropertySource;
8+
9+
/**
10+
* Auto-configuration for the dev login feature.
11+
* <p>
12+
* Activates only when the {@code local} profile is active and
13+
* {@code user.dev.auto-login-enabled=true}. Individual dev-login components
14+
* ({@link DevLoginController}, {@link DevLoginStartupWarning}) carry their own
15+
* guards for defense-in-depth.
16+
* </p>
17+
*/
18+
@Configuration
19+
@Profile("local")
20+
@ConditionalOnProperty(name = "user.dev.auto-login-enabled", havingValue = "true", matchIfMissing = false)
21+
@PropertySource("classpath:config/dsspringuserconfig.properties")
22+
@EnableConfigurationProperties(DevLoginConfigProperties.class)
23+
public class DevLoginAutoConfiguration {
24+
}

src/main/java/com/digitalsanctuary/spring/user/dev/DevLoginConfigProperties.java

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,6 @@
11
package com.digitalsanctuary.spring.user.dev;
22

33
import org.springframework.boot.context.properties.ConfigurationProperties;
4-
import org.springframework.context.annotation.PropertySource;
5-
import org.springframework.stereotype.Component;
64
import lombok.Data;
75

86
/**
@@ -17,8 +15,6 @@
1715
* </p>
1816
*/
1917
@Data
20-
@Component
21-
@PropertySource("classpath:config/dsspringuserconfig.properties")
2218
@ConfigurationProperties(prefix = "user.dev")
2319
public class DevLoginConfigProperties {
2420

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
package com.digitalsanctuary.spring.user.security;
2+
3+
import org.springframework.boot.context.properties.EnableConfigurationProperties;
4+
import org.springframework.context.annotation.Configuration;
5+
import org.springframework.context.annotation.PropertySource;
6+
7+
/**
8+
* Auto-configuration that registers {@link WebAuthnConfigProperties}.
9+
* <p>
10+
* This configuration is always active because {@code WebSecurityConfig} requires
11+
* {@link WebAuthnConfigProperties} regardless of whether WebAuthn is enabled.
12+
* Individual WebAuthn components carry their own
13+
* {@code @ConditionalOnProperty(name = "user.webauthn.enabled")} guards.
14+
* </p>
15+
*/
16+
@Configuration
17+
@PropertySource("classpath:config/dsspringuserconfig.properties")
18+
@EnableConfigurationProperties(WebAuthnConfigProperties.class)
19+
public class WebAuthnAutoConfiguration {
20+
}

src/main/java/com/digitalsanctuary/spring/user/security/WebAuthnConfigProperties.java

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,16 +2,12 @@
22

33
import java.util.Set;
44
import org.springframework.boot.context.properties.ConfigurationProperties;
5-
import org.springframework.context.annotation.PropertySource;
6-
import org.springframework.stereotype.Component;
75
import lombok.Data;
86

97
/**
108
* Configuration properties for WebAuthn (Passkey) authentication.
119
*/
1210
@Data
13-
@Component
14-
@PropertySource("classpath:config/dsspringuserconfig.properties")
1511
@ConfigurationProperties(prefix = "user.webauthn")
1612
public class WebAuthnConfigProperties {
1713

0 commit comments

Comments
 (0)