-
Notifications
You must be signed in to change notification settings - Fork 1.7k
PM-40665 - Seed SSO configuration and a realistic local-sso dev org in the Seeder #8014
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
Open
theMickster
wants to merge
16
commits into
main
Choose a base branch
from
seeder/add-sso-to-seeder
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
+1,397
β208
Open
Changes from 9 commits
Commits
Show all changes
16 commits
Select commit
Hold shift + click to select a range
47a646d
feat(seeder): model the SSO preset block, fixed org id, and local IdP
theMickster 7fa1baa
feat(seeder): seed SsoConfig through the recipe pipeline
theMickster f8ab875
feat(seeder): print the SSO .env wiring block from the CLI
theMickster ca20a10
feat(seeder): retire the tde/sso-vault fixtures for enterprise-basic
theMickster d36d629
feat(seeder): grow the enterprise-basic roster with department groups
theMickster f374fe1
feat(seeder): enrich the enterprise-basic cipher vault
theMickster f35885d
feat(seeder): add the golden local-sso preset and dev IdP wiring
theMickster dd448f9
docs(seeder): catalog local-sso and the enterprise-basic refresh
theMickster deb0cc0
Merge branch 'main' into seeder/add-sso-to-seeder
theMickster 3d7455c
chore: resolve code smells
theMickster 42f1589
Potential fix for pull request finding 'Unnecessarily complex Booleanβ¦
theMickster 4dc7ba4
feat(seeder): warn when --owner-email needs a matching authsources.phβ¦
theMickster 42e556d
Update test/SeederApi.IntegrationTest/FixtureParsingTests.cs
theMickster ca13e19
feat(seeder): fail fast when a preset's fixed organization already exβ¦
theMickster 5bd524d
Merge branch 'main' into seeder/add-sso-to-seeder
theMickster 875d218
Copilot fixes are legit.
theMickster File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or 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
This file contains hidden or 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
56 changes: 56 additions & 0 deletions
56
test/SeederApi.IntegrationTest/CreateSsoConfigStepTests.cs
This file contains hidden or 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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,56 @@ | ||
| ο»Ώusing Bit.Core.AdminConsole.Entities; | ||
| using Bit.Core.Auth.Enums; | ||
| using Bit.Seeder.Pipeline; | ||
| using Bit.Seeder.Services; | ||
| using Bit.Seeder.Steps; | ||
| using Xunit; | ||
|
|
||
| namespace Bit.SeederApi.IntegrationTest; | ||
|
|
||
| public class CreateSsoConfigStepTests | ||
| { | ||
| private static SeederContext BuildContext(Organization organization) | ||
| { | ||
| var services = new ServiceCollection(); | ||
| services.AddSingleton<IManglerService, NoOpManglerService>(); | ||
| services.AddLogging(); | ||
| return new SeederContext(services.BuildServiceProvider()) { Organization = organization }; | ||
| } | ||
|
|
||
| // The SAML path fetches the cert from the live IdP, so it is exercised end-to-end (M6/M7), | ||
| // not here. These cover the guards that don't need a running IdP. | ||
|
|
||
| [Fact] | ||
| public void Execute_NonSamlProvider_SkipsWithoutMutating() | ||
| { | ||
| var org = new Organization { Id = Guid.NewGuid(), Identifier = "unchanged" }; | ||
| var context = BuildContext(org); | ||
| var step = new CreateSsoConfigStep("local-sso", "oidc", MemberDecryptionType.MasterPassword); | ||
|
|
||
| step.Execute(context); | ||
|
|
||
| Assert.Empty(context.SsoConfigs); | ||
| Assert.Equal("unchanged", org.Identifier); | ||
| } | ||
|
|
||
| [Fact] | ||
| public void WithSso_WithoutOrganization_Throws() | ||
| { | ||
| var builder = new ServiceCollection().AddRecipe("test"); | ||
|
|
||
| var ex = Assert.Throws<InvalidOperationException>( | ||
| () => builder.WithSso("local-sso", "saml", MemberDecryptionType.MasterPassword)); | ||
| Assert.Contains("requires an organization", ex.Message); | ||
| } | ||
|
|
||
| [Fact] | ||
| public void WithSso_WithEmptyIdentifier_Throws() | ||
| { | ||
| var builder = new ServiceCollection().AddRecipe("test"); | ||
| builder.HasOrg = true; | ||
|
|
||
| var ex = Assert.Throws<InvalidOperationException>( | ||
| () => builder.WithSso(" ", "saml", MemberDecryptionType.MasterPassword)); | ||
| Assert.Contains("non-empty identifier", ex.Message); | ||
| } | ||
| } |
This file contains hidden or 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
This file contains hidden or 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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,49 @@ | ||
| ο»Ώusing Bit.Core.Auth.Enums; | ||
| using Bit.Seeder.Factories; | ||
| using Xunit; | ||
|
|
||
| namespace Bit.SeederApi.IntegrationTest; | ||
|
|
||
| public class SsoConfigSeederTests | ||
| { | ||
| private const string _idpEntityId = "http://localhost:8090/simplesaml/saml2/idp/metadata.php"; | ||
| private const string _idpSsoUrl = "http://localhost:8090/simplesaml/saml2/idp/SSOService.php"; | ||
| private const string _idpCert = "FAKE-TEST-CERT-BASE64=="; | ||
|
|
||
| [Fact] | ||
| public void CreateSaml2_ProducesEnabledConfigForOrganization() | ||
| { | ||
| var orgId = Guid.NewGuid(); | ||
|
|
||
| var config = SsoConfigSeeder.CreateSaml2(orgId, _idpEntityId, _idpSsoUrl, _idpCert); | ||
|
|
||
| Assert.Equal(orgId, config.OrganizationId); | ||
| Assert.True(config.Enabled); | ||
| } | ||
|
|
||
| [Fact] | ||
| public void CreateSaml2_SerializesSamlDataThatRoundTrips() | ||
| { | ||
| var config = SsoConfigSeeder.CreateSaml2(Guid.NewGuid(), _idpEntityId, _idpSsoUrl, _idpCert); | ||
|
|
||
| var data = config.GetData(); | ||
|
|
||
| Assert.Equal(SsoType.Saml2, data.ConfigType); | ||
| Assert.Equal(MemberDecryptionType.MasterPassword, data.MemberDecryptionType); | ||
| Assert.Equal(_idpEntityId, data.IdpEntityId); | ||
| Assert.Equal(_idpSsoUrl, data.IdpSingleSignOnServiceUrl); | ||
| Assert.Equal(_idpCert, data.IdpX509PublicCert); | ||
| Assert.Equal(Saml2BindingType.HttpRedirect, data.IdpBindingType); | ||
| Assert.True(data.SpUniqueEntityId); | ||
| } | ||
|
|
||
| [Fact] | ||
| public void CreateSaml2_HonorsMemberDecryptionTypeOverride() | ||
| { | ||
| var config = SsoConfigSeeder.CreateSaml2( | ||
| Guid.NewGuid(), _idpEntityId, _idpSsoUrl, _idpCert, | ||
| MemberDecryptionType.TrustedDeviceEncryption); | ||
|
|
||
| Assert.Equal(MemberDecryptionType.TrustedDeviceEncryption, config.GetData().MemberDecryptionType); | ||
| } | ||
| } |
This file contains hidden or 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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,15 @@ | ||
| ο»Ώnamespace Bit.Seeder.Data.Static; | ||
|
|
||
| /// <summary> | ||
| /// Fixed endpoints for the local dev SAML IdP shipped in <c>dev/docker-compose.yml</c> | ||
| /// (the <c>idp</c> profile, image <c>kenchan0130/simplesamlphp</c>). The signing certificate is | ||
| /// deliberately NOT stored here β it is fetched from the live metadata endpoint at seed time (see | ||
| /// <c>CreateSsoConfigStep</c>), so no certificate material lives in source and it always matches the | ||
| /// running image. | ||
| /// </summary> | ||
| internal static class LocalSamlIdp | ||
| { | ||
| internal const string EntityId = "http://localhost:8090/simplesaml/saml2/idp/metadata.php"; | ||
|
|
||
| internal const string SingleSignOnServiceUrl = "http://localhost:8090/simplesaml/saml2/idp/SSOService.php"; | ||
| } |
This file contains hidden or 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
This file contains hidden or 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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,40 @@ | ||
| ο»Ώusing Bit.Core.Auth.Entities; | ||
| using Bit.Core.Auth.Enums; | ||
| using Bit.Core.Auth.Models.Data; | ||
|
|
||
| namespace Bit.Seeder.Factories; | ||
|
|
||
| internal static class SsoConfigSeeder | ||
| { | ||
| internal static SsoConfig CreateSaml2( | ||
| Guid organizationId, | ||
| string idpEntityId, | ||
| string idpSingleSignOnServiceUrl, | ||
| string idpX509PublicCert, | ||
| MemberDecryptionType memberDecryptionType = MemberDecryptionType.MasterPassword) | ||
| { | ||
| var data = new SsoConfigurationData | ||
| { | ||
| ConfigType = SsoType.Saml2, | ||
| MemberDecryptionType = memberDecryptionType, | ||
| IdpEntityId = idpEntityId, | ||
| IdpSingleSignOnServiceUrl = idpSingleSignOnServiceUrl, | ||
| IdpX509PublicCert = idpX509PublicCert, | ||
| // Saml2BindingType has no 0 member, so the CLR default is invalid β set it explicitly. | ||
| IdpBindingType = Saml2BindingType.HttpRedirect, | ||
| // Per-org SP entity id (β¦/saml2/{orgId}), matching the Admin Console default and the | ||
| // dev/.env IDP_SP_ENTITY_ID wiring. Without it the SP entity id is the base β¦/saml2 and | ||
| // the IdP rejects the AuthnRequest ("metadata not found"). | ||
| SpUniqueEntityId = true, | ||
| }; | ||
|
|
||
| var ssoConfig = new SsoConfig | ||
| { | ||
| OrganizationId = organizationId, | ||
| Enabled = true, | ||
| }; | ||
| ssoConfig.SetData(data); | ||
|
|
||
| return ssoConfig; | ||
| } | ||
| } |
This file contains hidden or 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
This file contains hidden or 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
This file contains hidden or 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
This file contains hidden or 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
This file contains hidden or 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
Oops, something went wrong.
Oops, something went wrong.
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.
Uh oh!
There was an error while loading. Please reload this page.