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

add idauth back for sc2 #984

Open
wants to merge 1 commit into
base: release-sc2
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
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
110 changes: 110 additions & 0 deletions controllers/operator/ingress.go
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,8 @@ var ingressList []string = []string{
"id-mgmt",
"idmgmt-v2-api",
"platform-auth",
"platform-id-auth-block",
"platform-id-auth",
"platform-id-provider",
"platform-login",
"platform-oidc-block",
Expand Down Expand Up @@ -94,6 +96,8 @@ func (r *AuthenticationReconciler) handleIngress(instance *operatorv1alpha1.Auth
idMgmtIngress,
idmgmtV2ApiIngress,
platformAuthIngress,
platformIdAuthBlockIngress,
platformIdAuthIngress,
platformIdProviderIngress,
platformLoginIngress,
platformOidcBlockIngress,
Expand Down Expand Up @@ -345,6 +349,112 @@ func platformAuthIngress(instance *operatorv1alpha1.Authentication, scheme *runt

}

func platformIdAuthBlockIngress(instance *operatorv1alpha1.Authentication, scheme *runtime.Scheme) *netv1.Ingress {
pathType := netv1.PathType("ImplementationSpecific")
reqLogger := log.WithValues("Instance.Namespace", instance.Namespace, "Instance.Name", instance.Name)
newIngress := &netv1.Ingress{
ObjectMeta: metav1.ObjectMeta{
Name: "platform-id-auth-block",
Namespace: instance.Namespace,
Labels: map[string]string{"app": "platform-auth-service"},
Annotations: map[string]string{
"kubernetes.io/ingress.class": "ibm-icp-management",
"icp.management.ibm.com/location-modifier": "=",
"icp.management.ibm.com/configuration-snippet": `
add_header 'X-XSS-Protection' '1' always;
`,
},
},
Spec: netv1.IngressSpec{
Rules: []netv1.IngressRule{
{
IngressRuleValue: netv1.IngressRuleValue{
HTTP: &netv1.HTTPIngressRuleValue{
Paths: []netv1.HTTPIngressPath{
{
Path: "/idauth/oidc/endpoint",
PathType: &pathType,
Backend: netv1.IngressBackend{
Service: &netv1.IngressServiceBackend{
Name: "default-http-backend",
Port: netv1.ServiceBackendPort{
Number: 80,
},
},
},
},
},
},
},
},
},
},
}

// Set Authentication instance as the owner and controller of the Ingress
err := controllerutil.SetControllerReference(instance, newIngress, scheme)
if err != nil {
reqLogger.Error(err, "Failed to set owner for Ingress")
return nil
}
return newIngress

}

func platformIdAuthIngress(instance *operatorv1alpha1.Authentication, scheme *runtime.Scheme) *netv1.Ingress {
pathType := netv1.PathType("ImplementationSpecific")
reqLogger := log.WithValues("Instance.Namespace", instance.Namespace, "Instance.Name", instance.Name)
newIngress := &netv1.Ingress{
ObjectMeta: metav1.ObjectMeta{
Name: "platform-id-auth",
Namespace: instance.Namespace,
Labels: map[string]string{"app": "platform-auth-service"},
Annotations: map[string]string{
"kubernetes.io/ingress.class": "ibm-icp-management",
"icp.management.ibm.com/secure-backends": "true",
"icp.management.ibm.com/rewrite-target": "/",
"icp.management.ibm.com/configuration-snippet": `
add_header 'X-Frame-Options' 'SAMEORIGIN' always;
add_header 'X-Content-Type-Options' 'nosniff';
`,
},
},
Spec: netv1.IngressSpec{
Rules: []netv1.IngressRule{
{
IngressRuleValue: netv1.IngressRuleValue{
HTTP: &netv1.HTTPIngressRuleValue{
Paths: []netv1.HTTPIngressPath{
{
Path: "/idauth",
PathType: &pathType,
Backend: netv1.IngressBackend{
Service: &netv1.IngressServiceBackend{
Name: "platform-auth-service",
Port: netv1.ServiceBackendPort{
Number: 9443,
},
},
},
},
},
},
},
},
},
},
}

// Set Authentication instance as the owner and controller of the Ingress
err := controllerutil.SetControllerReference(instance, newIngress, scheme)
if err != nil {
reqLogger.Error(err, "Failed to set owner for Ingress")
return nil
}
return newIngress

}

func platformIdProviderIngress(instance *operatorv1alpha1.Authentication, scheme *runtime.Scheme) *netv1.Ingress {
pathType := netv1.PathType("ImplementationSpecific")
reqLogger := log.WithValues("Instance.Namespace", instance.Namespace, "Instance.Name", instance.Name)
Expand Down
1 change: 1 addition & 0 deletions controllers/operator/resourcestatus.go
Original file line number Diff line number Diff line change
Expand Up @@ -230,6 +230,7 @@ func (r *AuthenticationReconciler) getCurrentServiceStatus(ctx context.Context,
names: []string{
"id-mgmt",
"platform-auth",
"platform-id-auth",
"platform-id-provider",
"platform-login",
"platform-oidc",
Expand Down
42 changes: 12 additions & 30 deletions controllers/operator/routes.go
Original file line number Diff line number Diff line change
Expand Up @@ -184,6 +184,18 @@ func (r *AuthenticationReconciler) handleRoutes(ctx context.Context, instance *o
DestinationCAcert: platformIdentityProviderCert,
ServiceName: PlatformIdentityProviderServiceName,
},
"platform-id-auth": {
Annotations: map[string]string{
"haproxy.router.openshift.io/balance": "source",
"haproxy.router.openshift.io/rewrite-target": "/",
},
Name: "platform-id-auth",
RouteHost: routeHost,
RoutePath: "/idauth",
RoutePort: 9443,
DestinationCAcert: platformAuthCert,
ServiceName: PlatformAuthServiceName,
},
"platform-id-provider": {
Annotations: map[string]string{
"haproxy.router.openshift.io/rewrite-target": "/",
Expand Down Expand Up @@ -265,43 +277,13 @@ func (r *AuthenticationReconciler) handleRoutes(ctx context.Context, instance *o
return
}

func (r *AuthenticationReconciler) removeIdauth(ctx context.Context, instance *operatorv1alpha1.Authentication) (err error) {
namespace := instance.Namespace
reqLogger := log.WithValues("func", "ReconcileRoute", "namespace", namespace)
reqLogger.Info("Determined platform-id-auth Route should not exist; removing if present")
observedRoute := &routev1.Route{}
err = r.Get(ctx, types.NamespacedName{Name: "platform-id-auth", Namespace: namespace}, observedRoute)
if errors.IsNotFound(err) {
return nil
} else if err != nil {
reqLogger.Error(err, "Failed to get existing platform-id-auth route for reconciliation")
return
}
err = r.Delete(ctx, observedRoute)
if errors.IsNotFound(err) {
return nil
} else if err != nil {
reqLogger.Error(err, "Failed to delete platform-id-auth Route")
return
}
reqLogger.Info("Successfully deleted platform-id-auth Route")
return
}

func (r *AuthenticationReconciler) reconcileRoute(ctx context.Context, instance *operatorv1alpha1.Authentication, fields *reconcileRouteFields, needToRequeue *bool) (err error) {

namespace := instance.Namespace
reqLogger := log.WithValues("func", "ReconcileRoute", "name", fields.Name, "namespace", namespace)

reqLogger.Info("Reconciling route", "annotations", fields.Annotations, "routeHost", fields.RouteHost, "routePath", fields.RoutePath)

err = r.removeIdauth(ctx, instance)

if err != nil {
reqLogger.Error(err, "Error deleting platform-id-auth Route")
return
}

calculatedRoute, err := r.newRoute(instance, fields)
if err != nil {
reqLogger.Error(err, "Error creating desired route for reconcilition")
Expand Down