Last change
on this file was baf4cc4, checked in by ppaunovski <paunovskipavel@…>, 3 months ago |
split group project and individual project into two separate folders
|
-
Property mode
set to
100644
|
File size:
1.3 KB
|
Line | |
---|
1 | package mk.ukim.finki.busngobackend.config
|
---|
2 |
|
---|
3 | import mk.ukim.finki.busngobackend.encoder
|
---|
4 | import mk.ukim.finki.busngobackend.repository.KorisnikRepository
|
---|
5 | import org.springframework.context.annotation.Bean
|
---|
6 | import org.springframework.context.annotation.Configuration
|
---|
7 | import org.springframework.security.authentication.AuthenticationManager
|
---|
8 | import org.springframework.security.authentication.AuthenticationProvider
|
---|
9 | import org.springframework.security.authentication.dao.DaoAuthenticationProvider
|
---|
10 | import org.springframework.security.config.annotation.authentication.configuration.AuthenticationConfiguration
|
---|
11 | import org.springframework.security.core.userdetails.UserDetailsService
|
---|
12 |
|
---|
13 | @Configuration
|
---|
14 | class ApplicationConfig(
|
---|
15 | private val korisnikRepository: KorisnikRepository,
|
---|
16 | ) {
|
---|
17 | @Bean
|
---|
18 | fun userDetailsService(): UserDetailsService =
|
---|
19 | UserDetailsService { email ->
|
---|
20 | korisnikRepository.findByEmail(email)
|
---|
21 | }
|
---|
22 |
|
---|
23 | @Bean
|
---|
24 | fun authenticationProvider(korisnikRepository: KorisnikRepository): AuthenticationProvider {
|
---|
25 | val provider = DaoAuthenticationProvider()
|
---|
26 | provider.setUserDetailsService(userDetailsService())
|
---|
27 | provider.setPasswordEncoder(encoder())
|
---|
28 | return provider
|
---|
29 | }
|
---|
30 |
|
---|
31 | @Bean
|
---|
32 | fun authenticationManager(config: AuthenticationConfiguration): AuthenticationManager = config.authenticationManager
|
---|
33 | }
|
---|
Note:
See
TracBrowser
for help on using the repository browser.