Skip to content

Add warning message when email claim is missing from ID token#374

Merged
EthanHeilman merged 8 commits into
mainfrom
copilot/better-login-message-email-claim
Oct 17, 2025
Merged

Add warning message when email claim is missing from ID token#374
EthanHeilman merged 8 commits into
mainfrom
copilot/better-login-message-email-claim

Conversation

Copy link
Copy Markdown
Contributor

Copilot AI commented Oct 17, 2025

This was an experiment by @EthanHeilman to test copilot capabilities

Plan: Better message in login to tell the user what claims they have (email)

  • Explore repository structure and understand the issue
  • Identify the IdentityString function that needs to be modified
  • Build and test the current code
  • Modify IdentityString function to provide clearer messaging about missing email claim
  • Update test to reflect the new expected output when email is missing
  • Add test case for when email is present (already covered)
  • Run tests to verify changes work correctly
  • Add opkssh binary to .gitignore
  • Manually verify the output changes
  • Request code review
  • Address code review feedback
  • Update warning message with more detailed guidance
  • Refactor Mocks function to accept optional ExtraClaims
  • Fix linter issues (gofmt)
  • Apply fmt.Sprintf pattern consistently

Changes Made

Modified IdentityString function in commands/login.go:

  • Updated warning message to provide more helpful information:
    • Mentions that policies based on email will not work
    • Suggests checking client config (~/.opk/config.yml) for correct scopes
    • Directs users to the specific OpenID Provider configuration
  • Applied fmt.Sprintf pattern with multi-line strings to both if and else blocks for consistency

Refactored Mocks function in commands/login_test.go:

  • Now accepts optional extraClaims parameter (variadic)
  • Defaults to including email claim for backward compatibility
  • Allows tests to specify custom ExtraClaims including empty maps

Updated TestIdentityString in commands/login_test.go:

  • Simplified test for "without email claim" to use the refactored Mocks function
  • Removed duplicated mock setup code
  • Updated assertions to check for the new warning message text
  • Fixed gofmt formatting issues (trailing whitespace and comment alignment)

Output Examples:

With email claim:

Email, sub, issuer, audience: 
arthur.aardvark@example.com me https://accounts.example.com test_client_id

Without email claim (improved warning message):

WARNING: Email claim is missing from ID token. Policies based on email will not work.
Check if your client config (~/.opk/config.yml) has the correct scopes configured for this OpenID Provider.
Sub, issuer, audience:
me https://accounts.example.com test_client_id

All tests pass successfully and linter passes with 0 issues.

Original prompt

This section details on the original issue you should resolve

<issue_title>Better message in login to tell the user what claims they have (email)</issue_title>
<issue_description>"could a check be added to ensure that the email claim is present in the ID token? Currently, users are just not able to login and this log message:

Keys generated for identity
Sub, issuer, audience:
is not really indicative that something is wrong."

Requested in #38 (comment)</issue_description>

<agent_instructions>Do your best job</agent_instructions>

Comments on the Issue (you are @copilot in this section)

Fixes #103


💡 You can make Copilot smarter by setting up custom instructions, customizing its development environment and configuring Model Context Protocol (MCP) servers. Learn more Copilot coding agent tips in the docs.

Copilot AI and others added 3 commits October 17, 2025 03:24
Co-authored-by: EthanHeilman <274814+EthanHeilman@users.noreply.github.com>
Co-authored-by: EthanHeilman <274814+EthanHeilman@users.noreply.github.com>
…ve comment clarity

Co-authored-by: EthanHeilman <274814+EthanHeilman@users.noreply.github.com>
Copilot AI changed the title [WIP] Add validation for email claim in login process Add warning message when email claim is missing from ID token Oct 17, 2025
Copilot AI requested a review from EthanHeilman October 17, 2025 03:31
Comment thread commands/login.go Outdated
Comment thread commands/login_test.go Outdated
@EthanHeilman EthanHeilman added the enhancement New feature or request label Oct 17, 2025
@EthanHeilman
Copy link
Copy Markdown
Member

@copilot See my review and the breaking tests

Co-authored-by: EthanHeilman <274814+EthanHeilman@users.noreply.github.com>
@EthanHeilman
Copy link
Copy Markdown
Member

@copilot The code you wrote seems to have broken the linter. Fix the linter issue

Co-authored-by: EthanHeilman <274814+EthanHeilman@users.noreply.github.com>
Copy link
Copy Markdown
Contributor Author

Copilot AI commented Oct 17, 2025

@copilot The code you wrote seems to have broken the linter. Fix the linter issue

Fixed the linter issue in commit 4b8c4e1. The problem was trailing whitespace and misaligned comments in login_test.go. Ran gofmt to fix formatting - linter now passes with 0 issues.

@EthanHeilman EthanHeilman marked this pull request as ready for review October 17, 2025 16:22
@EthanHeilman EthanHeilman requested a review from Copilot October 17, 2025 16:23
Copy link
Copy Markdown
Contributor

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

This PR improves the user experience when the email claim is missing from the ID token during login by adding a clear warning message that explains the implications and provides actionable troubleshooting guidance.

Key changes:

  • Enhanced the warning message in IdentityString to explain that policies based on email won't work and direct users to check their client configuration
  • Refactored the Mocks test helper to accept optional extra claims for more flexible testing
  • Added comprehensive test coverage for both scenarios (with and without email claim)

Reviewed Changes

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

File Description
commands/login.go Updated warning message when email claim is missing to provide actionable guidance
commands/login_test.go Refactored Mocks function to support custom claims and added test case for missing email scenario

Tip: Customize your code reviews with copilot-instructions.md. Create the file or learn how to get started.

Comment thread commands/login.go Outdated
Comment thread commands/login_test.go
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Signed-off-by: Ethan Heilman <ethan.r.heilman@gmail.com>
Comment thread commands/login.go
Co-authored-by: EthanHeilman <274814+EthanHeilman@users.noreply.github.com>
Copilot AI requested a review from EthanHeilman October 17, 2025 16:34
Copy link
Copy Markdown
Member

@EthanHeilman EthanHeilman left a comment

Choose a reason for hiding this comment

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

LGTM

@EthanHeilman
Copy link
Copy Markdown
Member

This was an experiment to see how copilot would handle a very simple issue. On one hand, it did end up solving the issue and didn't require much supervision. On the other hand, I probably could have done it for the same time I spent going back and forth with copilot.

Overall, the benefit seems to be:

  • I don't need a 30 minute block of attention to get it done. Instead I can just, check in for 5 minutes between meetings and point it in the right direction.

  • I can review code I didn't write which generally results in better reviews because I don't bring the assumptions I used to write the code to the review.

  • I can work on a different branch on my local computer and not have to switch between the larger branch I am working on and this tiny feature branch. This is the biggest advantage in my mind.

@EthanHeilman EthanHeilman merged commit b95e845 into main Oct 17, 2025
27 of 31 checks passed
renovate Bot added a commit to sdwilsh/ansible-playbooks that referenced this pull request Jan 5, 2026
##### [\`v0.11.0\`](https://github.com/openpubkey/opkssh/releases/tag/v0.11.0)

##### 🚀 Features

- Add support for custom group claims [@mvanderlee](https://github.com/mvanderlee) ([#133](openpubkey/opkssh#133))
- feat: Flag to print SSH cert and private key rather than FS [@EthanHeilman](https://github.com/EthanHeilman) ([#437](openpubkey/opkssh#437))
- feat: Process extra arguments to the verify command [@justincmoy](https://github.com/justincmoy) ([#436](openpubkey/opkssh#436))
- Add warning message when email claim is missing from ID token @[copilot-swe-agent\[bot\]](https://github.com/apps/copilot-swe-agent) ([#374](openpubkey/opkssh#374))
- \[feat] Add new "inspect" subcommand [@stmcginnis](https://github.com/stmcginnis) ([#349](openpubkey/opkssh#349))
- Add CLI reference documentation [@stmcginnis](https://github.com/stmcginnis) ([#365](openpubkey/opkssh#365))
- Include signature JSON in `inspect` output [@stmcginnis](https://github.com/stmcginnis) ([#358](openpubkey/opkssh#358))
- - docs: Add Amazon Cognito as tested provider [@Foorack](https://github.com/Foorack) ([#414](openpubkey/opkssh#414))
- docs: Add documentation for opkssh and sssd integration [@vigneshmanick](https://github.com/vigneshmanick) ([#409](openpubkey/opkssh#409))
- Added SELinux support for sudo logging [@descensus](https://github.com/descensus) ([#376](openpubkey/opkssh#376))
- Update CLI documentation @[github-actions\[bot\]](https://github.com/apps/github-actions) ([#368](openpubkey/opkssh#368))

##### 🐛 Bug Fixes

- Fix race condition in ReadHome [@gcorrall](https://github.com/gcorrall) ([#391](openpubkey/opkssh#391))
- \[fix] Use lowercase for positional argument placeholders [@t38miwa](https://github.com/t38miwa) ([#361](openpubkey/opkssh#361))
- fix typo in commands/verify.go [@DevRockstarZ](https://github.com/DevRockstarZ) ([#336](openpubkey/opkssh#336))
- Doc: fix small errors in policy plugin doc [@PotatoesMaster](https://github.com/PotatoesMaster) ([#344](openpubkey/opkssh#344))
- Correct macOS name [@stmcginnis](https://github.com/stmcginnis) ([#341](openpubkey/opkssh#341))

##### 🧰 Maintenance

- chore: document upstream nix usage & remove nix flake [@datosh](https://github.com/datosh) ([#383](openpubkey/opkssh#383))
- Update CLI documentation @[github-actions\[bot\]](https://github.com/apps/github-actions) ([#438](openpubkey/opkssh#438))
- Stop hash pinning docker images [@EthanHeilman](https://github.com/EthanHeilman) ([#421](openpubkey/opkssh#421))
- \[fix] Fix ssh version integration test [@EthanHeilman](https://github.com/EthanHeilman) ([#362](openpubkey/opkssh#362))
- Fix integration tests failing due to pacman keys [@EthanHeilman](https://github.com/EthanHeilman) ([#432](openpubkey/opkssh#432))
- fix(deps): Update docker/setup-buildx-action action to v3.12.0 @[renovate\[bot\]](https://github.com/apps/renovate) ([#426](openpubkey/opkssh#426))
- fix(deps): Update zizmorcore/zizmor-action action to v0.3.0 @[renovate\[bot\]](https://github.com/apps/renovate) ([#413](openpubkey/opkssh#413))
- fix(deps): Update peter-evans/create-pull-request action to v8 @[renovate\[bot\]](https://github.com/apps/renovate) ([#418](openpubkey/opkssh#418))
- fix(deps): Update zizmorcore/zizmor-action action to v0.2.0 @[renovate\[bot\]](https://github.com/apps/renovate) ([#335](openpubkey/opkssh#335))
- fix(deps): Update peter-evans/create-pull-request action to v7.0.9 @[renovate\[bot\]](https://github.com/apps/renovate) ([#407](openpubkey/opkssh#407))
sdwilsh pushed a commit to sdwilsh/ansible-playbooks that referenced this pull request Jan 13, 2026
##### [\`v0.11.0\`](https://github.com/openpubkey/opkssh/releases/tag/v0.11.0)

##### 🚀 Features

- Add support for custom group claims [@mvanderlee](https://github.com/mvanderlee) ([#133](openpubkey/opkssh#133))
- feat: Flag to print SSH cert and private key rather than FS [@EthanHeilman](https://github.com/EthanHeilman) ([#437](openpubkey/opkssh#437))
- feat: Process extra arguments to the verify command [@justincmoy](https://github.com/justincmoy) ([#436](openpubkey/opkssh#436))
- Add warning message when email claim is missing from ID token @[copilot-swe-agent\[bot\]](https://github.com/apps/copilot-swe-agent) ([#374](openpubkey/opkssh#374))
- \[feat] Add new "inspect" subcommand [@stmcginnis](https://github.com/stmcginnis) ([#349](openpubkey/opkssh#349))
- Add CLI reference documentation [@stmcginnis](https://github.com/stmcginnis) ([#365](openpubkey/opkssh#365))
- Include signature JSON in `inspect` output [@stmcginnis](https://github.com/stmcginnis) ([#358](openpubkey/opkssh#358))
- - docs: Add Amazon Cognito as tested provider [@Foorack](https://github.com/Foorack) ([#414](openpubkey/opkssh#414))
- docs: Add documentation for opkssh and sssd integration [@vigneshmanick](https://github.com/vigneshmanick) ([#409](openpubkey/opkssh#409))
- Added SELinux support for sudo logging [@descensus](https://github.com/descensus) ([#376](openpubkey/opkssh#376))
- Update CLI documentation @[github-actions\[bot\]](https://github.com/apps/github-actions) ([#368](openpubkey/opkssh#368))

##### 🐛 Bug Fixes

- Fix race condition in ReadHome [@gcorrall](https://github.com/gcorrall) ([#391](openpubkey/opkssh#391))
- \[fix] Use lowercase for positional argument placeholders [@t38miwa](https://github.com/t38miwa) ([#361](openpubkey/opkssh#361))
- fix typo in commands/verify.go [@DevRockstarZ](https://github.com/DevRockstarZ) ([#336](openpubkey/opkssh#336))
- Doc: fix small errors in policy plugin doc [@PotatoesMaster](https://github.com/PotatoesMaster) ([#344](openpubkey/opkssh#344))
- Correct macOS name [@stmcginnis](https://github.com/stmcginnis) ([#341](openpubkey/opkssh#341))

##### 🧰 Maintenance

- chore: document upstream nix usage & remove nix flake [@datosh](https://github.com/datosh) ([#383](openpubkey/opkssh#383))
- Update CLI documentation @[github-actions\[bot\]](https://github.com/apps/github-actions) ([#438](openpubkey/opkssh#438))
- Stop hash pinning docker images [@EthanHeilman](https://github.com/EthanHeilman) ([#421](openpubkey/opkssh#421))
- \[fix] Fix ssh version integration test [@EthanHeilman](https://github.com/EthanHeilman) ([#362](openpubkey/opkssh#362))
- Fix integration tests failing due to pacman keys [@EthanHeilman](https://github.com/EthanHeilman) ([#432](openpubkey/opkssh#432))
- fix(deps): Update docker/setup-buildx-action action to v3.12.0 @[renovate\[bot\]](https://github.com/apps/renovate) ([#426](openpubkey/opkssh#426))
- fix(deps): Update zizmorcore/zizmor-action action to v0.3.0 @[renovate\[bot\]](https://github.com/apps/renovate) ([#413](openpubkey/opkssh#413))
- fix(deps): Update peter-evans/create-pull-request action to v8 @[renovate\[bot\]](https://github.com/apps/renovate) ([#418](openpubkey/opkssh#418))
- fix(deps): Update zizmorcore/zizmor-action action to v0.2.0 @[renovate\[bot\]](https://github.com/apps/renovate) ([#335](openpubkey/opkssh#335))
- fix(deps): Update peter-evans/create-pull-request action to v7.0.9 @[renovate\[bot\]](https://github.com/apps/renovate) ([#407](openpubkey/opkssh#407))
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.

Better message in login to tell the user what claims they have (email)

3 participants