Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

TotpAutoConfiguration is not loaded automatically by Spring Boot 3 #53

Open
micobarac opened this issue Aug 10, 2023 · 2 comments
Open

Comments

@micobarac
Copy link

micobarac commented Aug 10, 2023

TotpAutoConfiguration is not being loaded automatically by Spring Boot 3.
As a result, all beans defined in TotpAutoConfiguration, such as SecretGenerator, QrDataFactory, QrGenerator, CodeVerifier, are not recognized.

I had to import TotpAutoConfiguration manually in my Spring Boot 3 application:

package com.acme.config;

import dev.samstevens.totp.spring.autoconfigure.TotpAutoConfiguration;
import org.springframework.context.annotation.Configuration;
import org.springframework.context.annotation.Import;

@Configuration
@Import(TotpAutoConfiguration.class)
public class TotpConfiguration {
}
@limkinZero
Copy link

limkinZero commented Aug 22, 2023

Me too. In Spring Boot 3, there are some changes with register autoconfiguration beans in the starters. The file spring.factories has been removed.

https://github.com/spring-projects/spring-boot/wiki/Spring-Boot-3.0-Migration-Guide#auto-configuration-files

@basimons
Copy link

basimons commented Aug 29, 2023

Yeah, I also had this issue. You can fix it by doing this though:

@Configuration
public class MfaConfiguration {

    @Bean
    public TimeProvider timeProvider() {
        return new SystemTimeProvider();
    }

    @Bean
    public SecretGenerator secretGenerator() {
        return new DefaultSecretGenerator();
    }

    @Bean
    public CodeGenerator codeGenerator() {
        return new DefaultCodeGenerator(HashingAlgorithm.SHA1);
    }

    @Bean
    public CodeVerifier codeVerifier(CodeGenerator codeGenerator, TimeProvider timeProvider) {
        return new DefaultCodeVerifier(codeGenerator, timeProvider);
    }
}

Which is what it used to do

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants