Skip to content

Support runtime environment variables and safe Handlebars helpers #32

Description

@noahjalex

Today, credentials that need a transformation must be prepared and saved before running a request:

AUTH="Basic $(printf '%s' "$API_USERNAME:$API_PASSWORD" | base64)"
hit ephenv set AUTHORIZATION "$AUTH"
hit run users list

This adds a setup step and can leave stale credentials behind when the shell environment changes.

Could hit include process environment variables in the Handlebars context and provide a few safe built-in helpers?

{
  "headers": {
    "Authorization": "{{{basicAuth API_USERNAME API_PASSWORD}}}",
    "X-Api-Key": "{{{API_KEY}}}"
  }
}

Other useful helpers might include:

{{{base64 VALUE}}}
{{{urlEncode VALUE}}}

I think this should be limited to explicit helpers rather than allowing arbitrary shell execution. Helper output should also be unescaped so valid header characters are preserved.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions