This commit is contained in:
chong-de.fang
2023-09-08 09:36:20 +08:00
parent 5ef9a7ae56
commit 4b514cee81
34 changed files with 2170 additions and 0 deletions

View File

@@ -0,0 +1,13 @@
package com.leonardozw.resourceserver;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
@SpringBootApplication
public class ResourceServerApplication {
public static void main(String[] args) {
SpringApplication.run(ResourceServerApplication.class, args);
}
}

View File

@@ -0,0 +1,27 @@
package com.leonardozw.resourceserver;
import org.springframework.security.core.annotation.AuthenticationPrincipal;
import org.springframework.security.oauth2.jwt.Jwt;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
@RestController
@RequestMapping("tasks")
public class TasksController {
@GetMapping
public String getTasks(
@AuthenticationPrincipal Jwt jwt
){
return """
<h1>Top secret task for %s</h1>
<p>Do not share with anyone!</p>
<ol>
<li>Buy milk</li>
<li>Buy eggs</li>
<li>Buy bread</li>
</ol>
""".formatted(jwt.getSubject());
}
}

View File

@@ -0,0 +1,8 @@
server:
port: 9090
spring:
security:
oauth2:
resourceserver:
jwt:
issuer-uri: http://localhost:9000

View File

@@ -0,0 +1,13 @@
package com.leonardozw.resourceserver;
import org.junit.jupiter.api.Test;
import org.springframework.boot.test.context.SpringBootTest;
@SpringBootTest
class ResourceServerApplicationTests {
@Test
void contextLoads() {
}
}