generated from rzdata/template
init
This commit is contained in:
@@ -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);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -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());
|
||||
}
|
||||
}
|
||||
8
resource-server/src/main/resources/application.yml
Normal file
8
resource-server/src/main/resources/application.yml
Normal file
@@ -0,0 +1,8 @@
|
||||
server:
|
||||
port: 9090
|
||||
spring:
|
||||
security:
|
||||
oauth2:
|
||||
resourceserver:
|
||||
jwt:
|
||||
issuer-uri: http://localhost:9000
|
||||
@@ -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() {
|
||||
}
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user