-
Notifications
You must be signed in to change notification settings - Fork 645
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
Schema for organization membership requests #5204
Merged
Merged
Changes from 1 commit
Commits
Show all changes
6 commits
Select commit
Hold shift + click to select a range
9606b4c
Schema changes for org membership requests
chenriksson 69c027a
Make token required and add created column
chenriksson eec63e8
TenantId schema and auth service population
chenriksson fe5bde6
Remove Organization.TenantId column
chenriksson c2561b0
Add separate request table for org migrations
chenriksson 779bfe6
Fix comment
chenriksson 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 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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -22,6 +22,8 @@ namespace NuGetGallery.Authentication | |
{ | ||
public class AuthenticationService | ||
{ | ||
private const string tenantIdClaimType = "http://schemas.microsoft.com/identity/claims/tenantid"; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I believe the claim type will change with my AAD work, this is fine for now. |
||
|
||
private Dictionary<string, Func<string, string>> _credentialFormatters; | ||
private readonly IDiagnosticsSource _trace; | ||
private readonly IAppConfiguration _config; | ||
|
@@ -220,6 +222,9 @@ await Auditing.SaveAuditRecordAsync( | |
return null; | ||
} | ||
|
||
// store tenant (organization) id, if available | ||
matched.TenantId = credential.TenantId; | ||
|
||
// update last used timestamp | ||
matched.LastUsed = _dateTimeProvider.UtcNow; | ||
await Entities.SaveChangesAsync(); | ||
|
@@ -555,6 +560,8 @@ public virtual async Task<AuthenticateExternalLoginResult> ReadExternalLoginCred | |
var emailClaim = result.Identity.FindFirst(ClaimTypes.Email); | ||
string emailSuffix = emailClaim == null ? String.Empty : (" <" + emailClaim.Value + ">"); | ||
|
||
var tenantClaim = result.Identity.FindFirst(tenantIdClaimType); | ||
|
||
Authenticator auther; | ||
string authenticationType = idClaim.Issuer; | ||
if (!Authenticators.TryGetValue(idClaim.Issuer, out auther)) | ||
|
@@ -574,7 +581,7 @@ public virtual async Task<AuthenticateExternalLoginResult> ReadExternalLoginCred | |
Authentication = null, | ||
ExternalIdentity = result.Identity, | ||
Authenticator = auther, | ||
Credential = _credentialBuilder.CreateExternalCredential(authenticationType, idClaim.Value, nameClaim.Value + emailSuffix) | ||
Credential = _credentialBuilder.CreateExternalCredential(authenticationType, idClaim.Value, nameClaim.Value + emailSuffix, tenantClaim.Value) | ||
}; | ||
} | ||
|
||
|
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
29 changes: 29 additions & 0 deletions
29
src/NuGetGallery/Migrations/201712192219542_TenantId.Designer.cs
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
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,20 @@ | ||
namespace NuGetGallery.Migrations | ||
{ | ||
using System; | ||
using System.Data.Entity.Migrations; | ||
|
||
public partial class TenantId : DbMigration | ||
{ | ||
public override void Up() | ||
{ | ||
AddColumn("dbo.Credentials", "TenantId", c => c.String(maxLength: 256)); | ||
AddColumn("dbo.Organizations", "TenantId", c => c.String(maxLength: 256)); | ||
} | ||
|
||
public override void Down() | ||
{ | ||
DropColumn("dbo.Organizations", "TenantId"); | ||
DropColumn("dbo.Credentials", "TenantId"); | ||
} | ||
} | ||
} |
126 changes: 126 additions & 0 deletions
126
src/NuGetGallery/Migrations/201712192219542_TenantId.resx
Large diffs are not rendered by default.
Oops, something went wrong.
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
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nit: is this needed?