8000 feat(oauth2): remove unique constraint on app names for RFC 7591 comp… · coder/coder@54086ed · GitHub
[go: up one dir, main page]

Skip to content

Commit 54086ed

Browse files
committed
feat(oauth2): remove unique constraint on app names for RFC 7591 compliance
Change-Id: Iae7a1a06546fbc8de541a52e291f8a4510d57e8a Signed-off-by: Thomas Kosiewski <tk@coder.com>
1 parent 6b97ceb commit 54086ed

File tree

6 files changed

+7
-27
lines changed
  • migrations
  • 6 files changed

    +7
    -27
    lines changed

    coderd/database/dbmem/dbmem.go

    Lines changed: 0 additions & 6 deletions
    Original file line numberDiff line numberDiff line change
    @@ -8975,12 +8975,6 @@ func (q *FakeQuerier) InsertOAuth2ProviderApp(_ context.Context, arg database.In
    89758975
    q.mutex.Lock()
    89768976
    defer q.mutex.Unlock()
    89778977

    8978-
    for _, app := range q.oauth2ProviderApps {
    8979-
    if app.Name == arg.Name {
    8980-
    return database.OAuth2ProviderApp{}, errUniqueConstraint
    8981-
    }
    8982-
    }
    8983-
    89848978
    //nolint:gosimple // Go wants database.OAuth2ProviderApp(arg), but we cannot be sure the structs will remain identical.
    89858979
    app := database.OAuth2ProviderApp{
    89868980
    ID: arg.ID,

    coderd/database/dump.sql

    Lines changed: 0 additions & 3 deletions
    Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.
    Lines changed: 3 additions & 0 deletions
    Original file line numberDiff line numberDiff line change
    @@ -0,0 +1,3 @@
    1+
    -- Restore unique constraint on oauth2_provider_apps.name for rollback
    2+
    -- Note: This rollback may fail if duplicate names exist in the database
    3+
    ALTER TABLE oauth2_provider_apps ADD CONSTRAINT oauth2_provider_apps_name_key UNIQUE (name);
    Lines changed: 3 additions & 0 deletions
    Original file line numberDiff line numberDiff line change
    @@ -0,0 +1,3 @@
    1+
    -- Remove unique constraint on oauth2_provider_apps.name to comply with RFC 7591
    2+
    -- RFC 7591 does not require unique client names, only unique client IDs
    3+
    ALTER TABLE oauth2_provider_apps DROP CONSTRAINT oauth2_provider_apps_name_key;

    coderd/database/unique_constraint.go

    Lines changed: 0 additions & 1 deletion
    Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

    coderd/oauth2_test.go

    Lines changed: 1 addition & 17 deletions
    Original file line numberDiff line numberDiff line change
    @@ -64,13 +64,6 @@ func TestOAuth2ProviderApps(t *testing.T) {
    6464
    CallbackURL: "http://localhost:3000",
    6565
    },
    6666
    },
    67-
    {
    68-
    name: "NameTaken",
    69-
    req: codersdk.PostOAuth2ProviderAppRequest{
    70-
    Name: "taken",
    71-
    CallbackURL: "http://localhost:3000",
    72-
    },
    73-
    },
    7467
    {
    7568
    name: "URLMissing",
    7669
    req: codersdk.PostOAuth2ProviderAppRequest{
    @@ -135,17 +128,8 @@ func TestOAuth2ProviderApps(t *testing.T) {
    135128
    },
    136129
    }
    137130

    138-
    // Generate an application for testing name conflicts.
    139-
    req := codersdk.PostOAuth2ProviderAppRequest{
    140-
    Name: "taken",
    141-
    CallbackURL: "http://coder.com",
    142-
    }
    143-
    //nolint:gocritic // OAauth2 app management requires owner permission.
    144-
    _, err := client.PostOAuth2ProviderApp(ctx, req)
    145-
    require.NoError(t, err)
    146-
    147131
    // Generate an application for testing PUTs.
    148-
    req = codersdk.PostOAuth2ProviderAppRequest{
    132+
    req := codersdk.PostOAuth2ProviderAppRequest{
    149133
    Name: fmt.Sprintf("quark-%d", time.Now().UnixNano()%1000000),
    150134
    CallbackURL: "http://coder.com",
    151135
    }

    0 commit comments

    Comments
     (0)
    0