Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Elixir: Plug Header Groups & Plug Name #17

Merged
merged 7 commits into from
Jul 7, 2023

Conversation

halostatue
Copy link
Member

  • Elixir: Plug Header Groups & Plug Name (d307900)

    • Add support for header groups in AppIdentity.Plug to better handle fallback headers. Kinetic’s original Elixir implementation always verified only the first value from a list of headers, like so:

       with [] <- Conn.get_req_header(conn, "header-1"),
            [] <- Conn.get_req_header(conn, "header-2"),
            [] <- Conn.get_req_header(conn, "header-3") do
        :error
      else
        [value | _] -> {:ok, value}
      end

      AppIdentity.Plug always processes all values of a header and puts the result in a map with the header name as the key, it meant that we would have had to check these results in turn. Instead, the header_groups option allows you to collect all related headers into one result key:

      plug AppIdentity.Plug, header_groups: %{
       "app" => ["header-1", "header-2", "header-3"]
      }, ...
    • Add support for alternate names so that AppIdentity.Plug can be specified multiple times in a pipeline and will store its data separately.

  • Spec: Extend security details for secret handling (8b7edd0)

    These changes do not affect any implementation, but adds some security recommendations for secret handling that were omitted from the initial released version of the specification.

    1. Generated secret values should be prefixed for improved leak detection by scanning tools, such as those deployed by GitHub.

      The reference implementations do not generate application objects except for the integrated test suites, and the secrets are always generated on each independent run.

    2. Secret values should be stored in memory-safe and leak-resistant mechanisms.

      The reference implementations already use closures to wrap the secret and custom inspection definitions to ensure that the secrets cannot be accidentally leaked.

@halostatue halostatue force-pushed the elixir--plug-header-groups branch 5 times, most recently from 8ae6f56 to d4912d9 Compare April 19, 2023 14:31
mikestok

This comment was marked as outdated.

mikestok

This comment was marked as outdated.

@halostatue

This comment was marked as outdated.

@halostatue halostatue enabled auto-merge (rebase) April 19, 2023 20:13
@halostatue halostatue self-assigned this Apr 19, 2023
@halostatue halostatue added the enhancement New feature or request label Apr 19, 2023
spec/README.md Outdated Show resolved Hide resolved
spec/README.md Outdated Show resolved Hide resolved
Copy link

@mikestok mikestok left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I would like to print out and review the docs as a separate task so that we can release this now.

I'm at a nitpicking phase where my main nits seems to be:

  • front loading sentences
  • simplifying sentences
    • removing subclauses by rewriting
    • removing much of the emphasis so that it doesn't become less important to the reader
    • for example "Should no proof headers be included, the request is considered invalid" ; "If there are no proof headers the request is invalid"
  • moving important stuff earlier

For technical writing I have to ditch the writing style I like and think more along the guidelines in https://www.plainlanguage.gov/guidelines/

elixir/Changelog.md Outdated Show resolved Hide resolved
Changelog.md Outdated Show resolved Hide resolved
elixir/lib/app_identity/plug.ex Outdated Show resolved Hide resolved
@halostatue
Copy link
Member Author

I would like to print out and review the docs as a separate task so that we can release this now.

I’m going to be busy with internal tasks today and we’re not yet ready to pull this into our projects because of other changes blocking this test release. Just remember to flag the release date to be changed from today when putting other comments in place so that we get that updated. I’d rather have the documentation fixed than not.

If you see particularly egregious text that needs fixing, please also check the Typescript and Ruby to see if the text is equally awful. We probably won’t fix it in this PR (I think that I’ve seen an issue we need to resolve in the Ruby code, but haven’t verified it to be sure), but I would like to have it flagged.

@halostatue halostatue force-pushed the elixir--plug-header-groups branch 3 times, most recently from 67dd8fa to 5e491cd Compare July 3, 2023 16:23
@halostatue halostatue force-pushed the elixir--plug-header-groups branch 6 times, most recently from 0c7fd4a to a61a97e Compare July 3, 2023 23:53
- Add support for header groups in `AppIdentity.Plug` to better handle
  fallback headers. Kinetic’s original Elixir implementation always
  verified only the _first_ value from a _list_ of headers, like so:

  ```elixir
  with [] <- Conn.get_req_header(conn, "header-1"),
       [] <- Conn.get_req_header(conn, "header-2"),
       [] <- Conn.get_req_header(conn, "header-3") do
    :error
  else
    [value | _] -> {:ok, value}
  end
  ```

  AppIdentity.Plug always processes all values of a header and puts the
  result in a map with the header name as the key, it meant that we
  would have had to check these results in turn. Instead, the
  `header_groups` option allows you to collect all _related_ headers
  into one result key:

  ```elixir
  plug AppIdentity.Plug, header_groups: %{
    "app" => ["header-1", "header-2", "header-3"]
  }, ...
  ```

- Add support for alternate names so that `AppIdentity.Plug` can be
  specified multiple times in a pipeline and will store its data
  separately.

Signed-off-by: Austin Ziegler <[email protected]>
These changes do not affect any implementation, but adds some security
recommendations for secret handling that were omitted from the initial
released version of the specification.

1. Generated secret values should be prefixed for improved leak
   detection by scanning tools, such as those deployed by GitHub.

   The reference implementations do not generate application objects
   *except* for the integrated test suites, and the secrets are always
   generated on each independent run.

2. Secret values should be stored in memory-safe and leak-resistant
   mechanisms.

   The reference implementations already use closures to wrap the secret
   and custom inspection definitions to ensure that the secrets cannot
   be accidentally leaked.

Signed-off-by: Austin Ziegler <[email protected]>
- Mark all 'head' matrix entries as `continue-on-error`
- Add Ruby 3.2 to the Ubuntu 22.04 test scenarios.

Signed-off-by: Austin Ziegler <[email protected]>
Kinetic Commerce is not *currently* working on implementations in Swift
or Kotlin.

Signed-off-by: Austin Ziegler <[email protected]>
Technical Change Notes
======================

- Add latest PNPM to the test matrix.
  - Also fix some issues with the lockfile.
- Set release date as this July 7, 2023.
- Rework some comments based on April documentation comments.
- Allow Poison v5.

Signed-off-by: Austin Ziegler <[email protected]>
Technical Change Notes
======================

Various CI errors that are proving to be hard to deal with; we will
deprecate those for this version. This forces a full version upgrade
for semver.

- Add an .npmrc to try to fix issues with PNPM resolution still

Signed-off-by: Austin Ziegler <[email protected]>
@halostatue halostatue merged commit 507d2e2 into main Jul 7, 2023
57 checks passed
@halostatue halostatue deleted the elixir--plug-header-groups branch July 7, 2023 14:31
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants