NaN
NaN

Reputation: 3591

Spring security UserDetailsService configuration

I added a custom UserDetails and UserDetailsService class to my spring project and want to use them in combination with httpbasic. How can I configure spring to use my custom classes?

My application.yml looks like this:

security:
  basic:
    enabled: false
  require_ssl: false
  enable_csrf: false
  ignored:
    - /register/**
    - /acitivate/**
  headers:
    hsts: domain
  sessions: stateless

UserDetailsService:

@Service
@Transactional(readOnly = true)
public class UserDetailsServiceAdapter implements UserDetailsService {

    @Override
    public UserDetails loadUserByUsername(String username) throws UsernameNotFoundException {
      //...
    }

}

Do I have to define Beans, or is it possible to set it within my application.yml?

Upvotes: 0

Views: 345

Answers (1)

OhadR
OhadR

Reputation: 8839

You do not have to define the bean for the "UserDetails" in your XML. The fact that your config file is in YAML does not make things any different.

so in your case, you can derive from it (extend it) and it will be OK. Remember to call "super.loadUserByUsername()" in your impl, and in the class where you use it you will have to down-cast.

Upvotes: 1

Related Questions