-
Notifications
You must be signed in to change notification settings - Fork 827
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
[WIP] Migrate to Spring Security Core SAML #2793
Closed
Closed
Conversation
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Co-authored-by: Peter Chen <peter-h.chen@broadcom.com> Co-authored-by: Bruce Ricard <bruce.ricard@broadcom.com> Co-authored-by: Danny Faught <danny.faught@broadcom.com>
* Instead of calling fail(). We have a suspicion that there is a bug in the way the tests are running (most of them are somehow not running with "./gradlew test" and we have a theory that a combination of mixing junit4 imports and the junit5 fail() might be contributing. * I was careful to use @ignore for tests importing the junit4 @test, and @disabled for tests using the junit5 @test. * These annotations were added, with the idea that you can search for '@ignore("SAML' and '@disabled("SAML' to find the tests that need attention before we finish the SAML library conversion. @ignore("SAML test fails") @ignore("SAML test doesn't compile") @ignore("SAML test setup doesn't compile") @disabled("SAML test fails") @disabled("SAML test doesn't compile") * A few tests are set to ignore because they're failing for the right reasons, but more work is needed to finish that and get back to green. The goal is to start tracking these annotations instead of failing tests, so we can stay green. * Tests now running: server module: 3,435 (in IntelliJ) (98 total ignored) uaa module: 67 (command line run of "./gradlew test" for all tests - still needs troubleshooting) Co-authored-by: Danny Faught <danny.faught@broadcom.com>
Co-authored-by: Hongchol Sinn <hongchol.sinn@broadcom.com>
* Removed commented-out references to the outdated SAML extension library
- Adds back endpoint and incorporates forwarding for new pattern saml2 endpoints, Still has some wip elements WithHttpsNotRequired > samlMetadataReturnsOk still red RelyingPartyRegistration is hardcoded in xml, /saml/metadata/ with trailing slash not working missing parity with develop [#186986697] Co-authored-by: Peter Chen <peter-h.chen@broadcom.com>
…NotRequired -> samlMetadataReturnsOk is green - fixed one test but still WithHttpsRequired > samlMetadataReturnsOk is red after fixing this test - HealthzShouldNotBeProtectedMockMvcTests > WithHttpsRequired > samlMetadataRedirects() FAILED java.lang.AssertionError: Range for response status value 200 expected:<REDIRECTION> but was:<SUCCESSFUL> [#186986697]
We have created an issue in Pivotal Tracker to manage this: https://www.pivotaltracker.com/story/show/187279738 The labels on this github issue will be updated when the story is started. |
peterhaochen47
force-pushed
the
new-saml-lib-186822654
branch
4 times, most recently
from
March 25, 2024 21:53
37e2612
to
bdf8c16
Compare
Co-authored-by: Peter Chen <peter-h.chen@broadcom.com> Co-authored-by: Bruce Ricard <bruce.ricard@broadcom.com> Co-authored-by: Danny Faught <danny.faught@broadcom.com>
* Instead of calling fail(). We have a suspicion that there is a bug in the way the tests are running (most of them are somehow not running with "./gradlew test" and we have a theory that a combination of mixing junit4 imports and the junit5 fail() might be contributing. * I was careful to use @ignore for tests importing the junit4 @test, and @disabled for tests using the junit5 @test. * These annotations were added, with the idea that you can search for '@ignore("SAML' and '@disabled("SAML' to find the tests that need attention before we finish the SAML library conversion. @ignore("SAML test fails") @ignore("SAML test doesn't compile") @ignore("SAML test setup doesn't compile") @disabled("SAML test fails") @disabled("SAML test doesn't compile") * A few tests are set to ignore because they're failing for the right reasons, but more work is needed to finish that and get back to green. The goal is to start tracking these annotations instead of failing tests, so we can stay green. * Tests now running: server module: 3,435 (in IntelliJ) (98 total ignored) uaa module: 67 (command line run of "./gradlew test" for all tests - still needs troubleshooting) Co-authored-by: Danny Faught <danny.faught@broadcom.com>
Co-authored-by: Hongchol Sinn <hongchol.sinn@broadcom.com>
* Removed commented-out references to the outdated SAML extension library Co-authored-by: Peter Chen <peter-h.chen@broadcom.com>
- Adds back endpoint and incorporates forwarding for new pattern saml2 endpoints, Still has some wip elements WithHttpsNotRequired > samlMetadataReturnsOk still red RelyingPartyRegistration is hardcoded in xml, /saml/metadata/ with trailing slash not working missing parity with develop [#186986697] Co-authored-by: Peter Chen <peter-h.chen@broadcom.com>
…NotRequired -> samlMetadataReturnsOk is green - fixed one test but still WithHttpsRequired > samlMetadataReturnsOk is red after fixing this test - HealthzShouldNotBeProtectedMockMvcTests > WithHttpsRequired > samlMetadataRedirects() FAILED java.lang.AssertionError: Range for response status value 200 expected:<REDIRECTION> but was:<SUCCESSFUL> [#186986697] Co-authored-by: Peter Chen <peter-h.chen@broadcom.com>
- With the new SAML lib, SAML SP metadata generation relies on a relyingPartyRegistration, which requires a valid SAML IDP metadata. In the context of UAA external SAML IDP login, UAA does not know what the SAML IDP metadata is, until the operator adds it via the /identity-providers endpoint. Also, some SAML IDPs might require you to supply the SAML SP metadata first before you can obtain the SAML IDP metadata. See relevant issue: spring-projects/spring-security#11369 - Previously, to solve this problem, the SAML SP metadata generation relies on relyingPartyRegistration values in saml-providers.xml, which hardcodes a SAML IDP metadata URL (point to some example Okta SAML instance); this means that UAA's SP metadata generation relies on the example Okta SAML instance to be running. - This commit, instead, supplies a hardcoded dummy SAML IDP metadata here to unblock the SAML SP metadata generation, at the advice of Spring Security team, so that UAA's functioning does not rely on some external running Okta instance. - code reference: https://github.com/spring-projects/spring-security-samples/blob/1b28351693d60f01a511cbcc18b64590452a3851/servlet/java-configuration/saml2/login/src/main/java/example/SecurityConfiguration.java#L62 [#186986697] Co-authored-by: Peter Chen <peter-h.chen@broadcom.com>
* Has to be commented out of the erb file even when the test method used @disabled. Co-authored-by: Peter Chen <peter-h.chen@broadcom.com>
- A continuation of 65d1f0f - This is a test recently added to develop branch, so ignoring this here because the SAML feature is still being built. [#186986697] Co-authored-by: Peter Chen <peter-h.chen@broadcom.com>
- to reflect the fact that this IDP metadata just needs to exist in its bare minimal form, where the specific fields in it do not affect the SP metadata generation [#186986697] Co-authored-by: Peter Chen <peter-h.chen@broadcom.com>
peterhaochen47
force-pushed
the
new-saml-lib-186822654
branch
from
March 26, 2024 17:23
6996403
to
cbe6b06
Compare
- previously some tests error with: ``` net.shibboleth.utilities.java.support.xml.XMLParserException: Unable to parse inputstream, it contained invalid XML ``` - this issue is fixed once we switch to loading the idp saml metadata via a file (instead of an InputStream) [186822654] Co-authored-by: Danny Faught <danny.faught@broadcom.com>
Co-authored-by: Danny Faught <danny.faught@broadcom.com>
peterhaochen47
force-pushed
the
new-saml-lib-186822654
branch
from
March 26, 2024 23:05
cbe6b06
to
29a843f
Compare
* We're reprioritizing the test to get this test to pass. Co-authored-by: Bruce Ricard <bruce.ricard@broadcom.com>
swalchemist
force-pushed
the
new-saml-lib-186822654
branch
from
April 16, 2024 21:00
4f0ebd2
to
8759b56
Compare
…pulated in SPSSODescriptor - Building out EntityDescriptor in the RelyingPartyRegistration which contains the SPSSODescriptor picked up by the resolve method [#186986697] Co-authored-by: Duane May <duane.may@broadcom.com>
- Need to fix credential type being empty Caused by: java.lang.IllegalArgumentException: credentials types cannot be empty ....(SamlRelyingPartyRegistrationRepository.java:84) [#186986697] Co-authored-by: Duane May <duane.may@broadcom.com>
- Signature is not positioned correctly. It should be a child of EntityDescriptor, but the singingX509Credential.signing call positions it in SPSODescriptor [#186986697] Co-authored-by: Duane May <duane.may@broadcom.com>
…RequestsSigned - correctly reads off UAA configs to populate these fields, instead of using hardcoded values - refactor to directly reading `login.saml.NameID` config (a more modern approach) instead of constructing a bean in xml (a more legacy approach) - side note: update the UAA config used in mock mvc tests (/uaa/src/test/resources/integration_test_properties.yml) to use a non-default option of `login.saml.nameID` so that we can test that the correct value is being piped through Co-authored-by: Peter Chen <peter-h.chen@broadcom.com>
- there are many commented out codes from prior wip commits (which at this point, I decided, are too hard to fix or tidy up). Hence, in this commit, clean them up [186822654]
- the SAML SP metadata is still WIP, so this IT will fail. Ignoring it for now so that "CI" is green along with all other SAML tests currently failing / non-functional due to the WIP state of the SAML feature. - see defails of this approach in 73520d9 [186822654]
Use RestController, Slf4j, Getter Use textblocks
Use assertThat Use textblocks
[#186986697] Co-authored-by: Peter Chen <peter-h.chen@broadcom.com>
peterhaochen47
force-pushed
the
new-saml-lib-186822654
branch
from
April 23, 2024 21:08
3f817d9
to
84e2189
Compare
- also: refactor the UAA config used in mock mvc tests (/uaa/src/test/resources/integration_test_properties.yml) from the deprecated saml key fields (eg: login.serviceProviderKey) to the new ones (eg: login.saml.keys), so that we test for the new fields. - also fix the api docs test so that it now correctly marks the retrieve id zones response's `config.samlConfig.certificate` as optional (this field is only returned if you use the deprecated saml key config fields) [#186986697] Co-authored-by: Duane May <duane.may@broadcom.com>
peterhaochen47
force-pushed
the
new-saml-lib-186822654
branch
from
April 24, 2024 18:40
f8ebdb3
to
e4be388
Compare
- populate saml sp metadata field for use='encryption' cert - might be counter-intuitive that the setting on rp registration that controls this is "decryptionX509Credentials", but the resulting sp metadata indeed includes use='encryption' which matches develop branch [186822654]
- to be processed by a single class "SamlConfiguration" where the @ConfigurationProperties(prefix="login.saml") annotation has the ability to process all fields under the login.saml section of UAA.yml - this is helpful because we can now centrally read, process, even validate all saml config fields under "login.saml" - pay attention to @ConfigurationProperties annotation's various requirements though: such as the private field names need to match the actually UAA.yml field name (e.g.: login.saml.fooBar -> private String fooBar); and that there need to be public setters and getters for each field - see: https://docs.spring.io/spring-boot/docs/current/reference/html/features.html#features.external-config.typesafe-configuration-properties.using-annotated-types - the exception of the saml entity id, which in UAA.yml is somehow outside of the login.saml context (set by login.entityID) so that field stays under class SamlEntityIdConfiguration
- these getters and setters are required for @ConfigurationProperties annotation to work; use lombok so that we don't need to explicitly define them [186822654]
- as @DaTa covers the getters and setters
- configure the file name of the saml sp metadata (the downloaded xml file name when accessing the metadata endpoint: http://localhost:8080/uaa/saml/metadata) to match the status quo on develop branch: "saml-sp.xml" - This file name likely do not matter, but out of caution, we should maintain the same file name as before [186822654]
- now that the metadata is being provided at the correct location: /saml/metadata, we can correct the test expectation to reflect that (hence matching the develop branch) [#186986697] Co-authored-by: Duane May <duane.may@broadcom.com>
hsinn0
force-pushed
the
new-saml-lib-186822654
branch
from
April 30, 2024 00:09
03afecd
to
d278343
Compare
- Removed forwarding of `/saml/metadata` endpoint to `/saml/metadata/example`. It is not necessary because `/saml/metadata` endpoint method already calls `/saml/metadata/{registrationId}` with `example` as the default registrationId. (See class `SamlMetadataEndpoint`.) - Made `HttpsEnforcementFilter` to be added to the top of the `SecurityFilterChainPostProcessor`'s `SecurityFilterChain`. - Added `secFilterOpen06SAMLMetadata` to `SecurityFilterChainPostProcessor`'s `redirectToHttps` list. [#186986697] Co-authored-by: Duane May <duane.may@broadcom.com> Co-authored-by: Peter Chen <peter-h.chen@broadcom.com>
hsinn0
force-pushed
the
new-saml-lib-186822654
branch
from
April 30, 2024 00:13
d278343
to
3740582
Compare
- Removed SamlExtensionUrlForwardingFilter. Just commented out for now in case we need it later. - Removed unneeded comments in test code. [#186986697] Co-authored-by: Duane May <duane.may@broadcom.com>
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
This PR is WIP. Creating the PR to run GitHub Actions on each commits.