Skip to content

Document env variable format #173

@tredmon

Description

@tredmon

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 #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.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions