Register with BCrytEncoder

This commit is contained in:
Chantha 2020-05-19 15:30:16 +07:00
parent 961b318402
commit 0c0dffc6af
23 changed files with 269 additions and 31 deletions

View File

@ -0,0 +1,13 @@
<component name="libraryTable">
<library name="Maven: org.attoparser:attoparser:2.0.5.RELEASE">
<CLASSES>
<root url="jar://$MAVEN_REPOSITORY$/org/attoparser/attoparser/2.0.5.RELEASE/attoparser-2.0.5.RELEASE.jar!/" />
</CLASSES>
<JAVADOC>
<root url="jar://$MAVEN_REPOSITORY$/org/attoparser/attoparser/2.0.5.RELEASE/attoparser-2.0.5.RELEASE-javadoc.jar!/" />
</JAVADOC>
<SOURCES>
<root url="jar://$MAVEN_REPOSITORY$/org/attoparser/attoparser/2.0.5.RELEASE/attoparser-2.0.5.RELEASE-sources.jar!/" />
</SOURCES>
</library>
</component>

View File

@ -0,0 +1,13 @@
<component name="libraryTable">
<library name="Maven: org.springframework.boot:spring-boot-starter-thymeleaf:2.3.0.RELEASE">
<CLASSES>
<root url="jar://$MAVEN_REPOSITORY$/org/springframework/boot/spring-boot-starter-thymeleaf/2.3.0.RELEASE/spring-boot-starter-thymeleaf-2.3.0.RELEASE.jar!/" />
</CLASSES>
<JAVADOC>
<root url="jar://$MAVEN_REPOSITORY$/org/springframework/boot/spring-boot-starter-thymeleaf/2.3.0.RELEASE/spring-boot-starter-thymeleaf-2.3.0.RELEASE-javadoc.jar!/" />
</JAVADOC>
<SOURCES>
<root url="jar://$MAVEN_REPOSITORY$/org/springframework/boot/spring-boot-starter-thymeleaf/2.3.0.RELEASE/spring-boot-starter-thymeleaf-2.3.0.RELEASE-sources.jar!/" />
</SOURCES>
</library>
</component>

View File

@ -0,0 +1,13 @@
<component name="libraryTable">
<library name="Maven: org.thymeleaf.extras:thymeleaf-extras-java8time:3.0.4.RELEASE">
<CLASSES>
<root url="jar://$MAVEN_REPOSITORY$/org/thymeleaf/extras/thymeleaf-extras-java8time/3.0.4.RELEASE/thymeleaf-extras-java8time-3.0.4.RELEASE.jar!/" />
</CLASSES>
<JAVADOC>
<root url="jar://$MAVEN_REPOSITORY$/org/thymeleaf/extras/thymeleaf-extras-java8time/3.0.4.RELEASE/thymeleaf-extras-java8time-3.0.4.RELEASE-javadoc.jar!/" />
</JAVADOC>
<SOURCES>
<root url="jar://$MAVEN_REPOSITORY$/org/thymeleaf/extras/thymeleaf-extras-java8time/3.0.4.RELEASE/thymeleaf-extras-java8time-3.0.4.RELEASE-sources.jar!/" />
</SOURCES>
</library>
</component>

View File

@ -0,0 +1,13 @@
<component name="libraryTable">
<library name="Maven: org.thymeleaf:thymeleaf:3.0.11.RELEASE">
<CLASSES>
<root url="jar://$MAVEN_REPOSITORY$/org/thymeleaf/thymeleaf/3.0.11.RELEASE/thymeleaf-3.0.11.RELEASE.jar!/" />
</CLASSES>
<JAVADOC>
<root url="jar://$MAVEN_REPOSITORY$/org/thymeleaf/thymeleaf/3.0.11.RELEASE/thymeleaf-3.0.11.RELEASE-javadoc.jar!/" />
</JAVADOC>
<SOURCES>
<root url="jar://$MAVEN_REPOSITORY$/org/thymeleaf/thymeleaf/3.0.11.RELEASE/thymeleaf-3.0.11.RELEASE-sources.jar!/" />
</SOURCES>
</library>
</component>

View File

@ -0,0 +1,13 @@
<component name="libraryTable">
<library name="Maven: org.thymeleaf:thymeleaf-spring5:3.0.11.RELEASE">
<CLASSES>
<root url="jar://$MAVEN_REPOSITORY$/org/thymeleaf/thymeleaf-spring5/3.0.11.RELEASE/thymeleaf-spring5-3.0.11.RELEASE.jar!/" />
</CLASSES>
<JAVADOC>
<root url="jar://$MAVEN_REPOSITORY$/org/thymeleaf/thymeleaf-spring5/3.0.11.RELEASE/thymeleaf-spring5-3.0.11.RELEASE-javadoc.jar!/" />
</JAVADOC>
<SOURCES>
<root url="jar://$MAVEN_REPOSITORY$/org/thymeleaf/thymeleaf-spring5/3.0.11.RELEASE/thymeleaf-spring5-3.0.11.RELEASE-sources.jar!/" />
</SOURCES>
</library>
</component>

View File

@ -0,0 +1,13 @@
<component name="libraryTable">
<library name="Maven: org.unbescape:unbescape:1.1.6.RELEASE">
<CLASSES>
<root url="jar://$MAVEN_REPOSITORY$/org/unbescape/unbescape/1.1.6.RELEASE/unbescape-1.1.6.RELEASE.jar!/" />
</CLASSES>
<JAVADOC>
<root url="jar://$MAVEN_REPOSITORY$/org/unbescape/unbescape/1.1.6.RELEASE/unbescape-1.1.6.RELEASE-javadoc.jar!/" />
</JAVADOC>
<SOURCES>
<root url="jar://$MAVEN_REPOSITORY$/org/unbescape/unbescape/1.1.6.RELEASE/unbescape-1.1.6.RELEASE-sources.jar!/" />
</SOURCES>
</library>
</component>

View File

@ -2,13 +2,27 @@
<project version="4">
<component name="ChangeListManager">
<list default="true" id="47c3fbf4-4238-47d3-9ffa-fcd23da4e01e" name="Default Changelist" comment="">
<change afterPath="$PROJECT_DIR$/src/main/kotlin/com/chantha/jdbc/security/User.kt" afterDir="false" />
<change afterPath="$PROJECT_DIR$/src/main/kotlin/com/chantha/jdbc/security/UserDetailServiceImpl.kt" afterDir="false" />
<change afterPath="$PROJECT_DIR$/src/main/kotlin/com/chantha/jdbc/security/UserPrincipal.kt" afterDir="false" />
<change afterPath="$PROJECT_DIR$/src/main/kotlin/com/chantha/jdbc/security/UserRepo.kt" afterDir="false" />
<change afterPath="$PROJECT_DIR$/.idea/libraries/Maven__org_attoparser_attoparser_2_0_5_RELEASE.xml" afterDir="false" />
<change afterPath="$PROJECT_DIR$/.idea/libraries/Maven__org_springframework_boot_spring_boot_starter_thymeleaf_2_3_0_RELEASE.xml" afterDir="false" />
<change afterPath="$PROJECT_DIR$/.idea/libraries/Maven__org_thymeleaf_extras_thymeleaf_extras_java8time_3_0_4_RELEASE.xml" afterDir="false" />
<change afterPath="$PROJECT_DIR$/.idea/libraries/Maven__org_thymeleaf_thymeleaf_3_0_11_RELEASE.xml" afterDir="false" />
<change afterPath="$PROJECT_DIR$/.idea/libraries/Maven__org_thymeleaf_thymeleaf_spring5_3_0_11_RELEASE.xml" afterDir="false" />
<change afterPath="$PROJECT_DIR$/.idea/libraries/Maven__org_unbescape_unbescape_1_1_6_RELEASE.xml" afterDir="false" />
<change afterPath="$PROJECT_DIR$/src/main/kotlin/com/chantha/jdbc/controller/UserController.kt" afterDir="false" />
<change afterPath="$PROJECT_DIR$/src/main/resources/templates/register.html" afterDir="false" />
<change beforePath="$PROJECT_DIR$/.idea/workspace.xml" beforeDir="false" afterPath="$PROJECT_DIR$/.idea/workspace.xml" afterDir="false" />
<change beforePath="$PROJECT_DIR$/jdbc.iml" beforeDir="false" afterPath="$PROJECT_DIR$/jdbc.iml" afterDir="false" />
<change beforePath="$PROJECT_DIR$/pom.xml" beforeDir="false" afterPath="$PROJECT_DIR$/pom.xml" afterDir="false" />
<change beforePath="$PROJECT_DIR$/src/main/kotlin/com/chantha/jdbc/config/WebConfig.java" beforeDir="false" afterPath="$PROJECT_DIR$/src/main/kotlin/com/chantha/jdbc/config/WebConfig.java" afterDir="false" />
<change beforePath="$PROJECT_DIR$/src/main/kotlin/com/chantha/jdbc/security/User.kt" beforeDir="false" afterPath="$PROJECT_DIR$/src/main/kotlin/com/chantha/jdbc/security/User.kt" afterDir="false" />
<change beforePath="$PROJECT_DIR$/src/main/kotlin/com/chantha/jdbc/security/UserDetailServiceImpl.kt" beforeDir="false" afterPath="$PROJECT_DIR$/src/main/kotlin/com/chantha/jdbc/security/UserDetailServiceImpl.kt" afterDir="false" />
<change beforePath="$PROJECT_DIR$/src/main/kotlin/com/chantha/jdbc/security/UserPrincipal.kt" beforeDir="false" afterPath="$PROJECT_DIR$/src/main/kotlin/com/chantha/jdbc/security/UserPrincipal.kt" afterDir="false" />
<change beforePath="$PROJECT_DIR$/src/main/resources/application.properties" beforeDir="false" afterPath="$PROJECT_DIR$/src/main/resources/application.properties" afterDir="false" />
<change beforePath="$PROJECT_DIR$/target/classes/application.properties" beforeDir="false" afterPath="$PROJECT_DIR$/target/classes/application.properties" afterDir="false" />
<change beforePath="$PROJECT_DIR$/target/classes/com/chantha/jdbc/config/WebConfig.class" beforeDir="false" afterPath="$PROJECT_DIR$/target/classes/com/chantha/jdbc/config/WebConfig.class" afterDir="false" />
<change beforePath="$PROJECT_DIR$/target/classes/com/chantha/jdbc/security/User.class" beforeDir="false" afterPath="$PROJECT_DIR$/target/classes/com/chantha/jdbc/security/User.class" afterDir="false" />
<change beforePath="$PROJECT_DIR$/target/classes/com/chantha/jdbc/security/UserDetailServiceImpl.class" beforeDir="false" afterPath="$PROJECT_DIR$/target/classes/com/chantha/jdbc/security/UserDetailServiceImpl.class" afterDir="false" />
<change beforePath="$PROJECT_DIR$/target/classes/com/chantha/jdbc/security/UserPrincipal.class" beforeDir="false" afterPath="$PROJECT_DIR$/target/classes/com/chantha/jdbc/security/UserPrincipal.class" afterDir="false" />
</list>
<option name="SHOW_DIALOG" value="false" />
<option name="HIGHLIGHT_CONFLICTS" value="true" />
@ -22,6 +36,7 @@
<option value="Class" />
<option value="Kotlin Class" />
<option value="Kotlin Interface" />
<option value="HTML File" />
<option value="Kotlin File" />
</list>
</option>
@ -47,6 +62,7 @@
<option name="showLibraryContents" value="true" />
</component>
<component name="PropertiesComponent">
<property name="DefaultHtmlFileTemplate" value="HTML File" />
<property name="RequestMappingsPanelOrder0" value="0" />
<property name="RequestMappingsPanelOrder1" value="1" />
<property name="RequestMappingsPanelWidth0" value="75" />
@ -96,7 +112,7 @@
<workItem from="1589774040527" duration="72000" />
<workItem from="1589788206287" duration="4024000" />
<workItem from="1589857721932" duration="2546000" />
<workItem from="1589862025987" duration="5219000" />
<workItem from="1589862025987" duration="12626000" />
</task>
<task id="LOCAL-00001" summary="&quot;Add Spring Security to project&quot;">
<created>1589796661163</created>
@ -144,42 +160,42 @@
<screen x="0" y="0" width="1920" height="1040" />
</state>
<state x="508" y="29" key="CommitChangelistDialog2/0.0.1920.1040@0.0.1920.1040" timestamp="1589796659997" />
<state x="740" y="276" key="FileChooserDialogImpl" timestamp="1589866688537">
<state x="740" y="276" key="FileChooserDialogImpl" timestamp="1589873287289">
<screen x="0" y="0" width="1920" height="1040" />
</state>
<state x="740" y="276" key="FileChooserDialogImpl/0.0.1920.1040@0.0.1920.1040" timestamp="1589866688537" />
<state width="1877" height="420" key="GridCell.Tab.0.bottom" timestamp="1589868867505">
<state x="740" y="276" key="FileChooserDialogImpl/0.0.1920.1040@0.0.1920.1040" timestamp="1589873287289" />
<state width="1877" height="420" key="GridCell.Tab.0.bottom" timestamp="1589876503739">
<screen x="0" y="0" width="1920" height="1040" />
</state>
<state width="1877" height="420" key="GridCell.Tab.0.bottom/0.0.1920.1040@0.0.1920.1040" timestamp="1589868867505" />
<state width="1877" height="420" key="GridCell.Tab.0.center" timestamp="1589868867505">
<state width="1877" height="420" key="GridCell.Tab.0.bottom/0.0.1920.1040@0.0.1920.1040" timestamp="1589876503739" />
<state width="1877" height="420" key="GridCell.Tab.0.center" timestamp="1589876503738">
<screen x="0" y="0" width="1920" height="1040" />
</state>
<state width="1877" height="420" key="GridCell.Tab.0.center/0.0.1920.1040@0.0.1920.1040" timestamp="1589868867505" />
<state width="1877" height="420" key="GridCell.Tab.0.left" timestamp="1589868867505">
<state width="1877" height="420" key="GridCell.Tab.0.center/0.0.1920.1040@0.0.1920.1040" timestamp="1589876503738" />
<state width="1877" height="420" key="GridCell.Tab.0.left" timestamp="1589876503738">
<screen x="0" y="0" width="1920" height="1040" />
</state>
<state width="1877" height="420" key="GridCell.Tab.0.left/0.0.1920.1040@0.0.1920.1040" timestamp="1589868867505" />
<state width="1877" height="420" key="GridCell.Tab.0.right" timestamp="1589868867505">
<state width="1877" height="420" key="GridCell.Tab.0.left/0.0.1920.1040@0.0.1920.1040" timestamp="1589876503738" />
<state width="1877" height="420" key="GridCell.Tab.0.right" timestamp="1589876503739">
<screen x="0" y="0" width="1920" height="1040" />
</state>
<state width="1877" height="420" key="GridCell.Tab.0.right/0.0.1920.1040@0.0.1920.1040" timestamp="1589868867505" />
<state width="1877" height="420" key="GridCell.Tab.1.bottom" timestamp="1589868867506">
<state width="1877" height="420" key="GridCell.Tab.0.right/0.0.1920.1040@0.0.1920.1040" timestamp="1589876503739" />
<state width="1877" height="420" key="GridCell.Tab.1.bottom" timestamp="1589876503739">
<screen x="0" y="0" width="1920" height="1040" />
</state>
<state width="1877" height="420" key="GridCell.Tab.1.bottom/0.0.1920.1040@0.0.1920.1040" timestamp="1589868867506" />
<state width="1877" height="420" key="GridCell.Tab.1.center" timestamp="1589868867506">
<state width="1877" height="420" key="GridCell.Tab.1.bottom/0.0.1920.1040@0.0.1920.1040" timestamp="1589876503739" />
<state width="1877" height="420" key="GridCell.Tab.1.center" timestamp="1589876503739">
<screen x="0" y="0" width="1920" height="1040" />
</state>
<state width="1877" height="420" key="GridCell.Tab.1.center/0.0.1920.1040@0.0.1920.1040" timestamp="1589868867506" />
<state width="1877" height="420" key="GridCell.Tab.1.left" timestamp="1589868867505">
<state width="1877" height="420" key="GridCell.Tab.1.center/0.0.1920.1040@0.0.1920.1040" timestamp="1589876503739" />
<state width="1877" height="420" key="GridCell.Tab.1.left" timestamp="1589876503739">
<screen x="0" y="0" width="1920" height="1040" />
</state>
<state width="1877" height="420" key="GridCell.Tab.1.left/0.0.1920.1040@0.0.1920.1040" timestamp="1589868867505" />
<state width="1877" height="420" key="GridCell.Tab.1.right" timestamp="1589868867506">
<state width="1877" height="420" key="GridCell.Tab.1.left/0.0.1920.1040@0.0.1920.1040" timestamp="1589876503739" />
<state width="1877" height="420" key="GridCell.Tab.1.right" timestamp="1589876503739">
<screen x="0" y="0" width="1920" height="1040" />
</state>
<state width="1877" height="420" key="GridCell.Tab.1.right/0.0.1920.1040@0.0.1920.1040" timestamp="1589868867506" />
<state width="1877" height="420" key="GridCell.Tab.1.right/0.0.1920.1040@0.0.1920.1040" timestamp="1589876503739" />
<state width="1877" height="326" key="GridCell.Tab.2.bottom" timestamp="1589796703748">
<screen x="0" y="0" width="1920" height="1040" />
</state>
@ -200,13 +216,17 @@
<screen x="0" y="0" width="1920" height="1040" />
</state>
<state x="767" y="433" key="com.intellij.openapi.vcs.update.UpdateOrStatusOptionsDialogupdate-v2/0.0.1920.1040@0.0.1920.1040" timestamp="1589796631131" />
<state x="342" y="100" key="new project wizard" timestamp="1589876220249">
<screen x="0" y="0" width="1920" height="1040" />
</state>
<state x="342" y="100" key="new project wizard/0.0.1920.1040@0.0.1920.1040" timestamp="1589876220249" />
<state x="616" y="240" key="run.anything.popup" timestamp="1589796621453">
<screen x="0" y="0" width="1920" height="1040" />
</state>
<state x="616" y="240" key="run.anything.popup/0.0.1920.1040@0.0.1920.1040" timestamp="1589796621453" />
<state x="623" y="225" width="672" height="678" key="search.everywhere.popup" timestamp="1589859310268">
<state x="623" y="225" width="672" height="678" key="search.everywhere.popup" timestamp="1589874332627">
<screen x="0" y="0" width="1920" height="1040" />
</state>
<state x="623" y="225" width="672" height="678" key="search.everywhere.popup/0.0.1920.1040@0.0.1920.1040" timestamp="1589859310268" />
<state x="623" y="225" width="672" height="678" key="search.everywhere.popup/0.0.1920.1040@0.0.1920.1040" timestamp="1589874332627" />
</component>
</project>

View File

@ -129,6 +129,12 @@
<orderEntry type="library" name="Maven: com.fasterxml.jackson.core:jackson-core:2.10.4" level="project" />
<orderEntry type="library" name="Maven: com.fasterxml.jackson.core:jackson-annotations:2.10.4" level="project" />
<orderEntry type="library" name="Maven: org.postgresql:postgresql:42.2.12" level="project" />
<orderEntry type="library" name="Maven: org.springframework.boot:spring-boot-starter-thymeleaf:2.3.0.RELEASE" level="project" />
<orderEntry type="library" name="Maven: org.thymeleaf:thymeleaf-spring5:3.0.11.RELEASE" level="project" />
<orderEntry type="library" name="Maven: org.thymeleaf:thymeleaf:3.0.11.RELEASE" level="project" />
<orderEntry type="library" name="Maven: org.attoparser:attoparser:2.0.5.RELEASE" level="project" />
<orderEntry type="library" name="Maven: org.unbescape:unbescape:1.1.6.RELEASE" level="project" />
<orderEntry type="library" name="Maven: org.thymeleaf.extras:thymeleaf-extras-java8time:3.0.4.RELEASE" level="project" />
<orderEntry type="library" name="Maven: org.springframework.boot:spring-boot-starter-security:2.3.0.RELEASE" level="project" />
<orderEntry type="library" name="Maven: org.springframework:spring-aop:5.2.6.RELEASE" level="project" />
<orderEntry type="library" name="Maven: org.springframework.security:spring-security-config:5.2.4.RELEASE" level="project" />

View File

@ -38,6 +38,13 @@
<artifactId>postgresql</artifactId>
<version>42.2.12</version>
</dependency>
<!-- https://mvnrepository.com/artifact/org.springframework.boot/spring-boot-starter-thymeleaf -->
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-thymeleaf</artifactId>
<version>2.3.0.RELEASE</version>
</dependency>
<!-- https://mvnrepository.com/artifact/org.springframework.boot/spring-boot-starter-security -->
<dependency>
@ -45,7 +52,6 @@
<artifactId>spring-boot-starter-security</artifactId>
<version>2.3.0.RELEASE</version>
</dependency>
<dependency>
<groupId>org.jetbrains.kotlin</groupId>
<artifactId>kotlin-reflect</artifactId>

View File

@ -1,6 +1,7 @@
package com.chantha.jdbc.config;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.security.config.annotation.authentication.builders.AuthenticationManagerBuilder;
import org.springframework.security.config.annotation.web.builders.HttpSecurity;
@ -10,6 +11,8 @@ import org.springframework.security.config.annotation.web.configuration.WebSecur
import org.springframework.security.core.userdetails.User;
import org.springframework.security.core.userdetails.UserDetails;
import org.springframework.security.core.userdetails.UserDetailsService;
import org.springframework.security.crypto.bcrypt.BCryptPasswordEncoder;
import org.springframework.security.crypto.password.PasswordEncoder;
import org.springframework.security.web.util.matcher.AntPathRequestMatcher;
@Configuration
@ -18,6 +21,8 @@ public class WebConfig extends WebSecurityConfigurerAdapter {
private final UserDetailsService userDetailsService;
@Autowired
public WebConfig(UserDetailsService userDetailsService){
this.userDetailsService=userDetailsService;
@ -25,7 +30,7 @@ public class WebConfig extends WebSecurityConfigurerAdapter {
@Override
protected void configure(AuthenticationManagerBuilder auth) throws Exception {
auth.userDetailsService(userDetailsService);
auth.userDetailsService(userDetailsService).passwordEncoder(passwordEncoder());
}
@Override
@ -33,10 +38,16 @@ public class WebConfig extends WebSecurityConfigurerAdapter {
http.formLogin();
http.logout().logoutRequestMatcher(new AntPathRequestMatcher("/logout"));
http.authorizeRequests()
.antMatchers("/register").permitAll()
.antMatchers("/**").hasAnyRole("ADMIN");
http.csrf().disable();
}
@Bean
public PasswordEncoder passwordEncoder(){
return new BCryptPasswordEncoder();
}

View File

@ -0,0 +1,37 @@
package com.chantha.jdbc.controller
import com.chantha.jdbc.security.User
import com.chantha.jdbc.security.UserRepo
import com.sun.istack.NotNull
import org.springframework.beans.factory.annotation.Autowired
import org.springframework.security.crypto.bcrypt.BCryptPasswordEncoder
import org.springframework.stereotype.Controller
import org.springframework.web.bind.annotation.GetMapping
import org.springframework.web.bind.annotation.ModelAttribute
import org.springframework.web.bind.annotation.PostMapping
import org.springframework.web.bind.annotation.RequestParam
@Controller
class UserController @Autowired constructor(private val userRepo: UserRepo){
fun encoder():BCryptPasswordEncoder{
return BCryptPasswordEncoder()
}
@GetMapping("/register")
fun register():String{
return "register"
}
@PostMapping("/register")
fun saveRegister(@NotNull @ModelAttribute("user") user:User?):String{
user!!.password=encoder().encode(user.password)
user.roles="ROLES_${user.roles}"
userRepo.save(user)
return "register"
}
}

View File

@ -8,14 +8,14 @@ import javax.persistence.*
@Table(name = "tbUser")
data class User(
@Id
@GeneratedValue
var userId:Long ,
@GeneratedValue(strategy = GenerationType.IDENTITY)
var userId:Long ? = 0 ,
@Column(nullable = false,unique = true)
var userName:String,
@Column(nullable = false,unique = true)
var password:String,
var roles:String,
var status:Int
var status:Int ?= 1
)
{

View File

@ -7,8 +7,10 @@ import org.springframework.stereotype.Service
@Service
class UserDetailServiceImpl @Autowired constructor(private val userRepo: UserRepo):UserDetailsService {
@Throws(Exception::class)
override fun loadUserByUsername(p0: String?): UserDetails {
val user=userRepo.findByUsername(p0!!)
return UserPrincipal(user)
}
}

View File

@ -33,7 +33,7 @@ class UserPrincipal constructor(private val user: User):UserDetails{
}
override fun getPassword(): String {
return "{noop}${user.password}"
return user.password
}
override fun isAccountNonExpired(): Boolean {

View File

@ -5,6 +5,7 @@ spring.jpa.hibernate.ddl-auto=update
spring.jpa.open-in-view=true
server.port=8081
spring.thymeleaf.cache=true

View File

@ -0,0 +1,38 @@
<!doctype html>
<html lang="en" xmlns:th="http://www.thymeleaf.org">
<head>
<meta charset="UTF-8">
<meta name="viewport"
content="width=device-width, user-scalable=no, initial-scale=1.0, maximum-scale=1.0, minimum-scale=1.0">
<meta http-equiv="X-UA-Compatible" content="ie=edge">
<title>Document</title>
<link rel="stylesheet" href="https://stackpath.bootstrapcdn.com/bootstrap/4.5.0/css/bootstrap.min.css" integrity="sha384-9aIt2nRpC12Uk9gS9baDl411NQApFmC26EwAOH8WgZl5MYYxFfc+NcPb1dKGj7Sk" crossorigin="anonymous">
</head>
<body>
<div style="width: 200px; margin: auto; top: 500px ; ">
<form class="form-horizontal" th:action="@{/register}" th:method="POST" th:object="${user}">
<div class="form-group">
<label for="usr">Name:</label>
<input type="text" class="form-control" id="usr" th:name="userName">
</div>
<div class="form-group">
<label for="pwd">Password:</label>
<input type="password" class="form-control" id="pwd" th:name="password">
</div>
<div class="form-group">
<label for="sel1">Select list:</label>
<select class="form-control" id="sel1" th:name="roles">
<option th:value="Choose">Choose</option>
<option th:value="ADMIN">ADMIN</option>
<option th:value="DBA">DBA</option>
<option th:value="USER">USER</option>
</select>
</div>
<div class="form-group">
<button type="submit" class="btn btn-success">Success</button>
</div>
</form>
</div>
</body>
</html>

View File

@ -5,6 +5,7 @@ spring.jpa.hibernate.ddl-auto=update
spring.jpa.open-in-view=true
server.port=8081
spring.thymeleaf.cache=true

View File

@ -0,0 +1,38 @@
<!doctype html>
<html lang="en" xmlns:th="http://www.thymeleaf.org">
<head>
<meta charset="UTF-8">
<meta name="viewport"
content="width=device-width, user-scalable=no, initial-scale=1.0, maximum-scale=1.0, minimum-scale=1.0">
<meta http-equiv="X-UA-Compatible" content="ie=edge">
<title>Document</title>
<link rel="stylesheet" href="https://stackpath.bootstrapcdn.com/bootstrap/4.5.0/css/bootstrap.min.css" integrity="sha384-9aIt2nRpC12Uk9gS9baDl411NQApFmC26EwAOH8WgZl5MYYxFfc+NcPb1dKGj7Sk" crossorigin="anonymous">
</head>
<body>
<div style="width: 200px; margin: auto; top: 500px ; ">
<form class="form-horizontal" th:action="@{/register}" th:method="POST" th:object="${user}">
<div class="form-group">
<label for="usr">Name:</label>
<input type="text" class="form-control" id="usr" th:name="userName">
</div>
<div class="form-group">
<label for="pwd">Password:</label>
<input type="password" class="form-control" id="pwd" th:name="password">
</div>
<div class="form-group">
<label for="sel1">Select list:</label>
<select class="form-control" id="sel1" th:name="roles">
<option th:value="Choose">Choose</option>
<option th:value="ADMIN">ADMIN</option>
<option th:value="DBA">DBA</option>
<option th:value="USER">USER</option>
</select>
</div>
<div class="form-group">
<button type="submit" class="btn btn-success">Success</button>
</div>
</form>
</div>
</body>
</html>