by

Where communities thrive


  • Join over 1.5M+ people
  • Join over 100K+ communities
  • Free without limits
  • Create your own community
People
Repo info
Activity
    choubani amir
    @amirensit
    in dev here is my configuration:
    @Override
        public void configure(ClientDetailsServiceConfigurer clients) throws Exception {
           clients.inMemory().withClient("sampleClientId")
                .authorizedGrantTypes("implicit")
                .scopes("read", "write", "mobile")
                .redirectUris("http://localhost:8100") // how shall I set this value ?
                .autoApprove(true)
                .accessTokenValiditySeconds(1800);
    }
    Subham Ashish
    @SubhamAshish

    hello all i am using spring secuirty basic
    Spring boot version is 1.5.14.

    i wanted to prevent session hijacking is there any way to do?

    i am facing an issue like once i logged in chrome browser, after that i copied the session and with the same session i tried login different browser and its successful , how to prevent that?
    @josiahhaswell
    Subham Ashish
    @SubhamAshish
    @jzheaux please have a look
    James Howe
    @OrangeDog
    @amirensit it should be something that the app has selected, that it is able to intercept.
    choubani amir
    @amirensit
    @OrangeDog :thumbsup:
    Caleb Cushing
    @xenoterracide
      @Bean
        open fun configure(http: ServerHttpSecurity): SecurityWebFilterChain {
            return http.authorizeExchange()
                // .mvcMatchers(HttpMethod.PUT, "/monitor/**").permitAll()
                .anyExchange().authenticated()
                .and()
                .cors().disable()
                .csrf().disable()
                .build()
        }
    is it possible to do an mvc matcher with reactive, or only ant matchers?
    KayKoder
    @kmaverick
    Anyone know how to make an ssl connection in java
    Caleb Cushing
    @xenoterracide
    @kmaverick that's a big, depends on what you are trying to achieve. if you're making an https connection to a site with a cert signed by a pretrusted CA it's easy, however I suspect you're not trying to do that
    KayKoder
    @kmaverick
    @xenoterracide That is exactly what I am trying to do
    @xenoterracide Yes
    I have the cert, and the trust store ca and the cert password
    I just dont know the most simple way to establish the ssl conneciotn
    connection
    Caleb Cushing
    @xenoterracide
    @kmaverick if you're trying to do an https connection, just go ahead and make one with your http client
    KayKoder
    @kmaverick
    but how do I use the server key and passwords
    @xenoterracide I am not sure how to use the keys after I make a servlet and establish an http connection
    Felipe Adorno
    @FelipeAdorno
    hi guys I have problem when try use RedisTokenStore when clientId has a hyphen, anyone knows about this?
    I change the code to this and works fine:
    byte[] clientId = serializeKey(CLIENT_ID_TO_ACCESS
                    + authentication.getOAuth2Request().getClientId().replace("-", ""));
    Knut Schleßelmann
    @kschlesselmann

    Hi! Right now I try to add https://docs.spring.io/spring-security/site/docs/5.1.5.RELEASE/reference/htmlsingle/#preauth as a new possible way to authenticate users. To fetch the token I have to read a provided cookie. Which parts do I have to provide to get such a setup in a Spring Boot application up and running? Right now I have a AbstractPreAuthenticatedProcessingFilter reading the cookie,

    @Configuration
    class SecurityConfiguration : WebSecurityConfigurerAdapter() {
    
        override fun configure(http: HttpSecurity) {
            val filter = CookieFilter()
            filter.setAuthenticationManager(authenticationManager())
    
            http
                    .addFilterBefore(filter, AbstractPreAuthenticatedProcessingFilter::class.java)
                    .authorizeRequests()
                    .anyRequest().authenticated()
        }
    }

    setting up the filter and a @Service AuthenticationUserDetailsService<PreAuthenticatedAuthenticationToken> which should build the UserDetails based on the token value. I think I'm missing one little step of plumbing here so that everything works together?

    Nasibulloh
    @Nasibulloh
    @dsyer Hi, I am using spring-security-oauth2 . I am sending a request but I am getting the only previous token until the token has expired. But I don't need getting a single token for a user. I want to get a new token for every request. This for multiple users session. The problem is when I get a token, I use it in a device. But I have multiple devices with a single account. If I want to log out(invalidate the token), All my sessions are logging out. This is not a suitable way.
    Ruslan Stelmachenko
    @xak2000
    @Nasibulloh You can implement your own AuthenticationKeyGenerator which can take into account some request param like device_id. Then you can pass this generator to your tokenStore and it will generate new access token based on different keys (returned from AuthenticationKeyGenerator.extractKey). The uniqueness of this key determines if same or new access token will be used.
    Mohsin AR
    @iammohsinar

    hello guys i am implementing user authentication in spring security i am stuck at when authentication exception occur at loginfilter then method of LoginFilter.java

    @Override
        protected void unsuccessfulAuthentication(HttpServletRequest request, HttpServletResponse response,
                AuthenticationException failed) throws IOException, ServletException {
            super.unsuccessfulAuthentication(request, response, failed);
            ObjectMapper mapper = new ObjectMapper();
            response.setCharacterEncoding("UTF-8");
            response.getWriter().write(mapper.writeValueAsString(authException.getAuthentication().getInfo()));
    
        }

    gets executed in above method i have added Info object in response.
    now my question is that after LoginFilter AuthFilter(present in spring security configuration) is executed but only in error or any java exception i don't want this to executed on exception because if user enter wrong user and pass then i want to send response from LoginFilter.

    LoginFilter.java

    public class LoginFilter extends AbstractAuthenticationProcessingFilter {
    // constructor and beans;
    @Override
        public Authentication attemptAuthentication(HttpServletRequest request, HttpServletResponse response)
                throws AuthenticationException, IOException, ServletException {
          // other logic
            return auth;
        }
    @Override
        protected void successfulAuthentication(HttpServletRequest request, HttpServletResponse response, FilterChain chain,
                Authentication authResult) throws IOException, ServletException {
    // logic
    }
    
    @Override
        protected void unsuccessfulAuthentication(HttpServletRequest request, HttpServletResponse response,
                AuthenticationException failed) throws IOException, ServletException {
            super.unsuccessfulAuthentication(request, response, failed);       
    // this method is executed when user attempt wrong username or pass
            ObjectMapper mapper = new ObjectMapper();
            response.setCharacterEncoding("UTF-8");
            response.getWriter().write(mapper.writeValueAsString(authException.getAuthentication().getInfo()));
        }

    AuthFilter.java

    public class AuthFilter extends GenericFilterBean {
    @Override
        public void doFilter(ServletRequest request, ServletResponse response, FilterChain chain)
                throws IOException, ServletException {
    // some other logic
    if (auth.isAuthenticated())
                    chain.doFilter(request, response);
                else {
                    ObjectMapper mapper = new ObjectMapper();
                    res.getWriter().write(mapper.writeValueAsString(auth.getInfo()));
                }
    
    }
    }

    security config

    .and()
    .addFilterBefore(new LoginFilter(new AntPathRequestMatcher("/budget/login")),
                            UsernamePasswordAuthenticationFilter.class)
                    .addFilterBefore(new AuthFilter(),
                            UsernamePasswordAuthenticationFilter.class);
    Mohsin AR
    @iammohsinar
    BTW AuthFilter is for if user is already authenticated so it is working fine for that purpose. i need to stop execute this on exception which occurs in LoginFilter for wrong user and pass
    Hamza Ouni
    @HamzaOuni17_twitter
    Hello, how can i add a custom attribute to samlRequest (im my case the attribute specify the sending channel : web or mobile).
    i do some research about this , i found two solutions either put this in extensions element or in the relayState?
    Sivabalan
    @jofisiva
    Hello Team
    We are currently using wso2 for identity access management and SSO integration with ADFS .Plan to cut down WSO2 dependency
    Is Spring Security 5 can give all functionality ?
    Any thoughts
    we are looking some kind of open source access identity access management
    With SSO capabilities
    James Howe
    @OrangeDog
    There are Spring Security implementations of SAML and OpenID Connect
    Sivabalan
    @jofisiva
    thanks James
    Keerthi Meda
    @krmeda

    Hello Team...
    I am trying to make a starter library (for reactive microservices) for my organization where in I want to configure only the /actuator/** endpoints. I managed to isolate the configuration into an auto-configuration library and am defining the securityWebFilterChain bean where i am able to use a securityMatcher and perform the filtering...

    Further down the chain, when one of the microservices using this library wants to add their own authentication scheme (e.g JWT checking) to the path, they are now having to re-define the full bean including the actuator config to get the required results.

    Is there a built in way of allowing for this customization and injection of additional securityMatchers downstream if a library does the init upstream?

    Sanjeev Ghimire
    @sanjeevghimire
    is it possible to debug @PreAuthorize?
    I added a ROLE at runtime and when I try to hit the API which has that role in hasAnyRole the API gives me Access Denied Exception
    Any Idea?
    when I get that user I see that ROLE in the list of authorities
    this is my API definition:
    @GetMapping("/browse/{videoCatalogType}")
        @PreAuthorize("hasAnyRole(\"" + AuthoritiesConstants.ADMIN + "," + AuthoritiesConstants.CHALCHITRA + "," + AuthoritiesConstants.SUBSCRIBED + "\")")
    Ruslan Stelmachenko
    @xak2000
    @sanjeevghimire Make sure the roles you passed in to hasAnyRole method doesn't contain a ROLE_ prefix. If they contain that prefix, use hasAnyAuthorityinstead.
    piyush-devnow-io
    @piyush-devnow-io
    Hi, I have an api which registers a user into my system. I call it signup api which takes a request including email, password and username and creates a record in the database.
    There is another api which logs in the user (the sign in api) which provides an access token, its expiration duration, emailId as a response.
    My question is -> Can I provide an access token in the response of the signup api as a separate data node in the response? Is it a good design practice ? Is there any other reason why I should not include a access token in the signup api response ?
    Rakesh
    @ravening
    Hi, Im implementing security using JWT in spring boot by following the guide in https://auth0.com/blog/implementing-jwt-authentication-on-spring-boot/ . I am unable to handle the TokenExpiredExcpetion. Does anyone have experience or code samples in doing so?
    Andrew Zurn
    @AndrewZurn

    I'm trying to enable spring security only on the actuator endpoints, and allow all other requests, regardless of auth scheme to pass into the app code (which handles security in it's own regard).

    Right now this is what I have:

        @Bean
        fun securityWebFilterChain(http: ServerHttpSecurity): SecurityWebFilterChain {
            // NOTE: This will only add spring security to the actuator endpoints, all other endpoints will be handled
            // by the JWT auth handling.
            // https://stackoverflow.com/questions/38403740/authenticate-only-selected-rest-end-points-spring-boot
            return http.authorizeExchange()
                .pathMatchers("/actuator/**").authenticated()
                .anyExchange().permitAll()
                .and().httpBasic()
                .and().csrf().disable()
                .build()
        }
    
        @Bean
        fun userDetailsService(): MapReactiveUserDetailsService {
            return MapReactiveUserDetailsService(
                User.withDefaultPasswordEncoder()
                    .username(actuatorAdminUsername)
                    .password(actuatorAdminPassword)
                    .roles("SUPERUSER")
                    .build()
            )
        }

    This works to ensure that:
    1) http basic auth can be used to access the actuator endpoints
    2) any bearer request is passed through into the app code (which is what I want)

    but doesn't allow an http basic auth request to pass through and be handled by my app code. I've tried a few different incantations to get it working as expected, but mostly get the current state or I get it to pass through http basic requests (at which case my auth on the actuator endpoints doesn't work). Any pointers?

    Andrew Zurn
    @AndrewZurn
    Something else of interest, if I change the Authorization header key on the request I'm sending to Proxy-Authentication, it passes through just fine.
    Andrew Zurn
    @AndrewZurn
    Looks like using the securityMatcher on the http object and setting up separate filters seems to have done the trick.
    Marco Zanghì
    @marcozanghi
    Hi everyone, I am trying to save to db an acl entry using acl spring. I am using the mustableaclservice but i can't see any new record in the db. (I am using also ehcache) any ideas?
    choubani amir
    @amirensit
    hello.
    Please any idea what is the difference between these two dependencies:
    spring-security-config and spring-security-web ?
    James Howe
    @OrangeDog
    @amirensit they do completely different things, as indicated by the names
    Marco Zanghì
    @marcozanghi
    hi @OrangeDog, do you have any ideas how to save acl entries by using spring security support? It is possible to do that whit jdbc mutable service?
    James Howe
    @OrangeDog
    That's literally what JdbcMutableAclService says it's for
    Marco Zanghì
    @marcozanghi
    Sì, ma quando eseguo un updateAcl non ho la relativa voce acl nella tabella acl_entry
    I am using ehcache .