Skip to content
Projects
Groups
Snippets
Help
Loading...
Sign in
Toggle navigation
E
Ecsite
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
shoei.kanno
Ecsite
Commits
c32718a2
Commit
c32718a2
authored
Oct 14, 2020
by
DESKTOP-FI5PFC1\tevir
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
ログイン機能追加
parent
65fdd4eb
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
17 additions
and
25 deletions
+17
-25
pom.xml
pom.xml
+1
-11
SecurityConfig.java
src/main/java/com/example/SecurityConfig.java
+8
-7
User.java
src/main/java/com/example/domain/User.java
+0
-3
application.properties
src/main/resources/application.properties
+5
-1
login.html
src/main/resources/templates/login.html
+3
-3
No files found.
pom.xml
View file @
c32718a2
...
...
@@ -19,10 +19,6 @@
</properties>
<dependencies>
<dependency>
<groupId>
org.springframework.boot
</groupId>
<artifactId>
spring-boot-starter-jdbc
</artifactId>
</dependency>
<dependency>
<groupId>
org.springframework.boot
</groupId>
<artifactId>
spring-boot-starter-data-jpa
</artifactId>
...
...
@@ -39,13 +35,6 @@
<groupId>
org.springframework.boot
</groupId>
<artifactId>
spring-boot-starter-web
</artifactId>
</dependency>
<dependency>
<groupId>
org.springframework.boot
</groupId>
<artifactId>
spring-boot-devtools
</artifactId>
<scope>
runtime
</scope>
<optional>
true
</optional>
</dependency>
<dependency>
<groupId>
mysql
</groupId>
<artifactId>
mysql-connector-java
</artifactId>
...
...
@@ -66,6 +55,7 @@
<artifactId>
spring-security-test
</artifactId>
<scope>
test
</scope>
</dependency>
</dependencies>
<build>
...
...
src/main/java/com/example/SecurityConfig.java
View file @
c32718a2
...
...
@@ -12,11 +12,6 @@ import org.springframework.security.crypto.password.Pbkdf2PasswordEncoder;
@EnableWebSecurity
public
class
SecurityConfig
extends
WebSecurityConfigurerAdapter
{
@Bean
PasswordEncoder
passwordEncoder
(){
return
new
Pbkdf2PasswordEncoder
();
}
@Override
public
void
configure
(
WebSecurity
web
)
throws
Exception
{
...
...
@@ -29,14 +24,15 @@ public class SecurityConfig extends WebSecurityConfigurerAdapter{
@Override
protected
void
configure
(
HttpSecurity
http
)
throws
Exception
{
http
.
authorizeRequests
()
.
mvcMatchers
(
"/"
,
"/signup"
,
"/login"
).
permitAll
()
.
mvcMatchers
(
"/"
,
"/signup"
,
"/l
imited/l
ogin"
).
permitAll
()
.
mvcMatchers
(
"/limited/admin/**"
).
hasRole
(
"ADMIN"
)
.
anyRequest
().
authenticated
()
.
and
()
.
formLogin
()
.
loginProcessingUrl
(
"/login"
)
.
loginPage
(
"/limited/login"
)
.
defaultSuccessUrl
(
"/top"
)
.
and
()
.
logout
()
...
...
@@ -44,4 +40,9 @@ public class SecurityConfig extends WebSecurityConfigurerAdapter{
.
deleteCookies
(
"JSESSIONID"
)
.
logoutSuccessUrl
(
"/login"
);
}
@Bean
PasswordEncoder
passwordEncoder
(){
return
new
Pbkdf2PasswordEncoder
();
}
}
src/main/java/com/example/domain/User.java
View file @
c32718a2
package
com
.
example
.
domain
;
import
java.sql.Date
;
import
java.util.Collection
;
import
javax.persistence.Column
;
import
javax.persistence.Entity
;
...
...
@@ -9,8 +8,6 @@ import javax.persistence.GeneratedValue;
import
javax.persistence.Id
;
import
javax.persistence.Table
;
import
org.springframework.security.core.GrantedAuthority
;
import
lombok.AllArgsConstructor
;
import
lombok.Data
;
import
lombok.NoArgsConstructor
;
...
...
src/main/resources/application.properties
View file @
c32718a2
spring.datasource.url
=
jdbc:mysql://localhost:3306/limited
spring.datasource.username
=
root
spring.datasource.password
=
kanikani7
security.basic.enabled
=
false
spring.datasource.driverClassName
=
com.mysql.jdbc.Driver
src/main/resources/templates/login.html
View file @
c32718a2
<!doctype html>
<html
class=
"no-js"
lang=
"en"
>
<html
class=
"no-js"
lang=
"en"
xmlns:th=
"http://www.thymeleaf.org"
>
<head>
<meta
charset=
"utf-8"
/>
<meta
http-equiv=
"X-UA-Compatible"
content=
"IE=edge,chrome=1"
/>
...
...
@@ -56,11 +56,11 @@
<form
id=
"loginForm"
method=
"post"
th:action=
"@{/login}"
>
<div
id=
"emailForm"
>
<label
for=
"email"
>
Email
</label>
<input
type=
"text"
class=
"login"
id=
"email"
placeholder=
"Email"
required
/>
<input
type=
"text"
class=
"login"
id=
"email"
placeholder=
"Email"
required
=
"true"
/>
</div>
<div
id=
"passwordForm"
>
<label
for=
"password"
>
Password
</label>
<input
type=
"password"
class=
"login"
id=
"password"
placeholder=
"Password"
required
/>
<input
type=
"password"
class=
"login"
id=
"password"
placeholder=
"Password"
required
=
"true"
/>
</div>
<div
id=
"submitForm"
>
<input
type=
"submit"
class=
"login"
id=
"btn"
value=
"Login"
/>
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment