Using SAML with Spring Boot behind an ELB redirects to http instead of https











up vote
1
down vote

favorite












I'm trying to use Okta to authenticate users from a SpringBoot application.



I've setup the app following the Okta Tutorial from : https://developer.okta.com/blog/2017/03/16/spring-boot-saml



However my app is behind an ELB, and as such the TLS is being terminated at the LB. So I've modified the configuration from the tutorial to suit my needs.



 @Override
protected void configure(final HttpSecurity http) throws Exception {
http
.authorizeRequests()
.antMatchers("/saml*").permitAll()
.anyRequest().authenticated()
.and()
.apply(saml())
.serviceProvider()
.keyStore()
.storeFilePath(this.keyStoreFilePath)
.password(this.password)
.keyname(this.keyAlias)
.keyPassword(this.password)
.and()
.protocol("https")
.hostname(String.format("%s", serverName))
.basePath("/")
.and()
.identityProvider()
.metadataFilePath(this.metadataUrl);
}


This does the trick but there is a problem. After the user is authenticated by Okta, the user is finally redirected to a http URL instead of a https URL. I am thinking the reason for this is that the TLS is being terminated at the LB and my app is actually receiving the request with http which is being sent in the RelayState.



This is something I found : spring-boot-security-saml-config-options.md.
It contains a list of SAML properties for spring boot security. I added the following to the application.properties file



saml.sso.context-provider.lb.enabled = true
saml.sso.context-provider.lb.scheme=https
saml.sso.profile-options.relay-state=<https://my.website.com>


It doesn't change the http redirection. Is there something I am doing wrong?










share|improve this question


























    up vote
    1
    down vote

    favorite












    I'm trying to use Okta to authenticate users from a SpringBoot application.



    I've setup the app following the Okta Tutorial from : https://developer.okta.com/blog/2017/03/16/spring-boot-saml



    However my app is behind an ELB, and as such the TLS is being terminated at the LB. So I've modified the configuration from the tutorial to suit my needs.



     @Override
    protected void configure(final HttpSecurity http) throws Exception {
    http
    .authorizeRequests()
    .antMatchers("/saml*").permitAll()
    .anyRequest().authenticated()
    .and()
    .apply(saml())
    .serviceProvider()
    .keyStore()
    .storeFilePath(this.keyStoreFilePath)
    .password(this.password)
    .keyname(this.keyAlias)
    .keyPassword(this.password)
    .and()
    .protocol("https")
    .hostname(String.format("%s", serverName))
    .basePath("/")
    .and()
    .identityProvider()
    .metadataFilePath(this.metadataUrl);
    }


    This does the trick but there is a problem. After the user is authenticated by Okta, the user is finally redirected to a http URL instead of a https URL. I am thinking the reason for this is that the TLS is being terminated at the LB and my app is actually receiving the request with http which is being sent in the RelayState.



    This is something I found : spring-boot-security-saml-config-options.md.
    It contains a list of SAML properties for spring boot security. I added the following to the application.properties file



    saml.sso.context-provider.lb.enabled = true
    saml.sso.context-provider.lb.scheme=https
    saml.sso.profile-options.relay-state=<https://my.website.com>


    It doesn't change the http redirection. Is there something I am doing wrong?










    share|improve this question
























      up vote
      1
      down vote

      favorite









      up vote
      1
      down vote

      favorite











      I'm trying to use Okta to authenticate users from a SpringBoot application.



      I've setup the app following the Okta Tutorial from : https://developer.okta.com/blog/2017/03/16/spring-boot-saml



      However my app is behind an ELB, and as such the TLS is being terminated at the LB. So I've modified the configuration from the tutorial to suit my needs.



       @Override
      protected void configure(final HttpSecurity http) throws Exception {
      http
      .authorizeRequests()
      .antMatchers("/saml*").permitAll()
      .anyRequest().authenticated()
      .and()
      .apply(saml())
      .serviceProvider()
      .keyStore()
      .storeFilePath(this.keyStoreFilePath)
      .password(this.password)
      .keyname(this.keyAlias)
      .keyPassword(this.password)
      .and()
      .protocol("https")
      .hostname(String.format("%s", serverName))
      .basePath("/")
      .and()
      .identityProvider()
      .metadataFilePath(this.metadataUrl);
      }


      This does the trick but there is a problem. After the user is authenticated by Okta, the user is finally redirected to a http URL instead of a https URL. I am thinking the reason for this is that the TLS is being terminated at the LB and my app is actually receiving the request with http which is being sent in the RelayState.



      This is something I found : spring-boot-security-saml-config-options.md.
      It contains a list of SAML properties for spring boot security. I added the following to the application.properties file



      saml.sso.context-provider.lb.enabled = true
      saml.sso.context-provider.lb.scheme=https
      saml.sso.profile-options.relay-state=<https://my.website.com>


      It doesn't change the http redirection. Is there something I am doing wrong?










      share|improve this question













      I'm trying to use Okta to authenticate users from a SpringBoot application.



      I've setup the app following the Okta Tutorial from : https://developer.okta.com/blog/2017/03/16/spring-boot-saml



      However my app is behind an ELB, and as such the TLS is being terminated at the LB. So I've modified the configuration from the tutorial to suit my needs.



       @Override
      protected void configure(final HttpSecurity http) throws Exception {
      http
      .authorizeRequests()
      .antMatchers("/saml*").permitAll()
      .anyRequest().authenticated()
      .and()
      .apply(saml())
      .serviceProvider()
      .keyStore()
      .storeFilePath(this.keyStoreFilePath)
      .password(this.password)
      .keyname(this.keyAlias)
      .keyPassword(this.password)
      .and()
      .protocol("https")
      .hostname(String.format("%s", serverName))
      .basePath("/")
      .and()
      .identityProvider()
      .metadataFilePath(this.metadataUrl);
      }


      This does the trick but there is a problem. After the user is authenticated by Okta, the user is finally redirected to a http URL instead of a https URL. I am thinking the reason for this is that the TLS is being terminated at the LB and my app is actually receiving the request with http which is being sent in the RelayState.



      This is something I found : spring-boot-security-saml-config-options.md.
      It contains a list of SAML properties for spring boot security. I added the following to the application.properties file



      saml.sso.context-provider.lb.enabled = true
      saml.sso.context-provider.lb.scheme=https
      saml.sso.profile-options.relay-state=<https://my.website.com>


      It doesn't change the http redirection. Is there something I am doing wrong?







      spring-boot saml-2.0 spring-saml okta






      share|improve this question













      share|improve this question











      share|improve this question




      share|improve this question










      asked Nov 19 at 7:15









      Debashis Ghosh

      61




      61
























          1 Answer
          1






          active

          oldest

          votes

















          up vote
          0
          down vote













          When a SAML 2.0 IdP like Okta redirects back to you application the endpoint url is either based on the SAML 2.0 metadata you application expose or the configuration in the IdP.



          Furthermore, it is optional to add a Destination property in SAML 2.0 AuthnRequest:



          <samlp:AuthnRequest xmlns:samlp="urn:oasis:names:tc:SAML:2.0:protocol" Consent="urn:oasis:names:tc:SAML:2.0:consent:unspecified" 
          Destination="https://my.website.com" IssueInstant="2018-11-22T09:23:08.844Z" Version="2.0" ID="id-f8ee3ab1-6745-42d5-b00f-7845b97fe953">
          <Issuer xmlns="urn:oasis:names:tc:SAML:2.0:assertion"> ... </Issuer>
          ...
          </samlp:AuthnRequest>





          share|improve this answer





















            Your Answer






            StackExchange.ifUsing("editor", function () {
            StackExchange.using("externalEditor", function () {
            StackExchange.using("snippets", function () {
            StackExchange.snippets.init();
            });
            });
            }, "code-snippets");

            StackExchange.ready(function() {
            var channelOptions = {
            tags: "".split(" "),
            id: "1"
            };
            initTagRenderer("".split(" "), "".split(" "), channelOptions);

            StackExchange.using("externalEditor", function() {
            // Have to fire editor after snippets, if snippets enabled
            if (StackExchange.settings.snippets.snippetsEnabled) {
            StackExchange.using("snippets", function() {
            createEditor();
            });
            }
            else {
            createEditor();
            }
            });

            function createEditor() {
            StackExchange.prepareEditor({
            heartbeatType: 'answer',
            convertImagesToLinks: true,
            noModals: true,
            showLowRepImageUploadWarning: true,
            reputationToPostImages: 10,
            bindNavPrevention: true,
            postfix: "",
            imageUploader: {
            brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
            contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
            allowUrls: true
            },
            onDemand: true,
            discardSelector: ".discard-answer"
            ,immediatelyShowMarkdownHelp:true
            });


            }
            });














             

            draft saved


            draft discarded


















            StackExchange.ready(
            function () {
            StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53369901%2fusing-saml-with-spring-boot-behind-an-elb-redirects-to-http-instead-of-https%23new-answer', 'question_page');
            }
            );

            Post as a guest















            Required, but never shown

























            1 Answer
            1






            active

            oldest

            votes








            1 Answer
            1






            active

            oldest

            votes









            active

            oldest

            votes






            active

            oldest

            votes








            up vote
            0
            down vote













            When a SAML 2.0 IdP like Okta redirects back to you application the endpoint url is either based on the SAML 2.0 metadata you application expose or the configuration in the IdP.



            Furthermore, it is optional to add a Destination property in SAML 2.0 AuthnRequest:



            <samlp:AuthnRequest xmlns:samlp="urn:oasis:names:tc:SAML:2.0:protocol" Consent="urn:oasis:names:tc:SAML:2.0:consent:unspecified" 
            Destination="https://my.website.com" IssueInstant="2018-11-22T09:23:08.844Z" Version="2.0" ID="id-f8ee3ab1-6745-42d5-b00f-7845b97fe953">
            <Issuer xmlns="urn:oasis:names:tc:SAML:2.0:assertion"> ... </Issuer>
            ...
            </samlp:AuthnRequest>





            share|improve this answer

























              up vote
              0
              down vote













              When a SAML 2.0 IdP like Okta redirects back to you application the endpoint url is either based on the SAML 2.0 metadata you application expose or the configuration in the IdP.



              Furthermore, it is optional to add a Destination property in SAML 2.0 AuthnRequest:



              <samlp:AuthnRequest xmlns:samlp="urn:oasis:names:tc:SAML:2.0:protocol" Consent="urn:oasis:names:tc:SAML:2.0:consent:unspecified" 
              Destination="https://my.website.com" IssueInstant="2018-11-22T09:23:08.844Z" Version="2.0" ID="id-f8ee3ab1-6745-42d5-b00f-7845b97fe953">
              <Issuer xmlns="urn:oasis:names:tc:SAML:2.0:assertion"> ... </Issuer>
              ...
              </samlp:AuthnRequest>





              share|improve this answer























                up vote
                0
                down vote










                up vote
                0
                down vote









                When a SAML 2.0 IdP like Okta redirects back to you application the endpoint url is either based on the SAML 2.0 metadata you application expose or the configuration in the IdP.



                Furthermore, it is optional to add a Destination property in SAML 2.0 AuthnRequest:



                <samlp:AuthnRequest xmlns:samlp="urn:oasis:names:tc:SAML:2.0:protocol" Consent="urn:oasis:names:tc:SAML:2.0:consent:unspecified" 
                Destination="https://my.website.com" IssueInstant="2018-11-22T09:23:08.844Z" Version="2.0" ID="id-f8ee3ab1-6745-42d5-b00f-7845b97fe953">
                <Issuer xmlns="urn:oasis:names:tc:SAML:2.0:assertion"> ... </Issuer>
                ...
                </samlp:AuthnRequest>





                share|improve this answer












                When a SAML 2.0 IdP like Okta redirects back to you application the endpoint url is either based on the SAML 2.0 metadata you application expose or the configuration in the IdP.



                Furthermore, it is optional to add a Destination property in SAML 2.0 AuthnRequest:



                <samlp:AuthnRequest xmlns:samlp="urn:oasis:names:tc:SAML:2.0:protocol" Consent="urn:oasis:names:tc:SAML:2.0:consent:unspecified" 
                Destination="https://my.website.com" IssueInstant="2018-11-22T09:23:08.844Z" Version="2.0" ID="id-f8ee3ab1-6745-42d5-b00f-7845b97fe953">
                <Issuer xmlns="urn:oasis:names:tc:SAML:2.0:assertion"> ... </Issuer>
                ...
                </samlp:AuthnRequest>






                share|improve this answer












                share|improve this answer



                share|improve this answer










                answered Nov 22 at 10:00









                Anders Revsgaard

                7611




                7611






























                     

                    draft saved


                    draft discarded



















































                     


                    draft saved


                    draft discarded














                    StackExchange.ready(
                    function () {
                    StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53369901%2fusing-saml-with-spring-boot-behind-an-elb-redirects-to-http-instead-of-https%23new-answer', 'question_page');
                    }
                    );

                    Post as a guest















                    Required, but never shown





















































                    Required, but never shown














                    Required, but never shown












                    Required, but never shown







                    Required, but never shown

































                    Required, but never shown














                    Required, but never shown












                    Required, but never shown







                    Required, but never shown







                    Popular posts from this blog

                    Costa Masnaga

                    Fotorealismo

                    Sidney Franklin