Skip to content

Commit b0c1cbf

Browse files
authored
operator: Merge pull request redpanda-data#6359 from pvsune/enterprise/pvsune/rpcloud-sso
Console RedpandaCloud SSO support in the operator
2 parents 3d9a8f4 + f684fe8 commit b0c1cbf

File tree

6 files changed

+117
-4
lines changed

6 files changed

+117
-4
lines changed

apis/redpanda/v1alpha1/console_enterprise_types.go

+16
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,22 @@ type EnterpriseLogin struct {
2626
JWTSecretRef SecretKeyRef `json:"jwtSecretRef"`
2727

2828
Google *EnterpriseLoginGoogle `json:"google,omitempty"`
29+
30+
RedpandaCloud *EnterpriseLoginRedpandaCloud `json:"redpandaCloud,omitempty"`
31+
}
32+
33+
// EnterpriseLoginRedpandaCloud defines configurable fields for RedpandaCloud SSO provider
34+
type EnterpriseLoginRedpandaCloud struct {
35+
Enabled bool `json:"enabled" yaml:"enabled"`
36+
37+
// Domain is the domain of the auth server
38+
Domain string `json:"domain" yaml:"domain"`
39+
40+
// Audience is the domain where this auth is intended for
41+
Audience string `json:"audience" yaml:"audience"`
42+
43+
// AllowedOrigins indicates if response is allowed from given origin
44+
AllowedOrigins string `json:"allowedOrigins,omitempty" yaml:"allowedOrigins,omitempty"`
2945
}
3046

3147
// IsGoogleLoginEnabled returns true if Google SSO provider is enabled

apis/redpanda/v1alpha1/zz_generated.deepcopy.go

+20
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

config/crd/bases/redpanda.vectorized.io_consoles.yaml

+22
Original file line numberDiff line numberDiff line change
@@ -350,6 +350,28 @@ spec:
350350
- name
351351
- namespace
352352
type: object
353+
redpandaCloud:
354+
description: EnterpriseLoginRedpandaCloud defines configurable
355+
fields for RedpandaCloud provider
356+
properties:
357+
allowedOrigins:
358+
description: AllowedOrigins indicates if response is allowed
359+
from given origin
360+
type: string
361+
audience:
362+
description: Audience is the domain where this auth is intended
363+
for
364+
type: string
365+
domain:
366+
description: Domain is the domain of the auth server
367+
type: string
368+
enabled:
369+
type: boolean
370+
required:
371+
- audience
372+
- domain
373+
- enabled
374+
type: object
353375
required:
354376
- enabled
355377
- jwtSecretRef

controllers/redpanda/console_controller_test.go

+45
Original file line numberDiff line numberDiff line change
@@ -342,4 +342,49 @@ var _ = Describe("Console controller", func() {
342342
}, timeout, interval).Should(BeTrue())
343343
})
344344
})
345+
346+
Context("When enabling multiple Login providers", func() {
347+
ctx := context.Background()
348+
It("Should prioritize RedpandaCloud", func() {
349+
var (
350+
rpCloudDomain = "test.auth.vectorized.io"
351+
rpCloudAudience = "dev.vectorized.io"
352+
)
353+
354+
By("Updating Console RedpandaCloud Login fields")
355+
console := &redpandav1alpha1.Console{}
356+
Expect(k8sClient.Get(ctx, types.NamespacedName{Namespace: ConsoleNamespace, Name: ConsoleName}, console)).Should(Succeed())
357+
console.Spec.Login.RedpandaCloud = &redpandav1alpha1.EnterpriseLoginRedpandaCloud{
358+
Enabled: true,
359+
Domain: rpCloudDomain,
360+
Audience: rpCloudAudience,
361+
}
362+
Expect(k8sClient.Update(ctx, console)).Should(Succeed())
363+
364+
By("Having only RedpandaCloud provider in ConfigMap")
365+
createdConfigMaps := &corev1.ConfigMapList{}
366+
Eventually(func() bool {
367+
if err := k8sClient.List(ctx, createdConfigMaps, client.MatchingLabels(labels.ForConsole(console)), client.InNamespace(ConsoleNamespace)); err != nil {
368+
return false
369+
}
370+
if len(createdConfigMaps.Items) != 1 {
371+
return false
372+
}
373+
for _, cm := range createdConfigMaps.Items {
374+
cc := &consolepkg.ConsoleConfig{}
375+
if err := yaml.Unmarshal([]byte(cm.Data["config.yaml"]), cc); err != nil {
376+
return false
377+
}
378+
if cc.Login.Google != nil {
379+
return false
380+
}
381+
rpCloudConfig := cc.Login.RedpandaCloud
382+
if !rpCloudConfig.Enabled || rpCloudConfig.Domain != rpCloudDomain || rpCloudConfig.Audience != rpCloudAudience {
383+
return false
384+
}
385+
}
386+
return true
387+
}, timeout, interval).Should(BeTrue())
388+
})
389+
})
345390
})

pkg/console/configmap.go

+8-1
Original file line numberDiff line numberDiff line change
@@ -203,7 +203,14 @@ func (cm *ConfigMap) genLogin(ctx context.Context) (e EnterpriseLogin, err error
203203
}
204204
enterpriseLogin.JWTSecret = string(jwt)
205205

206-
switch { // nolint:gocritic // will support more providers
206+
switch {
207+
case provider.RedpandaCloud != nil:
208+
enterpriseLogin.RedpandaCloud = &redpandav1alpha1.EnterpriseLoginRedpandaCloud{
209+
Enabled: provider.RedpandaCloud.Enabled,
210+
Domain: provider.RedpandaCloud.Domain,
211+
Audience: provider.RedpandaCloud.Audience,
212+
AllowedOrigins: provider.RedpandaCloud.AllowedOrigins,
213+
}
207214
case provider.Google != nil:
208215
cc := redpandav1alpha1.SecretKeyRef{
209216
Namespace: provider.Google.ClientCredentialsRef.Namespace,

pkg/console/console.go

+6-3
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,8 @@ import (
1414
"github.com/cloudhut/common/rest"
1515
"github.com/redpanda-data/console/backend/pkg/connect"
1616
"github.com/redpanda-data/console/backend/pkg/kafka"
17+
18+
redpandav1alpha1 "github.com/redpanda-data/redpanda/src/go/k8s/apis/redpanda/v1alpha1"
1719
)
1820

1921
const (
@@ -54,9 +56,10 @@ type EnterpriseRBAC struct {
5456

5557
// EnterpriseLogin is the Console Enterprise Login config
5658
type EnterpriseLogin struct {
57-
Enabled bool `json:"enabled" yaml:"enabled"`
58-
JWTSecret string `json:"jwtSecret,omitempty" yaml:"jwtSecret,omitempty"`
59-
Google *EnterpriseLoginGoogle `json:"google,omitempty" yaml:"google,omitempty"`
59+
Enabled bool `json:"enabled" yaml:"enabled"`
60+
JWTSecret string `json:"jwtSecret,omitempty" yaml:"jwtSecret,omitempty"`
61+
Google *EnterpriseLoginGoogle `json:"google,omitempty" yaml:"google,omitempty"`
62+
RedpandaCloud *redpandav1alpha1.EnterpriseLoginRedpandaCloud `json:"redpandaCloud,omitempty" yaml:"redpandaCloud,omitempty"`
6063
}
6164

6265
// EnterpriseLoginGoogle is the Console Enterprise Google SSO config

0 commit comments

Comments
 (0)