Welcome. Ask away! Unless otherwise specified we assume you're using the latest 5.x version of Spring Security
Hi
Could someone help me please? I'm getting empty username
parameter in findByUsername(String username)
in ReactiveUserDetailsService
In my security config I defined this:
.formLogin()
.loginPage("/login")
.authenticationManager(new UserDetailsRepositoryReactiveAuthenticationManager(authService))
where authService
is Autowired ReactiveUserDetailsService
I'm sending POST request to /login
with parameters:
{
"username": "<some_username>",
"password": "<some_password>"
}
There is not controller implementing /login
Spring security somehow itslef managing it, so I'm getting hit straight into ReactiveUserDetailsService
but obviously request params were not properly mapped, I'm definitely missing something
username
only from Authentication
object,.authenticationManager(new UserDetailsRepositoryReactiveAuthenticationManager(authService))
ReactiveAuthenticationManager
with implementation of authenticate(Authentication authentication)
authentication
parameter is also empty, and I'm not sure where do I get request body content to return proper Authentication
object with username and password
/login/oauth2/code
endpoint which 302s to https://accounts.google.com/o/oauth2/v2/auth
which seems correct. Domain and SSL cert are matching/correct.
hasAnyIpAddress(String[] ipAddresses)
expression to be an extension to current hasIpAddress(String ipAddress)
. Context: I had to to allow some endpoints to be used only by specified machines that could not be described as normal ip range expression (eg. "192.168.1.1/24"). To accomplish that I had to use some weird string based expression ("hasIpAddress('...') or hasIpAddress('...')"
) which was dynamically generated. What do you think about that?
Hi all,
I need help with the next case:
https://gist.github.com/SteelAlex/ac129a8099c9518e50f6815b3c2bfe1f - I configured Spring Security + Spring Session. I use custom header for session. And I can't change session timeout, I always logout after default 15 minutes of inactivity. I tried to set spring.session.timeout
and/or server.servlet.session.timeout
, but it doesn't work.
I am sure I am doing something wrong, but I have no ideas what.
@Bean
public KeyStoreCallbackHandler callback() throws Exception{
KeyStoreCallbackHandler callbackHandler = new KeyStoreCallbackHandler();
callbackHandler.setPrivateKeyPassword("t_passwordo");
callbackHandler.setDefaultAlias("snet");
callbackHandler.setKeyStore(keyStoreFactoryBean());
callbackHandler.setTrustStore(TrustFactoryBean());
return callbackHandler;
}
can someone help me pls with this:
@miha-
Hello, can some one help me understand this:
i need to sign en encrypt soap request
https://docs.spring.io/spring-ws/site/reference/html/security.html
The XwsSecurityInterceptor will fire a SignatureKeyCallback to the registered handlers. Within Spring-WS, there are is one class which handles this particular callback: the KeyStoreCallbackHandler.
The XwsSecurityInterceptor will fire a EncryptionKeyCallback to the registered handlers in order to retrieve the encryption information. Within Spring-WS, there is one class which handled this particular callback: the KeyStoreCallbackHandler.
so for this only in policy has to be added, other things are the same
@Bean
public KeyStoreCallbackHandler callback() throws Exception{
KeyStoreCallbackHandler callbackHandler = new KeyStoreCallbackHandler();
callbackHandler.setPrivateKeyPassword("t_passwordo");
callbackHandler.setDefaultAlias("snet");
callbackHandler.setKeyStore(keyStoreFactoryBean());
callbackHandler.setTrustStore(TrustFactoryBean());
return callbackHandler;
}
signeture works ok
but for encrypt i get
2019-10-16 09:41:01.902 ERROR 21412 --- [nio-8080-exec-2] j.e.resource.xml.webservices.security : WSS0221: Unable to locate matching certificate for Key Encryption using Callback Handler.
2019-10-16 09:41:01.906 ERROR 21412 --- [nio-8080-exec-2] com.sun.xml.wss.logging.impl.filter : WSS1413: Error extracting certificate
tnx
BindAuthenticator
to authenticate users against LDAP. When the user provides the correct password, it gets correctly authenticated; the problem is when the user provides a wrong password: the authentication takes a very long time and then it fails with a timeout exception.
Hi, I have the following code, it's a MDCFilter.
import org.slf4j.MDC;
import org.springframework.security.oauth2.provider.OAuth2Authentication;
import org.springframework.security.oauth2.server.resource.authentication.BearerTokenAuthentication;
import org.springframework.web.server.ServerWebExchange;
import org.springframework.web.server.WebFilter;
import org.springframework.web.server.WebFilterChain;
import reactor.core.publisher.Mono;
public class NettyMDCFilter implements WebFilter {
public static final String USER_AND_APPLICATION_KEY = "user";
public static final String APPLICATION_KEY = "application";
public static final String USERNAME_KEY = "username";
@Override
public Mono<Void> filter(ServerWebExchange exchange, WebFilterChain chain) {
return exchange.<OAuth2Authentication>getPrincipal()
.doOnNext(this::logWithContext)
.map(auth -> exchange)
.switchIfEmpty(Mono.just(exchange))
.flatMap(chain::filter)
.doFinally(signalType -> removeMDCKeys());
}
private void logWithContext(OAuth2Authentication authentication) {
MDC.put(USER_AND_APPLICATION_KEY, userKey(authentication));
if (authentication.isClientOnly()) {
MDC.put(APPLICATION_KEY, authentication.getName());
} else {
MDC.put(APPLICATION_KEY, authentication.getOAuth2Request().getClientId());
MDC.put(USERNAME_KEY, authentication.getName());
}
}
private void removeMDCKeys() {
MDC.remove(USER_AND_APPLICATION_KEY);
MDC.remove(USERNAME_KEY);
MDC.remove(APPLICATION_KEY);
}
private String userKey(OAuth2Authentication authentication) {
if (authentication.isClientOnly()) {
return authentication.getName();
} else {
return String.format("%s:%s", authentication.getOAuth2Request().getClientId(), authentication.getName());
}
}
}
In the previous implementation was implemented using the class OAuth2Authentication, that belongs to the project the project spring-security-oauth, but this project now is under maintance mode , as you can see here . In my code, I want to check in the filter if the token belongs to a client application or to an user, but I don't have any idea about how could I do this in the new version of spring-security , even reading the documentation it's not clear for me what I should do, because there isn't a migration tutorial to migrate from spring-security-oauth2 project to the spring security project new version with built-in support to oauth2. I googled, but couldn't find a concrete tutorial to help me with this problem.