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

Support a browser-based login flow for LDAP and Active Directory providers #1163

Merged
merged 29 commits into from
May 24, 2022

Conversation

cfryanr
Copy link
Member

@cfryanr cfryanr commented May 11, 2022

Implements the LDAP/AD web UI proposal from #1116.

Note that this PR changes how the pinniped get kubeconfig cli deals with ambiguous flows. Previously, if there was more than one flow advertised for an IDP, the cli would require users to use the flag --upstream-identity-provider-flow. Now it chooses a default flow based on the IDP type (by choosing the first flow type in the Supervisor's discovery response).

Here's a screenshot of the new LDAP/AD login page, which is hosted by Supervisor:

Screen Shot 2022-06-02 at 10 55 15 AM

When using the Pinniped CLI, a successful login takes the user to the regular form_post success page, just like the previously supported browser authcode flow for an OIDCIdentityProvider:

Screen Shot 2022-06-02 at 10 55 34 AM

Release note:

End users can optionally use a new browser-based login flow from `kubectl` with LDAPIdentityProviders and ActiveDirectoryIdentityProviders.
The new login UI web page is hosted by the Pinniped Supervisor.

margocrawf and others added 26 commits April 25, 2022 14:54
To keep this backwards compatible, this PR changes how
the cli deals with ambiguous flows. Previously, if there
was more than one flow advertised, the cli would require users
to set the flag --upstream-identity-provider-flow. Now it
chooses the first one in the list.

Signed-off-by: Margo Crawford <margaretc@vmware.com>
Also change state param to include IDP type
Also fix some test failures on the callback handler, register the
new login handler in manager.go and add a (half baked) integration test

Signed-off-by: Margo Crawford <margaretc@vmware.com>
The other handlers for GET and POST requests are not yet implemented in
this commit. The shared handler code in login_handler.go takes care of
things checking the method, checking the CSRF cookie, decoding the state
param, and adding security headers on behalf of both the GET and POST
handlers.

Some code has been extracted from callback_handler.go to be shared.
also add more unit tests

Signed-off-by: Margo Crawford <margaretc@vmware.com>
Signed-off-by: Margo Crawford <margaretc@vmware.com>
Signed-off-by: Margo Crawford <margaretc@vmware.com>
Signed-off-by: Margo Crawford <margaretc@vmware.com>
Signed-off-by: Margo Crawford <margaretc@vmware.com>
Also add autocomplete attribute and title element

Signed-off-by: Margo Crawford <margaretc@vmware.com>
Also extract some helpers from auth_handler.go so they can be shared
with the new handler.
Signed-off-by: Margo Crawford <margaretc@vmware.com>
Also use more specific test assertions where security headers are
expected. And run the unit tests for the login package in parallel.
Signed-off-by: Margo Crawford <margaretc@vmware.com>
Also:
- Add CSS to login page
- Refactor login page HTML and CSS into a new package
- New custom CSP headers for the login page, because the requirements
  are different from the form_post page
Also do some refactoring to share more common test setup code in
supervisor_login_test.go.
Also fix some comments that didn't fit onto one line in the yaml
examples, be consistent about putting a blank line above `---` yaml
separators, and some other small doc improvements.
@codecov
Copy link

codecov bot commented May 11, 2022

Codecov Report

Merging #1163 (438ab0a) into main (7388097) will decrease coverage by 0.42%.
The diff coverage is 73.96%.

@@            Coverage Diff             @@
##             main    #1163      +/-   ##
==========================================
- Coverage   79.73%   79.30%   -0.43%     
==========================================
  Files         136      141       +5     
  Lines       10055    10240     +185     
==========================================
+ Hits         8017     8121     +104     
- Misses       1767     1847      +80     
- Partials      271      272       +1     
Impacted Files Coverage Δ
internal/oidc/oidc.go 0.00% <0.00%> (ø)
internal/oidc/login/post_login_handler.go 90.90% <90.90%> (ø)
internal/oidc/login/login_handler.go 95.00% <95.00%> (ø)
internal/oidc/auth/auth_handler.go 99.32% <98.51%> (+1.96%) ⬆️
cmd/pinniped/cmd/kubeconfig.go 84.15% <100.00%> (-0.03%) ⬇️
cmd/pinniped/cmd/login_oidc.go 91.62% <100.00%> (ø)
internal/oidc/callback/callback_handler.go 100.00% <100.00%> (ø)
...nternal/oidc/idpdiscovery/idp_discovery_handler.go 86.04% <100.00%> (ø)
internal/oidc/login/get_login_handler.go 100.00% <100.00%> (ø)
internal/oidc/login/loginhtml/loginhtml.go 100.00% <100.00%> (ø)
... and 3 more

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 7388097...438ab0a. Read the comment docs.

Copy link
Contributor

@enj enj left a comment

Choose a reason for hiding this comment

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

I am still looking through some of the tests.

cmd/pinniped/cmd/kubeconfig.go Outdated Show resolved Hide resolved
internal/oidc/provider/manager/manager.go Outdated Show resolved Hide resolved
internal/oidc/oidc.go Outdated Show resolved Hide resolved
internal/oidc/login/get_login_handler.go Outdated Show resolved Hide resolved
internal/oidc/login/loginhtml/loginhtml.go Outdated Show resolved Hide resolved
internal/oidc/login/loginhtml/loginhtml.go Show resolved Hide resolved
internal/oidc/login/post_login_handler.go Show resolved Hide resolved
internal/oidc/auth/auth_handler.go Outdated Show resolved Hide resolved
Copy link
Contributor

@enj enj left a comment

Choose a reason for hiding this comment

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

The change to internal/oidc/provider/manager/manager.go looks incorrect?

@cfryanr cfryanr merged commit 03ccef0 into main May 24, 2022
@cfryanr cfryanr deleted the ldap-login-ui branch May 24, 2022 14:19
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants