-
Notifications
You must be signed in to change notification settings - Fork 4
/
acorn.go
62 lines (48 loc) · 1.63 KB
/
acorn.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
package idp
import (
"context"
"github.com/Interhyp/metadata-service/acorns/repository"
"github.com/StephanHCB/go-autumn-acorn-registry/api"
auzerolog "github.com/StephanHCB/go-autumn-logging-zerolog"
librepo "github.com/StephanHCB/go-backend-service-common/acorns/repository"
)
// --- implementing Acorn ---
func New() auacornapi.Acorn {
return &Impl{}
}
func (r *Impl) IsIdentityProvider() bool {
return true
}
func (r *Impl) AcornName() string {
return repository.IdentityProviderAcornName
}
func (r *Impl) AssembleAcorn(registry auacornapi.AcornRegistry) error {
r.Configuration = registry.GetAcornByName(librepo.ConfigurationAcornName).(librepo.Configuration)
r.Logging = registry.GetAcornByName(librepo.LoggingAcornName).(librepo.Logging)
r.CustomConfiguration = repository.Custom(r.Configuration)
return nil
}
func (r *Impl) SetupAcorn(registry auacornapi.AcornRegistry) error {
err := registry.SetupAfter(r.Configuration.(auacornapi.Acorn))
if err != nil {
return err
}
err = registry.SetupAfter(r.Logging.(auacornapi.Acorn))
if err != nil {
return err
}
ctx := auzerolog.AddLoggerToCtx(context.Background())
if err := r.Setup(ctx); err != nil {
r.Logging.Logger().Ctx(ctx).Error().WithErr(err).Print("failed to set up idp connector. BAILING OUT")
return err
}
if err := r.ObtainKeySet(ctx); err != nil {
r.Logging.Logger().Ctx(ctx).Error().WithErr(err).Print("failed to obtain key set from identity provider. BAILING OUT")
return err
}
r.Logging.Logger().Ctx(ctx).Info().Print("successfully set up idp connector")
return nil
}
func (r *Impl) TeardownAcorn(registry auacornapi.AcornRegistry) error {
return nil
}