spring-projects / spring-projects/spring-security

logout url not responding with https

Open
#3,988 4 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

status: waiting-for-triage
Dominant language
Java
Stars
9.6k
Forks
6.3k
Avg merge
2d 11h
Merged PRs (30d)
52

Description

Summary

I've got my spring boot container behind Amazon cloudfront with the following settings

server.tomcat.remote_ip_header=x-forwarded-for
server.tomcat.protocol_header=x-forwarded-proto

it has worked well for everything so (including some returned Hateoas links) except now for logout. I set the logout url to / it's returning the right domain, but not https.
`

Actual Behavior

post to logout, via proxy via https://domain.tld returns a 302 http://domain.tld/

Expected Behavior

post to logout, via proxy via https://domain.tld should return a 302 https://domain.tld/

Configuration
@EnableWebSecurity
class WebSecurityConfig extends WebSecurityConfigurerAdapter {


    @Override
    public void configure( final WebSecurity web ) throws Exception {
        web.ignoring()
                .antMatchers( "/", "/index.html", "/partials/**/*.html" )
                .antMatchers( "/webjars/**/*.js" )
                .antMatchers( "/webjars/**/*.css" );
    }

    @Override
    protected void configure( final HttpSecurity http ) throws Exception {
        http.authorizeRequests().anyRequest().authenticated()
                .and().httpBasic()
                .and().logout().logoutSuccessUrl( "/" )
                .and().csrf().disable();
    }

}
Version

4.0.x

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start with the WebSecurityConfig example, especially HttpSecurity logoutSuccessUrl, and reproduce the 302 through CloudFront using the shown x-forwarded-for and x-forwarded-proto settings. Trace how the logout success redirect is constructed and verify that posting to logout through HTTPS returns https://domain.tld/ rather than an HTTP URL.

Written by the indexing model from the issue text.

Assessment

Tech stack
java, spring, spring-boot
Domain
authentication, backend, security
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.