scim/pkg/supplier/supplier.go

33 lines
568 B
Go
Raw Normal View History

2022-06-10 11:51:19 +00:00
package supplier
import (
"context"
)
func Reconcile(ctx context.Context, sp ServiceProviderSupplier, kc KeycloakSupplier) error {
if err := sp.StartSession(ctx); err != nil {
return err
}
defer sp.CloseSession()
if err := sp.InstallOrUpdate(); err != nil {
return err
}
if err := sp.Enable(); err != nil {
return err
}
username, password, err := sp.GenerateCredentials()
if err != nil {
return err
}
return kc.Reconcile(ctx, ScimClient{
Name: sp.Name(),
Endpoint: sp.ScimEndpoint(),
Username: username,
Password: password,
})
}