Skip to content

Use Bearer auth for GitHub API#1154

Merged
fhunleth merged 1 commit intomainfrom
github-bearer-auth
Apr 12, 2026
Merged

Use Bearer auth for GitHub API#1154
fhunleth merged 1 commit intomainfrom
github-bearer-auth

Conversation

@fhunleth
Copy link
Copy Markdown
Member

This is a transparent change to users. Bearer auth doesn't need the
username, so it's ignored if users provide it.

@fhunleth fhunleth requested a review from a team as a code owner April 12, 2026 02:55
@fhunleth fhunleth requested a review from Copilot April 12, 2026 02:55
Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

Updates the GitHub API artifact resolver to use Bearer token authentication instead of Basic auth, and refreshes tests/docs accordingly so users only need to provide a token (and tag) for private GitHub releases.

Changes:

  • Switch Nerves.Artifact.Resolvers.GithubAPI Authorization header from Basic ... to Bearer ....
  • Update resolver tests to assert Bearer auth behavior.
  • Update documentation and guides to remove username from :github_api examples.

Reviewed changes

Copilot reviewed 5 out of 5 changed files in this pull request and generated 3 comments.

Show a summary per file
File Description
lib/nerves/artifact/resolvers/github_api.ex Changes Authorization header construction to Bearer auth and removes :username from the struct.
test/nerves/artifact/resolvers_github_api_test.exs Updates mocked header assertions from Basic to Bearer.
lib/nerves/artifact.ex Updates :github_api example usage in docs.
guides/advanced/systems.md Updates :github_api examples and wording to remove username.
guides/advanced/customizing-systems.md Updates the list of supported artifact site helpers to remove username for :github_api.
Comments suppressed due to low confidence (1)

lib/nerves/artifact/resolvers/github_api.ex:32

  • get/2 builds the options struct via struct(__MODULE__, opts), which raises KeyError on any unknown keys. Since this PR removes :username from the struct, existing callers that still pass username: ... (per previous docs) will now crash instead of being "ignored". To keep this change transparent, either keep :username in the struct (even if unused) or drop that key from opts before calling struct/2.
  def get({org_proj, opts}, dest_path) do
    opts =
      %{struct(__MODULE__, opts) | opts: opts, repo: org_proj}
      |> maybe_adjust_token()
      |> add_http_opts()

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

Copilot reviewed 6 out of 6 changed files in this pull request and generated 2 comments.

Comments suppressed due to low confidence (1)

lib/nerves/artifact/resolvers/github_api.ex:31

  • Removing :username from the resolver struct is a breaking change for existing configs. get/2 calls struct(__MODULE__, opts), which raises if opts contains unknown keys (e.g. username:). If the intent is to transparently ignore usernames, either keep username in the struct for backward compatibility or drop :username (and any other deprecated keys) from opts before calling struct/2 (e.g. in get/2 or in Artifact.expand_site/3).
  defstruct artifact_name: nil,
            base_url: @base_url,
            headers: [],
            public?: false,
            opts: [],
            repo: nil,
            tag: "",
            token: "",
            url: nil

  @impl Nerves.Artifact.Resolver
  def get({org_proj, opts}, dest_path) do
    opts =
      %{struct(__MODULE__, opts) | opts: opts, repo: org_proj}
      |> maybe_adjust_token()

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

This is a transparent change to users. Bearer auth doesn't need the
username, so it's ignored if users provide it.
@fhunleth fhunleth force-pushed the github-bearer-auth branch from fa05ea4 to 92e06e7 Compare April 12, 2026 13:18
@fhunleth fhunleth merged commit 92e06e7 into main Apr 12, 2026
7 checks passed
@fhunleth fhunleth deleted the github-bearer-auth branch April 12, 2026 13:24
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants