You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
✨ feat(oidc): Refactor OIDC client with golang.org/x/oauth2 and go-oidc (#6)
* ✨ feat(oidc): Refactor OIDC client with golang.org/x/oauth2 and go-oidc
This commit refactors the `internal/oidc` package to leverage the
`golang.org/x/oauth2` and `github.com/coreos/go-oidc` libraries.
The manual implementation of OAuth2/OIDC flows, including discovery,
token requests, and JSON parsing, has been replaced by robust,
industry-standard libraries.
Key changes include:
- Replaced manual OIDC discovery with `oidc.NewProvider`.
- Updated token retrieval (password and client credentials grants)
to use `oauth2.Config` and `clientcredentials.Config`.
- Refactored token refreshing to use `oauth2.TokenSource` mechanisms.
- Eliminated custom `TokenResponse` struct in favor of `oauth2.Token`.
- Enhanced test suite (`internal/oidc/client_test.go`) to reflect new
implementation and ensure compatibility with `go-oidc` expectations.
- Updated `cmd/authk/root.go` to use `token.Expiry` for refresh
timing, removing custom `ExpiresIn` logic.
This refactoring significantly improves security (due to strict
validation of OIDC specs by go-oidc), maintainability, and reduces
the amount of custom code.
* ✅ feat: Improve test coverage and fix linting issue
This commit addresses the recent drop in test coverage reported by Coveralls and fixes a linting issue.
Changes include:
- **internal/oidc/client_test.go:**
- Added error checking for `w.Write` call in mock server to resolve an `errcheck` linting error.
- Introduced `TestClient_GetToken_Password` to specifically test the Resource Owner Password Credentials flow, increasing coverage for `GetToken` function.
- **internal/env/env_test.go:**
- Added `TestFind_NotFound` to verify error handling when a file is not found.
- Added `TestFind_WithSeparator` to test `Find` function behavior with paths containing separators.
These changes collectively improve the overall test coverage and code quality.
* 🐛 feat(oidc): Support "basic" and "post" auth methods
The OIDC client now correctly handles "basic" and "post" as authentication method configurations, aligning with the `schema.cue` definition. Previously, only "client_secret_basic" and "client_secret_post" were recognized, leading to an "unsupported auth method" error when "basic" or "post" were used in the configuration.
This change ensures that the OIDC client initialization works as expected with the simplified auth method names defined in the schema, while maintaining backward compatibility with the more verbose OIDC standard names.
0 commit comments