Login now functional

This commit is contained in:
neviyn 2021-04-30 12:46:12 +01:00
parent 1f43e53a83
commit 1a1594bcc1
2 changed files with 4 additions and 4 deletions

View File

@ -3,6 +3,7 @@ package uk.co.neviyn.booru
import com.fasterxml.jackson.annotation.JsonIgnore
import javax.persistence.Column
import javax.persistence.Entity
import javax.persistence.FetchType
import javax.persistence.Id
import javax.persistence.JoinColumn
import javax.persistence.JoinTable
@ -20,7 +21,7 @@ open class User(
@JsonIgnore
open var enabled: Boolean = true,
@JsonIgnore
@ManyToMany
@ManyToMany(fetch = FetchType.EAGER)
@JoinTable(
name = "user_roles",
joinColumns = [JoinColumn(name = "user_id", referencedColumnName = "id")],

View File

@ -21,7 +21,7 @@ class SecurityConfig
val userDetailsService: CustomUserDetailsService
) : WebSecurityConfigurerAdapter() {
override fun configure(http: HttpSecurity) {
http.authorizeRequests().antMatchers("/upload").authenticated()
http.authorizeRequests().antMatchers("/upload").hasAuthority("USER")
.anyRequest().permitAll().and()
.formLogin().loginPage("/login").permitAll().and()
.logout().logoutSuccessUrl("/").permitAll().and()
@ -33,7 +33,7 @@ class SecurityConfig
}
}
class CustomUserDetails
open class CustomUserDetails
constructor(
private val user: User
) : UserDetails {
@ -50,7 +50,6 @@ constructor(
override fun isCredentialsNonExpired(): Boolean = true
override fun isEnabled(): Boolean = user.enabled
}
@Service