spring-boot

Return custom http error message from Spring Security filter

萝らか妹 提交于 2021-02-10 23:20:50
问题 I am building a REST API that uses Spring Security (and it's filter chain) to authenticate the user via JWT. Now, if such a JWT is missing, expired or similar, I would like to return a nicely formatted error message to the API consumer, instead of the default whitelabel error response. The API error messages returned out of the Spring Security filter should look identical to the ones returned in case of business logic failure. In case of business logic failure, my Spring REST controllers

Should I explicitly verify Keycloak token or this is done by Keycloak adapter?

馋奶兔 提交于 2021-02-10 23:14:35
问题 There is a Spring-boot REST API, that needs to be secured by Keycloak, the application is using Keycloak-Spring-Security adapter (6.0.1). A call to an API endpoint, carries along the bearer token, obtained from Keycloak (currently through postman). I'm able to perform a successful REST endpoint call, but other thing is troubling me - should I explicitly verify the token against the public key? 1 - Is the adapter performing verification of the token against the public key, or should I

Should I explicitly verify Keycloak token or this is done by Keycloak adapter?

我与影子孤独终老i 提交于 2021-02-10 23:14:07
问题 There is a Spring-boot REST API, that needs to be secured by Keycloak, the application is using Keycloak-Spring-Security adapter (6.0.1). A call to an API endpoint, carries along the bearer token, obtained from Keycloak (currently through postman). I'm able to perform a successful REST endpoint call, but other thing is troubling me - should I explicitly verify the token against the public key? 1 - Is the adapter performing verification of the token against the public key, or should I

Should I explicitly verify Keycloak token or this is done by Keycloak adapter?

旧时模样 提交于 2021-02-10 23:09:50
问题 There is a Spring-boot REST API, that needs to be secured by Keycloak, the application is using Keycloak-Spring-Security adapter (6.0.1). A call to an API endpoint, carries along the bearer token, obtained from Keycloak (currently through postman). I'm able to perform a successful REST endpoint call, but other thing is troubling me - should I explicitly verify the token against the public key? 1 - Is the adapter performing verification of the token against the public key, or should I

Spring Boot @ComponentScan finds candidate component class but does not inject @Configuration beans

南楼画角 提交于 2021-02-10 22:45:16
问题 I have @SpringBootApplication with @ComponentScan({"myPackage"}) and in myPackage I have a class annotated with @Configuration or @Component . When I start the spring boot app the logs show: DEBUG [main] org.sprin.conte.annot.ClassPathScanningCandidateComponentProvider 437 scanCandidateComponents: Identified candidate component class: file [C:\Web\project\bin\main\myPackage\Config.class] but then nothing injects the class or its beans into the app... It looks related to this CODE package app;

How does Spring multipart file upload exactly work?

余生颓废 提交于 2021-02-10 22:28:09
问题 I develope a fileserver that has to handle large file uploads (>1G B) with spring boot. How can I implement the upload when I do not want to use the main memory? This is my code: final String id = GenerationHelper.uuid(); final File newFile = new File(id); LOG.info("New file: " + id + " with size " + content.getSize()); if (!content.isEmpty()) { FileInputStream in = null; FileOutputStream out = null; long totalBytes = 0; try { in = (FileInputStream) content.getInputStream(); out = new

CSS file cannot be located thymeleaf Spring Boot

若如初见. 提交于 2021-02-10 22:26:37
问题 I'm setting up a Spring boot server and I just can't get Thymeleaf to link to the CSS. I know there are a number of similar questions but none of them lead me to an answer. This is the link included in my "home.html". <link rel="stylesheet" type="text/css" href="webjars/bootstrap/3.3.7/css/bootstrap.min.css" /> <link rel="stylesheet" th:href="@{/styles/main.css}" href="../styles/main.css" /> bootstrap.min.css links fine but main.css gives me a 404. Project Structure This is what it shows me

How does Spring multipart file upload exactly work?

可紊 提交于 2021-02-10 22:20:35
问题 I develope a fileserver that has to handle large file uploads (>1G B) with spring boot. How can I implement the upload when I do not want to use the main memory? This is my code: final String id = GenerationHelper.uuid(); final File newFile = new File(id); LOG.info("New file: " + id + " with size " + content.getSize()); if (!content.isEmpty()) { FileInputStream in = null; FileOutputStream out = null; long totalBytes = 0; try { in = (FileInputStream) content.getInputStream(); out = new

CSS file cannot be located thymeleaf Spring Boot

ⅰ亾dé卋堺 提交于 2021-02-10 22:12:28
问题 I'm setting up a Spring boot server and I just can't get Thymeleaf to link to the CSS. I know there are a number of similar questions but none of them lead me to an answer. This is the link included in my "home.html". <link rel="stylesheet" type="text/css" href="webjars/bootstrap/3.3.7/css/bootstrap.min.css" /> <link rel="stylesheet" th:href="@{/styles/main.css}" href="../styles/main.css" /> bootstrap.min.css links fine but main.css gives me a 404. Project Structure This is what it shows me

Bind .m2 file to docker on build stage

孤街浪徒 提交于 2021-02-10 20:49:01
问题 I tried build a spring boot project in docker container based on below docker file.But every times all mvn dependency download from internet. How can I bind local .m2 file when i build the docker file. This is my Dockerfile FROM maven:3.5-jdk-8-alpine AS build COPY /src /usr/src/javaspring/src COPY pom.xml /usr/src/javaspring COPY Dockerfile /usr/src/javaspring RUN mvn -f /usr/src/javaspring/pom.xml clean install FROM openjdk:8-jre-alpine COPY --from=build /usr/src/javaspring/target