Skip to content
This repository has been archived by the owner on Aug 7, 2024. It is now read-only.

Rmove leftover code from before rework #4

Merged
merged 1 commit into from
Oct 13, 2023
Merged
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
37 changes: 0 additions & 37 deletions internal/controller/commonclientredirecturi_controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -281,43 +281,6 @@ func (r *CommonClientRedirectUriReconciler) SetupWithManager(mgr ctrl.Manager) e
Complete(r)
}

func (r *CommonClientRedirectUriReconciler) cleanUpExternalResources(ctx context.Context, instance *daplav1alpha1.CommonClientRedirectUri) error {

clientId := instance.Status.ClientId
redirectUri := instance.Status.RedirectUri

// If this is the case, chances are that the resource has been deleted already
if clientId == "" || redirectUri == "" {
return nil
}

// Ensure we are authenticated with Keycloak
if err := r.Keycloak.ensureToken(ctx); err != nil {
return err
}

// Get the client
client, err := r.Keycloak.getClientFromId(ctx, clientId)
if err != nil {
return err
}

// Remove the redirect uri from the client
for i, uri := range *client.RedirectURIs {
if uri == redirectUri {
*client.RedirectURIs = append((*client.RedirectURIs)[:i], (*client.RedirectURIs)[i+1:]...)
break
}
}

// Update the client
if err := r.Keycloak.UpdateClient(ctx, r.Keycloak.Token.AccessToken, r.Keycloak.Realm, *client); err != nil {
return err
}

return nil
}

func generateCookieSecret() (string, error) {
b := make([]byte, 32)
_, err := rand.Read(b)
Expand Down