Skip to content

Commit

Permalink
Turn of "insecure" of built-in IDP
Browse files Browse the repository at this point in the history
Setup idp to verify the LDAP server certificate. As this certificate
might be generated on startup, this also moved the IDP to the "delayed"
set of services. So it starts after "idm".
  • Loading branch information
rhafer committed Mar 16, 2022
1 parent 977f7d4 commit 40074c3
Show file tree
Hide file tree
Showing 4 changed files with 9 additions and 3 deletions.
3 changes: 2 additions & 1 deletion idp/pkg/config/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,8 @@ type Config struct {

// Ldap defines the available LDAP configuration.
type Ldap struct {
URI string `ocisConfig:"uri" env:"IDP_LDAP_URI"`
URI string `ocisConfig:"uri" env:"IDP_LDAP_URI"`
TLSCACert string `ocisConfig:"uri" env:"IDP_LDAP_TLS_CACERT"`

BindDN string `ocisConfig:"bind_dn" env:"IDP_LDAP_BIND_DN"`
BindPassword string `ocisConfig:"bind_password" env:"IDP_LDAP_BIND_PASSWORD"`
Expand Down
3 changes: 2 additions & 1 deletion idp/pkg/config/defaults/defaultconfig.go
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ func DefaultConfig() *config.Config {
SignedOutURI: "",
AuthorizationEndpointURI: "",
EndsessionEndpointURI: "",
Insecure: true,
Insecure: false,
TrustedProxy: nil,
AllowScope: nil,
AllowClientGuests: false,
Expand All @@ -69,6 +69,7 @@ func DefaultConfig() *config.Config {
},
Ldap: config.Ldap{
URI: "ldaps://localhost:9235",
TLSCACert: path.Join(defaults.BaseDataPath(), "idm", "ldap.crt"),
BindDN: "uid=idp,ou=sysusers,o=libregraph-idm",
BindPassword: "idp",
BaseDN: "ou=users,o=libregraph-idm",
Expand Down
4 changes: 4 additions & 0 deletions idp/pkg/service/v0/service.go
Original file line number Diff line number Diff line change
Expand Up @@ -138,6 +138,10 @@ func initLicoInternalEnvVars(ldap *config.Ldap) error {
"LDAP_FILTER": ldap.Filter,
}

if ldap.TLSCACert != "" {
defaults["LDAP_TLS_CACERT"] = ldap.TLSCACert
}

for k, v := range defaults {
if err := os.Setenv(k, v); err != nil {
return fmt.Errorf("could not set env var %s=%s", k, v)
Expand Down
2 changes: 1 addition & 1 deletion ocis/pkg/runtime/service/service.go
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,6 @@ func NewService(options ...Option) (*Service, error) {
s.ServicesRegistry["storage-metadata"] = storage.NewStorageMetadata
s.ServicesRegistry["graph"] = graph.NewSutureService
s.ServicesRegistry["graph-explorer"] = graphExplorer.NewSutureService
s.ServicesRegistry["idp"] = idp.NewSutureService
s.ServicesRegistry["idm"] = idm.NewSutureService
s.ServicesRegistry["ocs"] = ocs.NewSutureService
s.ServicesRegistry["store"] = store.NewSutureService
Expand All @@ -120,6 +119,7 @@ func NewService(options ...Option) (*Service, error) {
// populate delayed services
s.Delayed["storage-sharing"] = storage.NewSharing
s.Delayed["proxy"] = proxy.NewSutureService
s.Delayed["idp"] = idp.NewSutureService

return s, nil
}
Expand Down

0 comments on commit 40074c3

Please sign in to comment.