Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
2
20240528-BJava
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
20240528-BJava
Commits
df6c0198
Commit
df6c0198
authored
Jun 27, 2024
by
Patryk Czarnik
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
in Memory users
parent
74e47dcb
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
20 additions
and
1 deletions
+20
-1
Customer.java
PC33-SklepSpring/src/main/java/sklep/model/Customer.java
+2
-0
SecurityConfig.java
...epSpring/src/main/java/sklep/security/SecurityConfig.java
+18
-1
No files found.
PC33-SklepSpring/src/main/java/sklep/model/Customer.java
View file @
df6c0198
package
sklep
.
model
;
import
com.fasterxml.jackson.annotation.JsonIgnore
;
import
jakarta.persistence.*
;
import
jakarta.validation.constraints.Email
;
import
jakarta.validation.constraints.Pattern
;
...
...
@@ -32,6 +33,7 @@ public class Customer {
private
String
city
;
@OneToMany
(
mappedBy
=
"customer"
)
@JsonIgnore
private
Set
<
Order
>
orders
=
new
LinkedHashSet
<>();
public
String
getCustomerEmail
()
{
...
...
PC33-SklepSpring/src/main/java/sklep/security/SecurityConfig.java
View file @
df6c0198
...
...
@@ -2,7 +2,11 @@ package sklep.security;
import
org.springframework.context.annotation.Bean
;
import
org.springframework.context.annotation.Configuration
;
import
org.springframework.security.config.Customizer
;
import
org.springframework.security.config.annotation.web.builders.HttpSecurity
;
import
org.springframework.security.core.userdetails.User
;
import
org.springframework.security.core.userdetails.UserDetails
;
import
org.springframework.security.provisioning.InMemoryUserDetailsManager
;
import
org.springframework.web.servlet.handler.HandlerMappingIntrospector
;
import
org.springframework.security.web.SecurityFilterChain
;
...
...
@@ -11,10 +15,23 @@ public class SecurityConfig {
@Bean
SecurityFilterChain
configHttpSecurity
(
HttpSecurity
httpSecurity
,
HandlerMappingIntrospector
hmi
)
throws
Exception
{
httpSecurity
.
authorizeHttpRequests
(
auth
->
auth
.
anyRequest
().
permitAll
())
httpSecurity
.
authorizeHttpRequests
(
auth
->
auth
.
anyRequest
().
authenticated
())
.
formLogin
(
Customizer
.
withDefaults
())
// .httpBasic(Customizer.withDefaults())
.
csrf
(
config
->
config
.
disable
())
.
cors
(
config
->
config
.
disable
());
return
httpSecurity
.
build
();
}
@Bean
InMemoryUserDetailsManager
userDetailsService
()
{
UserDetails
[]
users
=
{
User
.
withUsername
(
"ala"
).
password
(
"{noop}ala123"
).
roles
(
"manager"
,
"worker"
).
build
(),
User
.
withUsername
(
"ola"
).
password
(
"{noop}ola123"
).
roles
(
"worker"
).
build
(),
};
return
new
InMemoryUserDetailsManager
(
users
);
}
}
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