Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add endpoints for internal services #98

Open
wants to merge 2 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@

@Slf4j
@RestController
@RequestMapping("/api/catalog/books")
@RequestMapping({"/api/catalog/books", "/api/catalog/internal/books"})
record GetBookApi(GetBookQuery getBookQuery, GetBookDtoMapper getBookDtoMapper) {

@GetMapping("/{bookId}")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ public class RentalsApiClient implements RentalsClient {

private ObjectMapper objectMapper = new ObjectMapper();

public RentalsApiClient(@Value("${rental.service.url}/api/rental/book/") String rentalsServiceUrl) {
public RentalsApiClient(@Value("${rental.service.url}/api/rental/books/") String rentalsServiceUrl) {
this.rentalsServiceUrl = rentalsServiceUrl;
}

Expand Down
3 changes: 2 additions & 1 deletion src/main/java/com/productdock/config/SecurityConfig.java
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
@RequiredArgsConstructor
@Configuration
public class SecurityConfig {

private static final String ROLE_ADMIN = "SCOPE_ROLE_ADMIN";

@Value("${jwt.public.key}")
Expand All @@ -27,6 +27,7 @@ public SecurityFilterChain securityFilterChain(HttpSecurity http) throws Excepti
http.authorizeRequests(authorize -> authorize.antMatchers("/actuator/**").permitAll()
.antMatchers(HttpMethod.POST, "/api/catalog/books").hasAuthority(ROLE_ADMIN)
.antMatchers(HttpMethod.DELETE, "/api/catalog/books/{bookId}").hasAuthority(ROLE_ADMIN)
.antMatchers("/api/catalog/internal/**").permitAll()
.anyRequest().authenticated())
.cors().and()
.oauth2ResourceServer().jwt();
Expand Down
Loading