Skip to content

chore: remove multi-organization and custom role experiment #14862

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

Merged
merged 10 commits into from
Sep 27, 2024
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
remove multi org check from psk auth
  • Loading branch information
Emyrk committed Sep 27, 2024
commit 2837ebcc165c39e2e69b60c4d099c2d908bbc728
19 changes: 3 additions & 16 deletions coderd/httpmw/provisionerdaemon.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,10 +20,9 @@ func ProvisionerDaemonAuthenticated(r *http.Request) bool {
}

type ExtractProvisionerAuthConfig struct {
DB database.Store
Optional bool
PSK string
MultiOrgEnabled bool
DB database.Store
Optional bool
Copy link
Contributor

Choose a reason for hiding this comment

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

This can be dropped as well

Copy link
Member Author

Choose a reason for hiding this comment

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

The Optional?

PSK string
}

func ExtractProvisionerDaemonAuthenticated(opts ExtractProvisionerAuthConfig) func(next http.Handler) http.Handler {
Expand All @@ -39,18 +38,6 @@ func ExtractProvisionerDaemonAuthenticated(opts ExtractProvisionerAuthConfig) fu
httpapi.Write(ctx, w, code, response)
}

if !opts.MultiOrgEnabled {
if opts.PSK == "" {
handleOptional(http.StatusUnauthorized, codersdk.Response{
Message: "External provisioner daemons not enabled",
})
return
}

fallbackToPSK(ctx, opts.PSK, next, w, r, handleOptional)
return
}

psk := r.Header.Get(codersdk.ProvisionerDaemonPSK)
key := r.Header.Get(codersdk.ProvisionerDaemonKey)
if key == "" {
Expand Down
7 changes: 3 additions & 4 deletions enterprise/coderd/coderd.go
Original file line number Diff line number Diff line change
Expand Up @@ -359,10 +359,9 @@ func New(ctx context.Context, options *Options) (_ *API, err error) {
api.provisionerDaemonsEnabledMW,
apiKeyMiddlewareOptional,
httpmw.ExtractProvisionerDaemonAuthenticated(httpmw.ExtractProvisionerAuthConfig{
DB: api.Database,
Optional: true,
PSK: api.ProvisionerDaemonPSK,
MultiOrgEnabled: api.AGPL.Experiments.Enabled(codersdk.ExperimentMultiOrganization),
DB: api.Database,
Optional: true,
PSK: api.ProvisionerDaemonPSK,
}),
// Either a user auth or provisioner auth is required
// to move forward.
Expand Down
93 changes: 41 additions & 52 deletions enterprise/coderd/provisionerdaemons_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -597,17 +597,16 @@ func TestProvisionerDaemonServe(t *testing.T) {
require.NoError(t, err)

tcs := []struct {
name string
psk string
multiOrgFeatureEnabled bool
multiOrgExperimentEnabled bool
insertParams database.InsertProvisionerKeyParams
requestProvisionerKey string
requestPSK string
errStatusCode int
name string
psk string
multiOrgFeatureEnabled bool
insertParams database.InsertProvisionerKeyParams
requestProvisionerKey string
requestPSK string
errStatusCode int
}{
{
name: "MultiOrgDisabledPSKAuthOK",
name: "PSKAuthOK",
psk: "provisionersftw",
requestPSK: "provisionersftw",
},
Expand All @@ -618,58 +617,51 @@ func TestProvisionerDaemonServe(t *testing.T) {
requestPSK: "provisionersftw",
},
{
name: "MultiOrgFeatureDisabledPSKAuthOK",
multiOrgExperimentEnabled: true,
psk: "provisionersftw",
requestPSK: "provisionersftw",
name: "MultiOrgFeatureDisabledPSKAuthOK",
psk: "provisionersftw",
requestPSK: "provisionersftw",
},
{
name: "MultiOrgEnabledPSKAuthOK",
psk: "provisionersftw",
multiOrgFeatureEnabled: true,
multiOrgExperimentEnabled: true,
requestPSK: "provisionersftw",
name: "MultiOrgEnabledPSKAuthOK",
psk: "provisionersftw",
multiOrgFeatureEnabled: true,
requestPSK: "provisionersftw",
},
{
name: "MultiOrgEnabledKeyAuthOK",
psk: "provisionersftw",
multiOrgFeatureEnabled: true,
multiOrgExperimentEnabled: true,
insertParams: insertParams,
requestProvisionerKey: token,
name: "MultiOrgEnabledKeyAuthOK",
psk: "provisionersftw",
multiOrgFeatureEnabled: true,
insertParams: insertParams,
requestProvisionerKey: token,
},
{
name: "MultiOrgEnabledPSKAuthDisabled",
multiOrgFeatureEnabled: true,
multiOrgExperimentEnabled: true,
requestPSK: "provisionersftw",
errStatusCode: http.StatusUnauthorized,
name: "MultiOrgEnabledPSKAuthDisabled",
multiOrgFeatureEnabled: true,
requestPSK: "provisionersftw",
errStatusCode: http.StatusUnauthorized,
},
{
name: "InvalidKey",
multiOrgFeatureEnabled: true,
multiOrgExperimentEnabled: true,
insertParams: insertParams,
requestProvisionerKey: "provisionersftw",
errStatusCode: http.StatusBadRequest,
name: "InvalidKey",
multiOrgFeatureEnabled: true,
insertParams: insertParams,
requestProvisionerKey: "provisionersftw",
errStatusCode: http.StatusBadRequest,
},
{
name: "KeyAndPSK",
multiOrgFeatureEnabled: true,
multiOrgExperimentEnabled: true,
psk: "provisionersftw",
insertParams: insertParams,
requestProvisionerKey: token,
requestPSK: "provisionersftw",
errStatusCode: http.StatusUnauthorized,
name: "KeyAndPSK",
multiOrgFeatureEnabled: true,
psk: "provisionersftw",
insertParams: insertParams,
requestProvisionerKey: token,
requestPSK: "provisionersftw",
errStatusCode: http.StatusUnauthorized,
},
{
name: "None",
multiOrgFeatureEnabled: true,
multiOrgExperimentEnabled: true,
psk: "provisionersftw",
insertParams: insertParams,
errStatusCode: http.StatusUnauthorized,
name: "None",
multiOrgFeatureEnabled: true,
psk: "provisionersftw",
insertParams: insertParams,
errStatusCode: http.StatusUnauthorized,
},
}

Expand All @@ -683,9 +675,6 @@ func TestProvisionerDaemonServe(t *testing.T) {
features[codersdk.FeatureMultipleOrganizations] = 1
}
dv := coderdtest.DeploymentValues(t)
if tc.multiOrgExperimentEnabled {
dv.Experiments.Append(string(codersdk.ExperimentMultiOrganization))
}
client, db, user := coderdenttest.NewWithDatabase(t, &coderdenttest.Options{
LicenseOptions: &coderdenttest.LicenseOptions{
Features: features,
Expand Down