forked from bitwarden/server
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[PM-12358] New Verified Organization Domain SSO Detail endpoint (bitw…
…arden#4838) * Added /domain/sso/verified to organization controller * Restricting sproc to only return verified domains if the org has sso. Adding name. corrected route. removed not found exception. Adding the sproc definition to the SQL project
- Loading branch information
1 parent
452a45b
commit e288ca9
Showing
11 changed files
with
174 additions
and
0 deletions.
There are no files selected for viewing
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
23 changes: 23 additions & 0 deletions
23
...Console/Models/Response/Organizations/VerifiedOrganizationDomainSsoDetailResponseModel.cs
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
using Bit.Core.Models.Api; | ||
using Bit.Core.Models.Data.Organizations; | ||
|
||
namespace Bit.Api.AdminConsole.Models.Response.Organizations; | ||
|
||
public class VerifiedOrganizationDomainSsoDetailResponseModel : ResponseModel | ||
{ | ||
public VerifiedOrganizationDomainSsoDetailResponseModel(VerifiedOrganizationDomainSsoDetail data) | ||
: base("verifiedOrganizationDomainSsoDetails") | ||
{ | ||
if (data is null) | ||
{ | ||
throw new ArgumentNullException(nameof(data)); | ||
} | ||
|
||
DomainName = data.DomainName; | ||
OrganizationIdentifier = data.OrganizationIdentifier; | ||
OrganizationName = data.OrganizationName; | ||
} | ||
public string DomainName { get; } | ||
public string OrganizationIdentifier { get; } | ||
public string OrganizationName { get; } | ||
} |
8 changes: 8 additions & 0 deletions
8
...onsole/Models/Response/Organizations/VerifiedOrganizationDomainSsoDetailsResponseModel.cs
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
using Bit.Api.Models.Response; | ||
|
||
namespace Bit.Api.AdminConsole.Models.Response.Organizations; | ||
|
||
public class VerifiedOrganizationDomainSsoDetailsResponseModel( | ||
IEnumerable<VerifiedOrganizationDomainSsoDetailResponseModel> data, | ||
string continuationToken = null) | ||
: ListResponseModel<VerifiedOrganizationDomainSsoDetailResponseModel>(data, continuationToken); |
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
22 changes: 22 additions & 0 deletions
22
src/Core/Models/Data/Organizations/VerifiedOrganizationDomainSsoDetail.cs
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
namespace Bit.Core.Models.Data.Organizations; | ||
|
||
public class VerifiedOrganizationDomainSsoDetail | ||
{ | ||
public VerifiedOrganizationDomainSsoDetail() | ||
{ | ||
} | ||
|
||
public VerifiedOrganizationDomainSsoDetail(Guid organizationId, string organizationName, string domainName, | ||
string organizationIdentifier) | ||
{ | ||
OrganizationId = organizationId; | ||
OrganizationName = organizationName; | ||
DomainName = domainName; | ||
OrganizationIdentifier = organizationIdentifier; | ||
} | ||
|
||
public Guid OrganizationId { get; init; } | ||
public string OrganizationName { get; init; } | ||
public string DomainName { get; init; } | ||
public string OrganizationIdentifier { get; init; } | ||
} |
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
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
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
23 changes: 23 additions & 0 deletions
23
src/Sql/dbo/Stored Procedures/VerfiedOrganaizationDomainSsoDetails_ReadByEmail.sql
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
CREATE PROCEDURE [dbo].[VerifiedOrganizationDomainSsoDetails_ReadByEmail] | ||
@Email NVARCHAR(256) | ||
AS | ||
BEGIN | ||
SET NOCOUNT ON | ||
|
||
DECLARE @Domain NVARCHAR(256) | ||
|
||
SELECT @Domain = SUBSTRING(@Email, CHARINDEX( '@', @Email) + 1, LEN(@Email)) | ||
|
||
SELECT | ||
O.Id AS OrganizationId, | ||
O.Name AS OrganizationName, | ||
O.Identifier AS OrganizationIdentifier, | ||
OD.DomainName | ||
FROM [dbo].[OrganizationView] O | ||
INNER JOIN [dbo].[OrganizationDomainView] OD ON O.Id = OD.OrganizationId | ||
LEFT JOIN [dbo].[Ssoconfig] S ON O.Id = S.OrganizationId | ||
WHERE OD.DomainName = @Domain | ||
AND O.Enabled = 1 | ||
AND OD.VerifiedDate IS NOT NULL | ||
AND S.Enabled = 1 | ||
END |
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
24 changes: 24 additions & 0 deletions
24
.../Migrator/DbScripts/2024-09-26_00_AddVerifiedOrganizationDomainSsoDetails_ReadByEmail.sql
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
CREATE OR ALTER PROCEDURE [dbo].[VerifiedOrganizationDomainSsoDetails_ReadByEmail] | ||
@Email NVARCHAR(256) | ||
AS | ||
BEGIN | ||
SET NOCOUNT ON | ||
|
||
DECLARE @Domain NVARCHAR(256) | ||
|
||
SELECT @Domain = SUBSTRING(@Email, CHARINDEX( '@', @Email) + 1, LEN(@Email)) | ||
|
||
SELECT | ||
O.Id AS OrganizationId, | ||
O.Name AS OrganizationName, | ||
O.Identifier AS OrganizationIdentifier, | ||
OD.DomainName | ||
FROM [dbo].[OrganizationView] O | ||
INNER JOIN [dbo].[OrganizationDomainView] OD ON O.Id = OD.OrganizationId | ||
LEFT JOIN [dbo].[Ssoconfig] S ON O.Id = S.OrganizationId | ||
WHERE OD.DomainName = @Domain | ||
AND O.Enabled = 1 | ||
AND OD.VerifiedDate IS NOT NULL | ||
AND S.Enabled = 1 | ||
END | ||
GO |