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 com.fasterxml.jackson.annotation.JsonIgnore
import javax.persistence.Column import javax.persistence.Column
import javax.persistence.Entity import javax.persistence.Entity
import javax.persistence.FetchType
import javax.persistence.Id import javax.persistence.Id
import javax.persistence.JoinColumn import javax.persistence.JoinColumn
import javax.persistence.JoinTable import javax.persistence.JoinTable
@ -20,7 +21,7 @@ open class User(
@JsonIgnore @JsonIgnore
open var enabled: Boolean = true, open var enabled: Boolean = true,
@JsonIgnore @JsonIgnore
@ManyToMany @ManyToMany(fetch = FetchType.EAGER)
@JoinTable( @JoinTable(
name = "user_roles", name = "user_roles",
joinColumns = [JoinColumn(name = "user_id", referencedColumnName = "id")], joinColumns = [JoinColumn(name = "user_id", referencedColumnName = "id")],

View File

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