Get hands-on experience with 20+ free Google Cloud products and $300 in free credit for new customers.

Setting environment variables and how to access them

Not applicable

Hi guys.

I am trying to figure out the best way of controlling different configurations.

For instance I have a JWT Validation Policy that for obvious resens have different configurations depending if I am in production or preproduction. For now I have created multiple policies but I was wondering if there werent a better way?

I looked into

https://docs.apigee.com/api-platform/cache/creating-and-editing-environment-keyvalue-maps and I created a container and a new variable but when I trace my request I dont see this variable anywhere and certanily not inside the environment scope.

7101-screen-shot-2018-07-11-at-101218.png

I tried using the variable in the policy under Issuer.

7102-screen-shot-2018-07-11-at-101403.png

What am I doing wrong?

7103-screen-shot-2018-07-11-at-102802.png

Solved Solved
0 10 5,200
1 ACCEPTED SOLUTION

Are you reading the KVM values using a Key Value Map Operations policy in your proxy?

KVM's can be environment specific. But values stored in the KVM do not propagate to context/flow automatically.

You have to use Key Value Map Operations policy to read from the KVM into context variables:

<KeyValueMapOperations  name="KVM-JWTAttributes" mapIdentifier="Identity">
    <DisplayName>KVM-JWTAttributes</DisplayName>
    <Properties/>
    <ExclusiveCache>false</ExclusiveCache>
    <ExpiryTimeInSecs>360</ExpiryTimeInSecs>
    <Get assignTo="var_auth0_jwt_issuer" index="1">
        <Key>
            <Parameter>auth0_jwt_issuer</Parameter>
        </Key>
    </Get>
    <Scope>environment</Scope>
</KeyValueMapOperations>

This will set value of auth0_jwt_issuer key of kvm Identity to context/flow variable var_auth0_jwt_issuer

Please use this document and configure the policy according to your need.

You can use it at reference in generate JWT policy for Issuer.

<Issuer ref='var_auth0_jwt_issuer'/>

Now for every enviroment you can have a KVM with same name and key but with a different value and it can be evaluated at runtime.

For sensitive information please use encrypted KVM.

Hope this will help !

View solution in original post

10 REPLIES 10