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

Schema for organization membership requests #5204

Merged
merged 6 commits into from
Dec 21, 2017

Conversation

chenriksson
Copy link
Member

@chenriksson chenriksson commented Dec 18, 2017

New membership request table will be used for confirming membership in organizations. Request can result from an organization adding new members, or from the initial migration where the first admin account is added. Design meeting scheduled for tomorrow will include this.

Also adds tenantId column to Credential, which can be used to enforce organization policy that AAD tenant ids match.

/CC: @anangaur

@scottbommarito
Copy link
Contributor

Let me know when to review this--I assume schema is going to change slightly after the discussion we had today.

@chenriksson
Copy link
Member Author

@scottbommarito Per our discussion, I'll see if I can persist the Organization.TenantId as security policy instead of a DB column. Thanks!

Copy link
Contributor

@shishirx34 shishirx34 left a comment

Choose a reason for hiding this comment

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

Tenant ID changes look good to me.

@@ -22,6 +22,8 @@ namespace NuGetGallery.Authentication
{
public class AuthenticationService
{
private const string tenantIdClaimType = "http://schemas.microsoft.com/identity/claims/tenantid";
Copy link
Contributor

Choose a reason for hiding this comment

The 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.

@chenriksson chenriksson requested review from agr, shishirx34, ryuyu, skofman1, scottbommarito and anangaur and removed request for anangaur December 19, 2017 22:55
@chenriksson
Copy link
Member Author

chenriksson commented Dec 19, 2017

@shishirx34 Do you know if tenantId would ever change? I'm guessing only if someone creates a new AAD tenant...

@shishirx34
Copy link
Contributor

I don't think the tenantid would change.

@chenriksson
Copy link
Member Author

@scottbommarito This is ready for review when you have a chance. I removed TenantId column from the Organizations table, and will instead do security policies in a separate PR.

@@ -2,6 +2,7 @@
// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.

using System.Collections.Generic;
using System.ComponentModel.DataAnnotations;
Copy link
Contributor

Choose a reason for hiding this comment

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

nit: is this needed?

/// <summary>
/// Organization membership requests, for a non-organization <see cref="User"/> account.
/// </summary>
public virtual ICollection<MembershipRequest> OrganizationRequests { get; set; }
Copy link
Contributor

Choose a reason for hiding this comment

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

These are requests for a user to become an organization, with an admin specified by the request, correct?

I would explicitly state that. Perhaps name this field OrganizationMigrationRequest or something.

Copy link
Member Author

Choose a reason for hiding this comment

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

OrganizationRequests are requests to join an organization.

Now that there are separate tables, I have OrganizationMigrationRequest below for the migration. Another bonus I see for the separate tables is that I'm also able to constrain this to an optional 1:1 relation, so there's only ever 1 migration request for an account... I like that.

Copy link
Member Author

Choose a reason for hiding this comment

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

There's also Organization.MemberRequests now, which are requests to join an organization - from the Organization direction.

Copy link
Contributor

Choose a reason for hiding this comment

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

Oh so these are requests to join an organization AFTER it's migrated?

///
/// Relationship is on the User table because organization transformation may not be complete.
/// </summary>
public virtual ICollection<MembershipRequest> MemberRequests { get; set; }
Copy link
Contributor

Choose a reason for hiding this comment

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

The more I look at this the more concerned I am that keeping MembershipRequest a single class for both organization migration and adding members to existing organizations instead of two separate classes is ultimately more confusing to use. There should only be one OrganizationMigrationRequest for a user at once and MembershipRequests should only be connected to an existing Organization. Given this API, neither of those things are guaranteed, and the code will have to constantly check that those conditions are not violated.

Copy link
Member Author

Choose a reason for hiding this comment

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

Going to split into 2 separate request tables.

Copy link
Contributor

@scottbommarito scottbommarito left a comment

Choose a reason for hiding this comment

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

looks great!

@@ -29,5 +29,10 @@ public Organization(string name) : base(name)
/// Organization Memberships to this organization.
/// </summary>
public virtual ICollection<Membership> Members { get; set; }

/// <summary>
/// Organization membership requests, for an organization <see cref="Organization"/> account.
Copy link
Contributor

Choose a reason for hiding this comment

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

for an organization is now redundant given this is on the Organization object.

/// <summary>
/// Organization membership requests, for a non-organization <see cref="User"/> account.
/// </summary>
public virtual ICollection<MembershipRequest> OrganizationRequests { get; set; }
Copy link
Contributor

Choose a reason for hiding this comment

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

Oh so these are requests to join an organization AFTER it's migrated?

@chenriksson chenriksson merged commit fdd75b9 into dev Dec 21, 2017
@chenriksson chenriksson deleted the chenriks-org-migration-schema branch December 21, 2017 19:31
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants