Skip to content

Commit d4d574d

Browse files
committed
cleanup and add spring profiles for solution
1 parent 6f6d742 commit d4d574d

File tree

15 files changed

+110
-100
lines changed

15 files changed

+110
-100
lines changed

README.md

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,9 +30,13 @@ Please follow the provided step-by-step [Tutorial](https://andifalk.gitbook.io/o
3030
* [Lab 1: The server side (resource server)](labs/initial/product/README.md)
3131
* [Lab 2: The client side](labs/initial/ui/README.md)
3232

33+
## Feedback
34+
35+
Any feedback on this hands-on workshop is highly appreciated.
36+
Just email _andreas.falk(at)novatec-gmbh.de_ or contact me via Twitter (_@andifalk_).
37+
3338
## License
3439

3540
Apache 2.0 licensed
36-
Copyright (c) by 2023 Andreas Falk
3741

3842
[1]:http://www.apache.org/licenses/LICENSE-2.0.txt

introduction/architecture/README.md

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -16,11 +16,11 @@ These microservices are configured to be reachable via the following URL address
1616

1717
Service URLs:
1818

19-
| Service | URL |
20-
|--------------------------------|------------------------------|
21-
| OIDC Identity Provider | https://localhost:9000 |
22-
| Client (UI) | http://localhost:9095/client |
23-
| Resource Server (Products API) | http://localhost:9090/server |
19+
| Service | URL |
20+
|--------------------------------|--------------------------------------------------------------|
21+
| OIDC Identity Provider | [http://localhost:9000](http://localhost:9000) |
22+
| Client (UI) | [http://localhost:9095/client](http://localhost:9095/client) |
23+
| Resource Server (Products API) | [http://localhost:9090/server](http://localhost:9090/server) |
2424

2525
## Project contents
2626

labs/initial/README.md

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,6 @@
1-
# cloud-security-workshop
2-
Workshop on building secure cloud-native applications using spring security.
3-
4-
## Initial OAuth2 Security Workshop
1+
# Initial Sample Applications for the Workshop
52

63
You can find the initial applications for the workshop here:
74

8-
* product: Spring boot application providing a rest api for products: http://localhost:8080/products
9-
* ui: A Spring boot application providing thymeleaf based html frontend to display products
5+
* __product__: Spring boot application providing a REST API for products
6+
* __ui__: A Spring boot application providing thymeleaf based html frontend to display products

labs/initial/product/README.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
# Product Server (Resource server)
1+
# Lab 1: The server side (resource server)
22

33
> __Tip__:
44
> You may look into the [Spring Boot Reference Documentation](https://docs.spring.io/spring-boot/docs/current/reference/htmlsingle/#boot-features-security-oauth2-server)
@@ -215,10 +215,10 @@ instead by default the class `org.springframework.security.oauth2.jwt.Jwt` will
215215
```java
216216
@RestController
217217
public class ProductRestController {
218-
...
218+
//...
219219
@GetMapping(path = "/products")
220220
public List<Product> getAllProducts(@AuthenticationPrincipal(errorOnInvalidType = true) ProductUser productUser) {
221-
...
221+
//...
222222
}
223223
}
224224
```

labs/initial/product/src/main/java/com/example/security/MethodSecurityConfiguration.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,4 +5,5 @@
55

66
@EnableMethodSecurity
77
@Configuration
8-
public class MethodSecurityConfiguration {}
8+
public class MethodSecurityConfiguration {
9+
}

labs/initial/ui/README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
# Product Client Frontend UI
1+
# Lab 2: The client side
22

33
Now we will implement the corresponding client for the product server to show the product list in a web UI.
44

labs/initial/ui/src/main/java/com/example/ProductService.java

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,14 +3,16 @@
33
import org.slf4j.Logger;
44
import org.slf4j.LoggerFactory;
55
import org.springframework.beans.factory.annotation.Value;
6-
import org.springframework.http.*;
6+
import org.springframework.http.HttpEntity;
7+
import org.springframework.http.HttpHeaders;
8+
import org.springframework.http.HttpStatusCode;
9+
import org.springframework.http.ResponseEntity;
710
import org.springframework.security.access.AccessDeniedException;
811
import org.springframework.security.core.Authentication;
912
import org.springframework.security.core.context.SecurityContextHolder;
1013
import org.springframework.security.core.userdetails.UserDetails;
1114
import org.springframework.security.core.userdetails.UserDetailsService;
1215
import org.springframework.stereotype.Service;
13-
import org.springframework.web.client.DefaultResponseErrorHandler;
1416
import org.springframework.web.client.HttpClientErrorException;
1517
import org.springframework.web.client.RestTemplate;
1618

labs/initial/ui/src/main/java/com/example/WebSecurityConfiguration.java

Lines changed: 18 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -31,24 +31,24 @@ public SecurityFilterChain api(HttpSecurity http) throws Exception {
3131
@Bean
3232
public UserDetailsService productUserDetailsService() {
3333
return new InMemoryUserDetailsManager(
34-
builder()
35-
.username("bruce.wayne@example.com")
36-
.password("wayne")
37-
.passwordEncoder(passwordEncoder()::encode)
38-
.roles("USER")
39-
.build(),
40-
builder()
41-
.username("clark.kent@example.com")
42-
.password("kent")
43-
.passwordEncoder(passwordEncoder()::encode)
44-
.roles("USER")
45-
.build(),
46-
builder()
47-
.username("peter.parker@example.com")
48-
.password("parker")
49-
.passwordEncoder(passwordEncoder()::encode)
50-
.roles("USER", "ADMIN")
51-
.build()
34+
builder()
35+
.username("bruce.wayne@example.com")
36+
.password("wayne")
37+
.passwordEncoder(passwordEncoder()::encode)
38+
.roles("USER")
39+
.build(),
40+
builder()
41+
.username("clark.kent@example.com")
42+
.password("kent")
43+
.passwordEncoder(passwordEncoder()::encode)
44+
.roles("USER")
45+
.build(),
46+
builder()
47+
.username("peter.parker@example.com")
48+
.password("parker")
49+
.passwordEncoder(passwordEncoder()::encode)
50+
.roles("USER", "ADMIN")
51+
.build()
5252
);
5353
}
5454

labs/solution/README.md

Lines changed: 4 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,6 @@
1-
# cloud-security-workshop
2-
Workshop on building secure cloud-native applications using spring cloud security (OAuth2).
1+
# Reference Solution of Sample Applications for the Workshop
32

4-
## OAuth2 Security Workshop Reference (Step 1)
5-
6-
You can find the completed applications for step 1 of the workshop here:
7-
8-
* product: Spring boot application providing a rest api for products: http://localhost:8080/products
9-
* ui: A Spring boot application providing thymeleaf based html frontend to display products
10-
11-
In this step user credentials are configured using the _application.properties_ file.
12-
Here the authorization server uses basic authentication as login type.
13-
14-
Username: _user_
15-
Password: _secret_
3+
You can find the reference solution for the applications of the workshop here:
164

5+
* __product__: Spring boot application providing a REST API for products, extended to serve as OAuth/OIDC resource server
6+
* __ui__: A Spring boot application providing thymeleaf based html frontend to display products, extended as OAuth/OIDC client

labs/solution/product/src/main/java/com/example/security/MethodSecurityConfiguration.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,4 +5,5 @@
55

66
@EnableMethodSecurity
77
@Configuration
8-
public class MethodSecurityConfiguration {}
8+
public class MethodSecurityConfiguration {
9+
}

0 commit comments

Comments
 (0)