spring-security

Why this Spring application with java-based configuration don't work properly

一世执手 提交于 2019-12-28 02:56:05
问题 I started recently a project with the Spring framework with the ojective to develop it without none XML config file, only Java code. In this current moment, I add the follow files to my project: WebAppConfig.java @EnableWebMvc @ComponentScan(value="org.webapp") @Configuration public class WebAppConfig extends WebMvcConfigurerAdapter { @Override public void addResourceHandlers(ResourceHandlerRegistry registry) { registry.addResourceHandler("/css/**").addResourceLocations("/css/")

Spring security: adding “On successful login event listener”

情到浓时终转凉″ 提交于 2019-12-28 02:32:15
问题 I'm new to Spring Security. How do I add an event listener which will be called as a user logs in successfully? Also I need to get some kind of unique session ID in this listener which should be available further on. I need this ID to synchronize with another server. 回答1: You need to define a Spring Bean which implements ApplicationListener. Then, in your code, do something like this: public void onApplicationEvent(ApplicationEvent appEvent) { if (appEvent instanceof

Logging user activity in web app

筅森魡賤 提交于 2019-12-27 19:13:58
问题 I'd like to be able to log user activities in a web app. I'm currently using log4j which works well for logging errors etc, but I'm unsure what the best approach is to log the user, executed servlet method, and method params. I'm using spring security for the authentication. A typical servlet could look like: public class BankAccountServlet { @RequestMapping("/deposit") public void deposit(double amount) { ... } @RequestMapping("/checkBalance") public double checkBalance() { ... } } If there

Logging user activity in web app

南楼画角 提交于 2019-12-27 19:13:30
问题 I'd like to be able to log user activities in a web app. I'm currently using log4j which works well for logging errors etc, but I'm unsure what the best approach is to log the user, executed servlet method, and method params. I'm using spring security for the authentication. A typical servlet could look like: public class BankAccountServlet { @RequestMapping("/deposit") public void deposit(double amount) { ... } @RequestMapping("/checkBalance") public double checkBalance() { ... } } If there

How to write a custom filter in spring security?

大城市里の小女人 提交于 2019-12-27 17:29:32
问题 I want to receive some information per request, so I think instead of having a function for each request and obtaining those information from requests separately, it's better to have a filter. So every request shall pass that filter and I gain what I want. The question is: How can I write a custom filter? Suppose it is not like any predefined spring security filters and it is totally new. 回答1: You can use the standard Java filter. Just place it after authentication filter in web.xml (this

Spring boot Security Disable security

守給你的承諾、 提交于 2019-12-27 17:07:54
问题 When I use security.basic.enabled=false to disable security on a Spring Boot project that has the following dependencies: <dependency> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-starter-web</artifactId> </dependency> <dependency> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-starter-security</artifactId> </dependency> <dependency> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-starter-actuator</artifactId> </dependency>

Can't load my css when using spring security and thymeleaf

给你一囗甜甜゛ 提交于 2019-12-26 03:54:14
问题 I am not able to load my css file while using spring security and thymeleaf. Whenever i use rel="stylesheet" it gives me Strict MIME enable error. My css file is in resources/static folder My html file is resources/template. HTML HEAD: <head> <meta charset="utf-8"> <meta http-equiv="X-UA-Compatible" content="IE=edge"> <meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no"> <title>Login</title> <meta http-equiv="content-type" content="text/css; charset=UTF-8">

Can't load my css when using spring security and thymeleaf

孤街醉人 提交于 2019-12-26 03:54:11
问题 I am not able to load my css file while using spring security and thymeleaf. Whenever i use rel="stylesheet" it gives me Strict MIME enable error. My css file is in resources/static folder My html file is resources/template. HTML HEAD: <head> <meta charset="utf-8"> <meta http-equiv="X-UA-Compatible" content="IE=edge"> <meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no"> <title>Login</title> <meta http-equiv="content-type" content="text/css; charset=UTF-8">

Getting error while Giving Request to MyCompany in Broadleaf Commerce

无人久伴 提交于 2019-12-25 16:50:14
问题 We are using BroadLeafCommerce Framework 3.1.0 for our application, After doing all the changes, If we'll give a request to Admin , All are good. But, If we give request to mycompany, we are getting the following stacktrace. Help me on this. Thanks --SKC java.lang.NullPointerException at org.broadleafcommerce.common.web.BroadleafRequestCustomerResolverImpl.setCustomer(BroadleafRequestCustomerResolverImpl.java:62) at org.broadleafcommerce.profile.web.core.CustomerState.setCustomer

Spring Security - “Error: Forbidden” response from rest endpoint

一笑奈何 提交于 2019-12-25 16:38:06
问题 I'm setting up Spring Security in my project and I'm having some trouble hitting one of my rest endpoints. I receive an "Error: Forbidden" response from the server when I hit the endpoint through my client. What I'm doing is going to the login page (I assume at this point I'm an anonymous user with ROLE_ANONYMOUS) and clicking a tab that shows me a create new account form. When I fill out the fields and hit submit then the rest endpoint is called and the JSON data is sent to the server. In my