Skip to content

Commit 01c37dd

Browse files
committed
chore: Refactor tunnelSecret handling
1 parent 24fc774 commit 01c37dd

1 file changed

Lines changed: 3 additions & 15 deletions

File tree

api/v1alpha1/amaltheasession_children.go

Lines changed: 3 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -759,25 +759,16 @@ func (as *AmaltheaSession) Secret() v1.Secret {
759759
},
760760
StringData: map[string]string{},
761761
}
762+
762763
// Secret used to secure the tunnel for remote sessions
763-
tunnelSecret := ""
764764
if as.Spec.SessionLocation == Remote {
765-
var err error
766-
tunnelSecret, err = makeTunnelSecret(16)
765+
tunnelSecret, err := makeTunnelSecret(16)
767766
if err != nil {
768767
panic(err)
769768
}
770-
}
771769

772-
if as.Spec.Authentication == nil || as.Spec.Authentication.Type != Oidc {
773-
// In this case we do not need the 'oidc' configuration in the secret,
774-
// we just return an empty one, or one populated with the tunnel secret.
775-
if tunnelSecret != "" {
776-
secret.StringData["WSTUNNEL_SECRET"] = tunnelSecret
777-
}
778-
return secret
770+
secret.StringData["WSTUNNEL_SECRET"] = tunnelSecret
779771
}
780-
781772
// Skip the 'oidc' configuration if it is not needed
782773
if as.Spec.Authentication != nil && as.Spec.Authentication.Type == Oidc {
783774
pathPrefix := as.ingressPathPrefix()
@@ -842,9 +833,6 @@ func (as *AmaltheaSession) Secret() v1.Secret {
842833
secret.StringData["oauth2-proxy-config.yaml"] = strings.Join(oldConfigLines, "\n")
843834
}
844835

845-
if tunnelSecret != "" {
846-
secret.StringData["WSTUNNEL_SECRET"] = tunnelSecret
847-
}
848836
return secret
849837
}
850838

0 commit comments

Comments
 (0)