Commit Graph

3706 Commits

Author SHA1 Message Date
Benjamin A. Petersen
a4447fa606 Add .Status to JWTAuthenticator with Conditions,Phase
- "Ready" condition & supporting conditions
- Legacy "Phase" for convenience
- Refactor newCachedJWTAuthenticator() func
  to improve ability to provide additional conditions
- Update JWTAuthenticator.Status type
- Update RBAC for SA to get/watch/update JWTAuthenticator.Status
- Update logger to plog, add tests for logs & statuses
- update Sync() to reduce enqueue when error is config/user managed, perhaps remove validateJWKSResponse()
2024-02-27 15:45:32 -08:00
Ryan Richard
f18d7310a8 Merge pull request #1875 from vmware-tanzu/pinny/bump-deps
Bump dependencies (adds gotoolchain to go.mod) and fix CodeQL and unit test races
2024-02-27 15:43:32 -08:00
Ryan Richard
28251f8b92 Update some comments in go.mod 2024-02-27 14:54:26 -08:00
Ryan Richard
50b54580de Fix races in login_test.go units tests 2024-02-27 14:54:05 -08:00
Ryan Richard
d88883328a Update codeql workflow actions to latest versions and add setup-go
See deprecation of v2 message in README.md at
https://github.com/github/codeql-action

Added setup-go because codeql code scanning stopped working and gave
this error message:
The go.mod file requires version v1.21.3 of Go, but version v1.20.14 is installed. Consider adding an actions/setup-go step to your workflow.
2024-02-27 12:26:32 -08:00
Pinny
ca6687d428 Bump dependencies 2024-02-27 14:03:11 +00:00
Ryan Richard
848d83c496 Merge pull request #1874 from vmware-tanzu/cli_checks_if_stderr_is_tty
"login oidc" CLI command sometimes skips printing auth URL for non-ttys
2024-02-26 14:56:24 -08:00
Ryan Richard
5bd73fc10d "login oidc" CLI command sometimes skips printing auth URL for non-ttys 2024-02-23 12:23:07 -08:00
Ryan Richard
40e548ebf0 Merge pull request #1873 from vmware-tanzu/1864_followup
CLI deciding if token exchange needed should not look at ID token expiry
2024-02-23 12:17:54 -08:00
Ryan Richard
64b0e69430 Update configure-concierge-jwt.md doc with clarifications 2024-02-23 08:37:43 -08:00
Ryan Richard
daec673b81 Add hack/prepare-jwtauthenticator-on-kind.sh 2024-02-23 08:37:43 -08:00
Ryan Richard
01d6bdb497 CLI deciding if token exchange needed should not look at ID token expiry
This fixes a small mistake in PR #1864. When the "pinniped login oidc"
CLI command is deciding if the RFC8693 token exchange is needed, it
should not look at the expiry of the ID token. This mistake would cause
the RFC8693 token exchange to happen when the OIDC provider is not
a Pinniped Supervisor, which would fail because most other providers
do not support that type of token exchange.

It does not matter if the current ID token is close to expiring when
deciding if the RFC8693 token exchange is needed, because the token
exchange is going to yield a new ID token anyway. It does matter if the
current ID token is close to expiring if the CLI decides that it is
not going to perform the token exchange, and this commit does not change
that logic.
2024-02-23 08:37:01 -08:00
Ryan Richard
216fce70aa Merge pull request #1872 from vmware-tanzu/pinny/bump-deps
Bump dependencies
2024-02-23 06:51:43 -08:00
Pinny
5939ce8cc6 Bump dependencies 2024-02-23 14:00:47 +00:00
Ryan Richard
9471ed2d09 Merge pull request #1871 from vmware-tanzu/always_search_groups
Don't skip upstream group memberships when groups scope is not granted
2024-02-22 08:11:08 -08:00
Ryan Richard
0d31e955ae Don't skip upstream group memberships when groups scope is not granted
Background: For dynamic clients, the groups scope is not always allowed
and/or requested by the client, so it will not always be granted by the
Supervisor for an authorization request.

Previously, when the groups scope was not granted, we would skip
searching for upstream groups in some scenarios.

This commit changes the behavior of authorization flows so that even
when the groups scope is not granted we still search for the upstream
group memberships as configured, and we pass the upstream group
memberships into any configured identity transformations. The identity
transformations could potentially reject the user's authentication based
on their upstream group membership.

When the groups scope is not granted, we don't include the groups in
the final Supervisor-issued ID token. This behavior is not changed.
2024-02-21 13:12:18 -08:00
Ryan Richard
5697bb2915 Merge pull request #1870 from vmware-tanzu/pinny/bump-deps
Bump dependencies
2024-02-21 08:07:37 -08:00
Pinny
ca7b27de3f Bump dependencies 2024-02-21 14:02:55 +00:00
Ryan Richard
867468ee66 Merge pull request #1867 from vmware-tanzu/refactor_supervisor_authenticators
Refactor Supervisor to make interface for upstream IDPs, to better separate upstream and downstream concerns
2024-02-20 22:11:52 -08:00
Ryan Richard
4b4a4ad592 Rename a func and collapse applying id transforms into creating session 2024-02-20 14:47:28 -08:00
Ryan Richard
b341e52214 Refactor to move invocation of identity transforms out of IDP interfaces
Each endpoint handler is now responsible for applying the identity
transformations and creating most of the session data, rather than each
implementation of the upstream IDP interface. This shares code better,
and reduces the responsibilities of the implementations of the IDP
interface by letting them focus more on the upstream stuff.

Also refactor the parameters and return types of the IDP interfaces to
make them more clear, and because they can be more focused on upstream
identities (pre-identity transformation). This clarifies the
responsibilities of the implementations of the IDP interface.
2024-02-20 10:45:54 -08:00
Ryan Richard
1e8e7b948e Refactor token endpoint to add interface for IDP upstream refresh 2024-02-20 09:26:34 -08:00
Ryan Richard
1bc13e94f7 Refactor to extract interface for upstream IDP interactions
Create an interface to abstract the upstream IDP from the
authorize, IDP discovery, callback, choose IDP, and login
endpoints. This commit does not refactor the token endpoint,
which will be refactored in a similar way in the next commit.
2024-02-20 09:26:34 -08:00
Ryan Richard
9db87132b1 More refactoring of auth handler and related refactor of upstreamldap
- continued refactoring the auth handler to share more code between
  the two supported browserless flows: OIDC and LDAP/AD
- the upstreamldap package should not know about the concept of
  OIDC granted scopes, so refactored it to be a skipGroups bool
2024-02-20 09:26:34 -08:00
Ryan Richard
9992855cb8 Refactor error handling in authorize endpoint (changes some responses)
- Simplify the error handling in the authorize endpoint by making the
  private helper functions return fosite-style errors, and having
  one place that writes those errors to the response.
- Some types of errors were previously returned as regular http-style
  errors. Those have all been converted to be returned as oauth-style
  errors (which can be redirects to the client), except for http method
  not found errors. This is a change in behavior from the client's point
  of view, but only when those unexpected errors happen. These types of
  errors are more consistent with RFC6749 section 4.1.2.1.
- Avoids using the httperr package for error handling.
- Create a struct for the handler as a first step toward making smaller
  functions with fewer parameters.
2024-02-20 09:26:34 -08:00
Ryan Richard
23dce42a94 Merge pull request #1869 from vmware-tanzu/pinny/bump-deps
Bump dependencies
2024-02-20 09:25:16 -08:00
Pinny
edf92303ae Bump dependencies 2024-02-20 15:57:22 +00:00
Ryan Richard
719cd75f64 Merge pull request #1866 from vmware-tanzu/upgrade_fosite_feb_2024
Upgrade fosite to latest version
2024-02-13 11:25:24 -08:00
Ryan Richard
ceb9973657 Correct doc which explained bug that has since been fixed. 2024-02-13 10:16:41 -08:00
Ryan Richard
cf82cf996e Adjust tests and comments for upgrade to latest version of fosite 2024-02-13 10:16:41 -08:00
Pinny
5c702738cf Bump dependencies 2024-02-13 16:44:20 +00:00
Ryan Richard
485b2271f0 Merge pull request #1864 from vmware-tanzu/cli_use_cached_access_token
login oidc cmd checks access token expiry before doing token exchange
2024-02-09 14:21:05 -08:00
Ryan Richard
dce9409ccc login oidc cmd checks access token expiry before doing token exchange
In the RFC8693 token exchange, the CLI sends your access token and
receives in exchange a new cluster-scoped ID token.

Fix a bug in the CLI. Whenever the "pinniped login oidc" command was
planning to perform the RFC8693 token exchange, it failed to check if
the cached access token was still valid before performing the exchange,
which sends the access token. It instead checked if the cached ID token
was still valid, but that it not relevant in this situation because the
ID token is not going to be used for anything (instead the new ID token
returned by the RFC8693 token exchange will be used for auth).

This bug doesn't actually matter today, because the Supervisor-issued
access and ID tokens always both have the same 2-minute lifetimes.
However, future enhancements may cause them to have different lifetimes
in certain circumstances. Fixing this CLI bug now to prepare for those
potential future enhancements.
2024-02-09 13:33:30 -08:00
Ryan Richard
d5ce48bd4b Convert double-quoted strings to raw strings in login_test.go 2024-02-09 08:38:51 -08:00
Ryan Richard
492dfa84d8 Merge pull request #1862 from vmware-tanzu/pinny/bump-deps
Bump dependencies
2024-02-09 08:20:58 -08:00
Pinny
e4fddc3596 Bump dependencies 2024-02-09 14:02:39 +00:00
Ryan Richard
ad9d9ce1a5 Merge pull request #1863 from vmware-tanzu/revert_support_for_new_goboring
Upgrade to Go 1.22 and revert support for new goboring
2024-02-08 15:05:38 -08:00
Ryan Richard
904a60f04a Fix ptls_test.go for Go 1.22 2024-02-08 14:13:09 -08:00
Ryan Richard
bf3b4bfca7 Rerun codegen after upgrading CI controller-gen from v0.13.0 to v0.14.0 2024-02-08 13:27:02 -08:00
Ryan Richard
560ee45b50 Fix plog_test.go for Go 1.22 2024-02-08 11:53:59 -08:00
Ryan Richard
d2794114f4 Revert support TLS 1.3 in FIPS mode because Go reverted goboring upgrade
Goboring only allows TLS 1.2.

The next goboring will allow both TLS 1.2 and TLS 1.3. We got a preview
of this when the Go team upgraded goboring in Go 1.21.6, but then
downgraded it again in the next Go releases.

When the Go team eventually upgrades goboring again, then we can
revert this commit to bring back TLS 1.3 support in FIPS mode.
2024-02-08 10:43:52 -08:00
Ryan Richard
e303a45dd1 Test util AssertTLS supports both old and new goboring
- Current goboring only allows TLS 1.2.
- The next goboring will allow TLS 1.2 and TLS 1.3. We got a preview
  of this when the Go team upgraded goboring in Go 1.21.6, but then
  downgraded it again in the next Go releases.
2024-02-08 09:39:01 -08:00
Pinny
c47bc74ad0 Bump dependencies 2024-02-07 20:09:08 +00:00
Ryan Richard
a728822993 Merge pull request #1861 from vmware-tanzu/dependabot/go_modules/hack/update-go-mod/golang.org/x/mod-0.15.0
Bump golang.org/x/mod from 0.14.0 to 0.15.0 in /hack/update-go-mod
2024-02-07 11:04:16 -08:00
dependabot[bot]
5cd4d47f9e Bump golang.org/x/mod from 0.14.0 to 0.15.0 in /hack/update-go-mod
Bumps [golang.org/x/mod](https://github.com/golang/mod) from 0.14.0 to 0.15.0.
- [Commits](https://github.com/golang/mod/compare/v0.14.0...v0.15.0)

---
updated-dependencies:
- dependency-name: golang.org/x/mod
  dependency-type: direct:production
  update-type: version-update:semver-minor
...

Signed-off-by: dependabot[bot] <support@github.com>
2024-02-07 02:01:12 +00:00
Ryan Richard
2832e7c45e Merge pull request #1858 from vmware-tanzu/pinny/bump-deps
Bump dependencies
2024-02-06 08:48:32 -08:00
Pinny
04bb45947d Bump dependencies 2024-02-06 14:01:03 +00:00
Ryan Richard
f2c9b67854 Merge pull request #1856 from vmware-tanzu/pinny/bump-deps
Bump dependencies
2024-02-02 10:03:18 -08:00
Pinny
e05ae08b77 Bump dependencies 2024-02-02 17:01:56 +00:00
Ryan Richard
1ab1fd4c50 Merge pull request #1855 from vmware-tanzu/pinny/bump-deps
Bump dependencies
2024-02-01 10:06:48 -08:00