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
dfadbcbc
Commit
dfadbcbc
authored
Oct 16, 2020
by
keita.onoguchi
Browse files
Options
Browse Files
Download
Plain Diff
Merge branch 'TOP画面ルーティング' into 'master'
Top画面ルーティング See merge request
!6
parents
2c83df65
c9ed5244
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
48 additions
and
18 deletions
+48
-18
SecurityConfig.java
src/main/java/com/example/SecurityConfig.java
+10
-10
LoginUser.java
src/main/java/com/example/service/LoginUser.java
+1
-0
EcsiteController.java
src/main/java/com/example/web/EcsiteController.java
+28
-0
index.html
src/main/resources/templates/index.html
+9
-8
No files found.
src/main/java/com/example/SecurityConfig.java
View file @
dfadbcbc
...
@@ -21,23 +21,23 @@ public class SecurityConfig extends WebSecurityConfigurerAdapter{
...
@@ -21,23 +21,23 @@ public class SecurityConfig extends WebSecurityConfigurerAdapter{
protected
void
configure
(
HttpSecurity
http
)
throws
Exception
{
protected
void
configure
(
HttpSecurity
http
)
throws
Exception
{
http
http
.
authorizeRequests
()
.
authorizeRequests
()
.
mvcMatchers
(
"/limited/login"
).
permitAll
()
.
mvcMatchers
(
"/limited/login"
).
permitAll
()
//ログイン前でもアクセス可能なURLの指定
.
mvcMatchers
(
"/limited/admin/**"
).
hasRole
(
"ADMIN"
)
.
mvcMatchers
(
"/limited/admin/**"
).
hasRole
(
"ADMIN"
)
//ADMIN権限のユーザーのみアクセスできるURLの指定
.
anyRequest
().
authenticated
()
.
anyRequest
().
authenticated
()
//ログイン前は他のアドレスにログインできないよう指定
.
and
()
.
and
()
.
formLogin
()
.
formLogin
()
.
loginProcessingUrl
(
"/login"
)
.
loginProcessingUrl
(
"/login"
)
//ログイン処理でpostするURL
.
loginPage
(
"/limited/login"
)
.
loginPage
(
"/limited/login"
)
//ログインページのURL
.
defaultSuccessUrl
(
"/limited/top"
,
true
)
.
defaultSuccessUrl
(
"/limited/top"
,
true
)
//ログイン成功時のURL
.
usernameParameter
(
"email"
).
passwordParameter
(
"password"
)
.
usernameParameter
(
"email"
).
passwordParameter
(
"password"
)
//ログインのパラメーター指定
.
and
()
.
and
()
.
logout
()
.
logout
()
.
invalidateHttpSession
(
true
)
.
invalidateHttpSession
(
true
)
.
deleteCookies
(
"JSESSIONID"
)
.
deleteCookies
(
"JSESSIONID"
)
//ログアウト時キャッシュを削除する処理
.
logoutSuccessUrl
(
"/limited/login"
);
.
logoutSuccessUrl
(
"/limited/login"
);
//ログアウト後に表示するURL
}
}
@Bean
@Bean
//パスワードのハッシュか
PasswordEncoder
passwordEncoder
(){
PasswordEncoder
passwordEncoder
(){
return
new
Pbkdf2PasswordEncoder
();
return
new
Pbkdf2PasswordEncoder
();
}
}
...
...
src/main/java/com/example/service/LoginUser.java
View file @
dfadbcbc
...
@@ -23,6 +23,7 @@ public class LoginUser extends org.springframework.security.core.userdetails.Use
...
@@ -23,6 +23,7 @@ public class LoginUser extends org.springframework.security.core.userdetails.Use
return
user
;
return
user
;
}
}
//ログイン権限、文字列変更
private
Collection
<
GrantedAuthority
>
getAuthorities
(
String
role
)
{
private
Collection
<
GrantedAuthority
>
getAuthorities
(
String
role
)
{
if
(
role
.
equals
(
"ADMIN"
))
{
if
(
role
.
equals
(
"ADMIN"
))
{
return
AuthorityUtils
.
createAuthorityList
(
"ROLE_ADMIN"
,
"ROLE_GENERAL"
);
return
AuthorityUtils
.
createAuthorityList
(
"ROLE_ADMIN"
,
"ROLE_GENERAL"
);
...
...
src/main/java/com/example/web/EcsiteController.java
0 → 100644
View file @
dfadbcbc
package
com
.
example
.
web
;
import
org.springframework.security.core.annotation.AuthenticationPrincipal
;
import
org.springframework.stereotype.Controller
;
import
org.springframework.ui.Model
;
import
org.springframework.web.bind.annotation.GetMapping
;
import
org.springframework.web.bind.annotation.RequestMapping
;
import
com.example.domain.User
;
import
com.example.service.LoginUser
;
@Controller
@RequestMapping
(
"limited"
)
public
class
EcsiteController
{
//トップ画面遷移(現在のログインユーザーデータもmodelに格納済み)
@GetMapping
(
"top"
)
public
String
top
(
Model
model
,
@AuthenticationPrincipal
LoginUser
userDetails
)
{
User
user
=
userDetails
.
getUser
();
model
.
addAttribute
(
"user"
,
user
);
return
"index"
;
}
@GetMapping
(
"list"
)
public
String
list
()
{
return
"Hello world"
;
}
}
src/main/resources/templates/index.html
View file @
dfadbcbc
<!DOCTYPE html>
<!DOCTYPE html>
<html
class=
"no-js"
lang=
"ja"
>
<html
class=
"no-js"
lang=
"ja"
xmlns:th=
"http://www.thymeleaf.org"
>
<head>
<head>
<meta
charset=
"utf-8"
/>
<meta
charset=
"utf-8"
/>
<meta
http-equiv=
"X-UA-Compatible"
content=
"IE=edge,chrome=1"
/>
<meta
http-equiv=
"X-UA-Compatible"
content=
"IE=edge,chrome=1"
/>
...
@@ -74,6 +74,7 @@
...
@@ -74,6 +74,7 @@
</ul>-->
</ul>-->
<!--</div> /.navbar-collapse -->
<!--</div> /.navbar-collapse -->
<!--</div> /.container -->
<!--</div> /.container -->
</div>
</nav>
</nav>
</header>
</header>
...
@@ -83,7 +84,7 @@
...
@@ -83,7 +84,7 @@
<div
class=
"col-md-12"
>
<div
class=
"col-md-12"
>
<form
class=
"form-inline col-md-12 wow fadeInDown animated"
>
<form
class=
"form-inline col-md-12 wow fadeInDown animated"
>
<div
class=
"form-group"
>
<div
class=
"form-group"
>
<input
type=
"email"
class=
"form-control subscribe"
id=
"email"
placeholder=
"Search..."
>
<input
type=
"email"
class=
"form-control subscribe"
id=
"email"
placeholder=
"Search..."
/
>
<button
class=
"suscribe-btn"
><i
class=
"pe-7s-search"
></i></button>
<button
class=
"suscribe-btn"
><i
class=
"pe-7s-search"
></i></button>
</div>
</div>
</form>
<!-- end /. form -->
</form>
<!-- end /. form -->
...
@@ -104,27 +105,27 @@
...
@@ -104,27 +105,27 @@
<!-- Wrapper for slides -->
<!-- Wrapper for slides -->
<div
class=
"carousel-inner"
role=
"listbox"
>
<div
class=
"carousel-inner"
role=
"listbox"
>
<div
class=
"item active"
>
<div
class=
"item active"
>
<img
src=
"images/スニーカー1.jpg"
width=
"1648"
height=
"600"
alt=
""
>
<img
src=
"images/スニーカー1.jpg"
width=
"1648"
height=
"600"
alt=
""
/
>
<div
class=
"carousel-caption"
>
<div
class=
"carousel-caption"
>
<h2>
LIMITED SHOES
</h2>
<h2>
LIMITED SHOES
</h2>
<h3><Span>
SALE SITE
</Span></h3>
<h3><Span>
SALE SITE
</Span></h3>
<a
th:href=
"
http://localhost:8080/limited/list
"
>
Go To
</a>
<a
th:href=
"
@{http://localhost:8080/limited/list}
"
>
Go To
</a>
</div>
</div>
</div>
</div>
<div
class=
"item"
>
<div
class=
"item"
>
<img
src=
"images/スニーカー1.jpg"
width=
"1648"
height=
"600"
alt=
""
>
<img
src=
"images/スニーカー1.jpg"
width=
"1648"
height=
"600"
alt=
""
/
>
<div
class=
"carousel-caption"
>
<div
class=
"carousel-caption"
>
<h2>
LIMITED SHOES
</h2>
<h2>
LIMITED SHOES
</h2>
<h3><Span>
SALE SITE
</Span></h3>
<h3><Span>
SALE SITE
</Span></h3>
<a
th:href=
"
http://localhost:8080/limited/list
"
>
Go To
</a>
<a
th:href=
"
@{http://localhost:8080/limited/list}
"
>
Go To
</a>
</div>
</div>
</div>
</div>
<div
class=
"item "
>
<div
class=
"item "
>
<img
src=
"images/スニーカー1.jpg"
width=
"1648"
height=
"600"
alt=
""
>
<img
src=
"images/スニーカー1.jpg"
width=
"1648"
height=
"600"
alt=
""
/
>
<div
class=
"carousel-caption"
>
<div
class=
"carousel-caption"
>
<h2>
LIMITED SHOES
</h2>
<h2>
LIMITED SHOES
</h2>
<h3><Span>
SALE SITE
</Span></h3>
<h3><Span>
SALE SITE
</Span></h3>
<a
th:href=
"
http://localhost:8080/limited/list
"
>
Go To
</a>
<a
th:href=
"
@{http://localhost:8080/limited/list}
"
>
Go To
</a>
</div>
</div>
</div>
</div>
</div>
</div>
...
...
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