question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Document env variable format

See original GitHub issue

Please do not report security vulnerabilities here. The Responsible Disclosure Program details the procedure for disclosing security issues.

Thank you in advance for helping us to improve this library! Your attention to detail here is greatly appreciated and will help us respond as quickly as possible. For general support or usage questions, use the Auth0 Community or Auth0 Support. Finally, to avoid duplicates, please search existing Issues before submitting one here.

By submitting an Issue to this repository, you agree to the terms within the Auth0 Code of Conduct.

Describe the problem you’d like to have solved

A clear and concise description of what the problem is. Ex. I’m always frustrated when […]

The documentation is sparse on the config.json file, but is completely lacking when it comes to the format of environment variables that override said file. Furthermore, the format is not intuitive.

For example, I would think the format of the variable AUTH0_EXCLUDED_RULES would either be a JSON array or comma-delimited list, but it seems to be neither.

$ AUTH0_DOMAIN=some-valid-domain.auth0.com AUTH0_CLIENT_ID=some-valid-client-id AUTH0_CLIENT_SECRET=some-valid-client-secret AUTH0_EXCLUDED_RULES='["my-rule-to-exclude-1","my-rule-to-exclude-2"]' a0deploy import -i config/dir
2019-10-11T20:12:41.006Z - info: Processing directory config
2019-10-11T20:12:41.010Z - info: Getting access token for some-valid-client-id/some-valid-domain.auth0.com
2019-10-11T20:12:41.055Z - error: Problem running command import
2019-10-11T20:12:41.055Z - error: Schema validation failed loading [
    {
        "keyword": "type",
        "dataPath": ".exclude.rules",
        "schemaPath": "#/properties/exclude/properties/rules/type",
        "params": {
            "type": "array"
        },
        "message": "should be array"
    }
]
$ AUTH0_DOMAIN=some-valid-domain.auth0.com AUTH0_CLIENT_ID=some-valid-client-id AUTH0_CLIENT_SECRET=some-valid-client-secret AUTH0_EXCLUDED_RULES='my-rule-to-exclude-1,my-rule-to-exclude-2' a0deploy import -i config/dir
2019-10-11T20:12:41.006Z - info: Processing directory config
2019-10-11T20:12:41.010Z - info: Getting access token for some-valid-client-id/some-valid-domain.auth0.com
2019-10-11T20:12:41.055Z - error: Problem running command import
2019-10-11T20:12:41.055Z - error: Schema validation failed loading [
    {
        "keyword": "type",
        "dataPath": ".exclude.rules",
        "schemaPath": "#/properties/exclude/properties/rules/type",
        "params": {
            "type": "array"
        },
        "message": "should be array"
    }
]

Describe the ideal solution

A clear and concise description of what you want to happen.

The ideal situation would be clear documentation for the format of the environment variables.

Alternatives and current work-arounds

A clear and concise description of any alternatives you’ve considered or any work-arounds that are currently in place.

I considered the workaround of creating a temporary config.json file with values from the environment variables. This fails due to https://github.com/auth0/auth0-deploy-cli/issues/172

set -e
jq -n --arg AUTH0_DOMAIN "$AUTH0_DOMAIN" --arg AUTH0_CLIENT_ID "$AUTH0_CLIENT_ID" --arg AUTH0_CLIENT_SECRET "$AUTH0_CLIENT_SECRET" --argjson AUTH0_EXCLUDED_RULES "$AUTH0_EXCLUDED_RULES" '{$AUTH0_DOMAIN,$AUTH0_CLIENT_ID,$AUTH0_CLIENT_SECRET,$AUTH0_EXCLUDED_RULES}' > /tmp/a0deploy-config.json
export FAILED=0
a0deploy import --no-env -c /tmp/a0deploy-config.json -i config/dir || export FAILED=1
rm /tmp/a0deploy-config.json
[[ $FAILED -eq 0 ]]

Current workaround that also works around the --no-env issue:

set -e
printf -v CONFIG_VAR_AUTH0_DOMAIN %s "${CONFIG_VAR_PREFIX}AUTH0_DOMAIN"
printf -v CONFIG_VAR_AUTH0_CLIENT_ID %s "${CONFIG_VAR_PREFIX}AUTH0_CLIENT_ID"
printf -v CONFIG_VAR_AUTH0_CLIENT_SECRET %s "${CONFIG_VAR_PREFIX}AUTH0_CLIENT_SECRET"
printf -v CONFIG_VAR_AUTH0_ALLOW_DELETE %s "${CONFIG_VAR_PREFIX}AUTH0_ALLOW_DELETE"
printf -v CONFIG_VAR_AUTH0_KEYWORD_REPLACE_MAPPINGS %s "${CONFIG_VAR_PREFIX}AUTH0_KEYWORD_REPLACE_MAPPINGS"
printf -v CONFIG_VAR_INCLUDED_PROPS %s "${CONFIG_VAR_PREFIX}INCLUDED_PROPS"
printf -v CONFIG_VAR_EXCLUDED_PROPS %s "${CONFIG_VAR_PREFIX}EXCLUDED_PROPS"
printf -v CONFIG_VAR_AUTH0_EXCLUDED_RULES %s "${CONFIG_VAR_PREFIX}AUTH0_EXCLUDED_RULES"
printf -v CONFIG_VAR_AUTH0_EXCLUDED_CLIENTS %s "${CONFIG_VAR_PREFIX}AUTH0_EXCLUDED_CLIENTS"
printf -v CONFIG_VAR_AUTH0_EXCLUDED_RESOURCE_SERVERS %s "${CONFIG_VAR_PREFIX}AUTH0_EXCLUDED_RESOURCE_SERVERS"
jq -ne \
    --arg AUTH0_DOMAIN "${!CONFIG_VAR_AUTH0_DOMAIN}" \
    --arg AUTH0_CLIENT_ID "${!CONFIG_VAR_AUTH0_CLIENT_ID}" \
    --arg AUTH0_CLIENT_SECRET "${!CONFIG_VAR_AUTH0_CLIENT_SECRET}" \
    --arg AUTH0_ALLOW_DELETE "${!CONFIG_VAR_AUTH0_ALLOW_DELETE}" \
    --argjson AUTH0_KEYWORD_REPLACE_MAPPINGS "${!CONFIG_VAR_AUTH0_KEYWORD_REPLACE_MAPPINGS}" \
    --argjson INCLUDED_PROPS "${!CONFIG_VAR_INCLUDED_PROPS}" \
    --argjson EXCLUDED_PROPS "${!CONFIG_VAR_EXCLUDED_PROPS}" \
    --argjson AUTH0_EXCLUDED_RULES "${!CONFIG_VAR_AUTH0_EXCLUDED_RULES}" \
    --argjson AUTH0_EXCLUDED_CLIENTS "${!CONFIG_VAR_AUTH0_EXCLUDED_CLIENTS}" \
    --argjson AUTH0_EXCLUDED_RESOURCE_SERVERS "${!CONFIG_VAR_AUTH0_EXCLUDED_RESOURCE_SERVERS}" \
    '{$AUTH0_DOMAIN,$AUTH0_CLIENT_ID,$AUTH0_CLIENT_SECRET,$AUTH0_ALLOW_DELETE,$AUTH0_KEYWORD_REPLACE_MAPPINGS,$INCLUDED_PROPS,$EXCLUDED_PROPS,$AUTH0_EXCLUDED_RULES,$AUTH0_EXCLUDED_CLIENTS,$AUTH0_EXCLUDED_RESOURCE_SERVERS}' \
    >/tmp/a0deploy-config.json
export FAILED=0
a0deploy import -i config -c /tmp/a0deploy-config.json || export FAILED=1
rm /tmp/a0deploy-config.json
[[ $FAILED -eq 0 ]]

Additional context

Add any other context or screenshots about the feature request here.

Issue Analytics

  • State:closed
  • Created 4 years ago
  • Comments:10 (3 by maintainers)

github_iconTop GitHub Comments

2reactions
dan-jackson-githubcommented, Mar 2, 2021

@mendhak @mikestopcontinues if I have understood your problem correctly, it is the same one I think I have just solved.

If you want to save an array value via an environment variable then use the ## notation to denote your variable and set the variable value like this:

[“http://domain1”,“http://domain2”]. Double quotes surrounding each array element, but no double quotes surrounding the entire array. Also make sure there are no spaces between array elements, this threw an error for me.

In my specific example I was setting the web_origins arrary in my client.json. It look like this:

an extract of my json looked like this:

“app_type”: “spa”, “grant_types”: [ “authorization_code”, “implicit”, “refresh_token” ], “web_origins”: ##WEB_CLIENT_CONNECTION_WEB_ORIGINS##, “custom_login_page_on”: true

We use Azure Devops so we just set the environment variable from a variable in an associated group. Hope that helps.

0reactions
wouterSeyencommented, Nov 4, 2022

@willvedd, thank you for the fast reply. I’ve created https://github.com/auth0/auth0-deploy-cli/issues/687 for this issue.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Dotenv File Format — Dotenvy v0.7.0
.env files (a.k.a. "dotenv") store key-value pairs in a format descended from simple bash files that exported environment variables.
Read more >
An Introduction to Environment Variables and How to Use ...
Environment variables are an important element of a Developer's ... Environment variables in .env are formatted as name=value , lines ...
Read more >
Declare default environment variables in file
Compose supports declaring environment variables in an environment file. ... For braced expressions, the following formats are supported:.
Read more >
Environment Variables: What They Are and How To Use ...
The usual format for storing environment variables in a .env file is: Key1=Value1. You need to strictly stick to this format for your...
Read more >
environment File
The /etc/environment file contains variables specifying the basic environment for all processes. When a new process begins, the exec subroutine makes an array ......
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found