Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
J
java_weekendowa_20221008
Overview
Overview
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
Patryk Czarnik
java_weekendowa_20221008
Commits
b1a97377
Commit
b1a97377
authored
Nov 27, 2022
by
Patryk Czarnik
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
WhoAmI i początek zmian w security
parent
e26d672b
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
47 additions
and
2 deletions
+47
-2
SecurityConfig.java
...epSpring/src/main/java/sklep/security/SecurityConfig.java
+0
-2
WhoAmI.java
PC30-SklepSpring/src/main/java/sklep/security/WhoAmI.java
+19
-0
whoami.jsp
...-SklepSpring/src/main/webapp/WEB-INF/templates/whoami.jsp
+28
-0
No files found.
PC30-SklepSpring/src/main/java/sklep/security/SecurityConfig.java
View file @
b1a97377
...
@@ -12,8 +12,6 @@ public class SecurityConfig {
...
@@ -12,8 +12,6 @@ public class SecurityConfig {
SecurityFilterChain
setHttpSecurity
(
HttpSecurity
httpSecurity
)
throws
Exception
{
SecurityFilterChain
setHttpSecurity
(
HttpSecurity
httpSecurity
)
throws
Exception
{
httpSecurity
.
authorizeHttpRequests
()
httpSecurity
.
authorizeHttpRequests
()
.
anyRequest
().
permitAll
()
.
anyRequest
().
permitAll
()
.
and
()
.
csrf
().
disable
()
;
;
return
httpSecurity
.
build
();
return
httpSecurity
.
build
();
}
}
...
...
PC30-SklepSpring/src/main/java/sklep/security/WhoAmI.java
0 → 100644
View file @
b1a97377
package
sklep
.
security
;
import
org.springframework.security.core.Authentication
;
import
org.springframework.stereotype.Controller
;
import
org.springframework.ui.Model
;
import
org.springframework.web.bind.annotation.GetMapping
;
@Controller
public
class
WhoAmI
{
@GetMapping
(
"/whoami"
)
public
String
whoAmI
(
Authentication
authentication
,
Model
model
)
{
if
(
authentication
!=
null
&&
authentication
.
isAuthenticated
())
{
model
.
addAttribute
(
"userName"
,
authentication
.
getName
());
model
.
addAttribute
(
"authorities"
,
authentication
.
getAuthorities
());
}
return
"whoami"
;
}
}
PC30-SklepSpring/src/main/webapp/WEB-INF/templates/whoami.jsp
0 → 100644
View file @
b1a97377
<
%@
page
language=
"java"
contentType=
"text/html; charset=UTF-8"
pageEncoding=
"UTF-8"
%
>
<
%@
taglib
prefix=
"c"
uri=
"http://java.sun.com/jsp/jstl/core"
%
>
<!DOCTYPE html>
<html>
<head>
<meta
charset=
"UTF-8"
>
<title>
Hello
</title>
</head>
<body>
<c:choose>
<c:when
test=
"${not empty userName}"
>
<p>
Jesteś zalogowany jako
<strong>
${userName}
</strong>
.
</p>
<p>
Twoje uprawnienia (
<i>
authorities
</i>
):
</p>
<ul>
<c:forEach
var=
"auth"
items=
"${authorities}"
>
<li>
${auth}
</li>
</c:forEach>
</ul>
</c:when>
<c:otherwise>
<p>
Nie jesteś zalogowany.
</p>
</c:otherwise>
</c:choose>
<div><a
href=
"/"
>
Powrót do spisu treści
</a></div>
<div><a
href=
"/logout"
>
Wyloguj się
</a></div>
</body>
</html>
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