skip to Main Content

I try to pass Docker env variable in my Spring boot application.yml like this:

  security:
    saml2:
      relyingparty:
        registration:
          my-saml:
            signing:
              credentials:
                - private-key-location: classpath:HARD_PATH_TO_KEY
                  certificate-location: classpath:HARD_PATH_TO_CERT
            identityprovider:
              verification.credentials:
                - certificate-location: classpath:HARD_PATH_TO_CERT
              entity-id: MY_ID
              singlesignon:
                url: {{saml.ip.singlesignon.url}}
                sign-request: true

But when I use env variable to

            - private-key-location: {{saml.ip.private.key}}
              certificate-location: {{saml.ip.certif.emp}}

and

          verification.credentials:
            - certificate-location: {{saml.ip.certif2.emp}}

I got this error:

java.lang.ClassCastException: java.util.LinkedHashMap cannot be cast to java.lang.String
    at java.util.LinkedHashMap.forEach(LinkedHashMap.java:684)
    at org.springframework.beans.factory.config.YamlProcessor.buildFlattenedMap(YamlProcessor.java:309)
    at org.springframework.beans.factory.config.YamlProcessor.lambda$buildFlattenedMap$1(YamlProcessor.java:325)
    at java.util.LinkedHashMap.forEach(LinkedHashMap.java:684)
    at org.springframework.beans.factory.config.YamlProcessor.buildFlattenedMap(YamlProcessor.java:309)
    at org.springframework.beans.factory.config.YamlProcessor.lambda$buildFlattenedMap$1(YamlProcessor.java:325)
    at java.util.Collections$SingletonMap.forEach(Collections.java:4910)

 

Any idea

2

Answers


  1. Try to remove the ‘-‘ at the beginning of lines

              private-key-location: {{saml.ip.private.key}}
              certificate-location: {{saml.ip.certif.emp}}
              ...
              certificate-location: {{saml.ip.certif2.emp}}
    
    Login or Signup to reply.
  2. If you want 2 separate Strings, or credentials is a Map, I think it should be:

                 credentials:
                     private-key-location: {{saml.ip.private.key}}
                     certificate-location: {{saml.ip.certif.emp}}
    

    If you want an array, I think it should be:

                 credentials:
                     - private-key-location: {{saml.ip.private.key}}
                     - certificate-location: {{saml.ip.certif.emp}}
    
    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search