I recently upgraded to Spring Security 6, and have found that authenticating using basic auth from JS or from curl no longer works but authenticating with basic auth using Java’s HttpClient does work. My goal is to be able to authenticate with all approaches. The app uses Java 17, Spring Security 6, and Spring Session 3. It has a “login”
Tag: spring-boot
Spring security exception handling custom response
How is it possible to return a json instead a html? I got: i need something like this: My Adapter: The CustomAuthenticationEntryPoint Answer Pragmatically we can print/write to response[.getWriter()] within our entry point, like: BasicAuthenticationEntryPoint@github Then we can pass a test like: To make it work for basic authetication and “wrong credentials” see also: https://stackoverflow.com/a/74547059/592355 . Dup/Related: How to set
I am trying to create an API using SpringBoot but I don’t know how to handle json request/response
I am new to Java and Spring boot. I am creating a new API. Using postman I am sending a request body which contains request header and request payload. Then I have a controller which handles the request with the help of RequestPayload class. (And a service and dao file but I am sure those are ok.) Kindly let me
Isn’t SecurityContextHolder a Bean?
Trying to Autowire SecurityContextHolder I get error Turns out that it is available from any part of the code like How come it isn’t a bean and how does it get initialized under the hood? Are there other static utility classes like that available to be consumed from anywhere and how do I find them? Answer SecurityContextHolder is a utility
Get records which are last updated in n minutes in jpa
I am working on a jpa query which requires to fetch all the records whose last updated time is more than 15 minutes My query goes like I will be passing the minutes dynamically ie in my jpa This does not work. I want to pass the minute dynamically. Can someone please help me with this Answer You can use
Spring Cloud API Gateway JWT Issue Web Token Issue
I have a problem about sending any request to a defined service through api gateway with the usage of bearer token coming from login. After login, I tried to send a request to a defined service but I got this issue in JWTAuthenticationFilter of api gateway shown below. The exact location is in JWTUtils class with this line shown below.
Error creating table in MSSQL server in Microsoft Azure: Spring Boot and Hibernate
I have created a Spring Boot Web Application with Hibernate. I am using Microsoft Azure and SQL Database to deploy my application. I have configured the database on Azure and in my code. Configuration code is- 1. application.properties file 2. application.yml file I am creating several tables in my database. All the tables are getting created, but one that needs
When is a @JsonCreator method required for parsing?
When I try to parse the following object: I get the error And I solved this by adding a creator to the User class like this: This works fine. So now I go and parse the following object: and I don’t get an error… why? why it doesn’t require me to use a constructor here? Here’s the class where the
Spring Boot – Download a file from GCP Bucket
I’ve a Spring Boot Application and I have to develop an API to download a file from GCP bucket. So I have the download path and the name of the bucket, e.g. Before I start writing the code for download, what are the preliminary steps? I read that I need a GOOGLE_APPLICATION_CREDENTIALS environment variable, where can I find it? Once
Spring Batch: KafkaItemReader reads from offset 0 if the JVM is not restarted
I’m trying to implement a Spring Batch job that is scheduled by a Spring scheduler. The current befavior is as follows: The job is launched by the scheduler using JarLauncher The job consumes the kafka records and processed them The next time the jobs ris launched by the scheduler, it consumes the kafka records already processed The expected behavior is