15
15
package authn
16
16
17
17
import (
18
- // "time"
19
-
20
18
"github.com/greenpau/go-authcrunch/pkg/acl"
21
- // "github.com/greenpau/go-authcrunch/pkg/authn/cache"
22
19
"github.com/greenpau/go-authcrunch/pkg/authn/cookie"
23
- "github.com/greenpau/go-authcrunch/pkg/authn/registration"
24
20
"github.com/greenpau/go-authcrunch/pkg/authn/transformer"
25
21
"github.com/greenpau/go-authcrunch/pkg/authn/ui"
26
22
"github.com/greenpau/go-authcrunch/pkg/authz/options"
27
- // "github.com/greenpau/go-authcrunch/pkg/authz/validator"
28
- "github.com/greenpau/go-authcrunch/pkg/credentials"
29
23
"github.com/greenpau/go-authcrunch/pkg/errors"
30
24
"github.com/greenpau/go-authcrunch/pkg/kms"
31
- "github.com/greenpau/go-authcrunch/pkg/messaging"
32
25
cfgutil "github.com/greenpau/go-authcrunch/pkg/util/cfg"
33
- // "go.uber.org/zap"
34
26
"strings"
35
27
)
36
28
@@ -39,8 +31,6 @@ type PortalConfig struct {
39
31
Name string `json:"name,omitempty" xml:"name,omitempty" yaml:"name,omitempty"`
40
32
// UI holds the configuration for the user interface.
41
33
UI * ui.Parameters `json:"ui,omitempty" xml:"ui,omitempty" yaml:"ui,omitempty"`
42
- // UserRegistrationConfig holds the configuration for the user registration.
43
- UserRegistrationConfig * registration.Config `json:"user_registration_config,omitempty" xml:"user_registration_config,omitempty" yaml:"user_registration_config,omitempty"`
44
34
// UserTransformerConfig holds the configuration for the user transformer.
45
35
UserTransformerConfigs []* transformer.Config `json:"user_transformer_configs,omitempty" xml:"user_transformer_configs,omitempty" yaml:"user_transformer_configs,omitempty"`
46
36
// CookieConfig holds the configuration for the cookies issues by Authenticator.
@@ -49,6 +39,8 @@ type PortalConfig struct {
49
39
IdentityStores []string `json:"identity_stores,omitempty" xml:"identity_stores,omitempty" yaml:"identity_stores,omitempty"`
50
40
// The names of identity providers.
51
41
IdentityProviders []string `json:"identity_providers,omitempty" xml:"identity_providers,omitempty" yaml:"identity_providers,omitempty"`
42
+ // The names of user registries.
43
+ UserRegistries []string `json:"user_registries,omitempty" xml:"user_registries,omitempty" yaml:"user_registries,omitempty"`
52
44
// AccessListConfigs hold the configurations for the ACL of the token validator.
53
45
AccessListConfigs []* acl.RuleConfiguration `json:"access_list_configs,omitempty" xml:"access_list_configs,omitempty" yaml:"access_list_configs,omitempty"`
54
46
// TokenValidatorOptions holds the configuration for the token validator.
@@ -68,11 +60,6 @@ type PortalConfig struct {
68
60
69
61
// Indicated that the config was successfully validated.
70
62
validated bool
71
-
72
- // Shared credentials.
73
- credentials * credentials.Config `json:"credentials,omitempty" xml:"credentials,omitempty" yaml:"credentials,omitempty"`
74
- // Shared messaging.
75
- messaging * messaging.Config `json:"messaging,omitempty" xml:"messaging,omitempty" yaml:"messaging,omitempty"`
76
63
}
77
64
78
65
// AddRawCryptoConfigs adds raw crypto configs.
@@ -123,54 +110,6 @@ func (cfg *PortalConfig) parseRawCryptoConfigs() error {
123
110
return nil
124
111
}
125
112
126
- // SetCredentials binds to shared credentials.
127
- func (cfg * PortalConfig ) SetCredentials (c * credentials.Config ) {
128
- cfg .credentials = c
129
- return
130
- }
131
-
132
- // SetMessaging binds to messaging config.
133
- func (cfg * PortalConfig ) SetMessaging (c * messaging.Config ) {
134
- cfg .messaging = c
135
- return
136
- }
137
-
138
- // ValidateCredentials validates messaging provider and credentials used for
139
- // the user registration.
140
- func (cfg * PortalConfig ) ValidateCredentials () error {
141
- if cfg .UserRegistrationConfig == nil {
142
- return nil
143
- }
144
-
145
- if cfg .UserRegistrationConfig .EmailProvider == "" {
146
- return nil
147
- }
148
-
149
- if cfg .messaging == nil {
150
- return errors .ErrPortalConfigMessagingNil
151
- }
152
- if found := cfg .messaging .FindProvider (cfg .UserRegistrationConfig .EmailProvider ); ! found {
153
- return errors .ErrPortalConfigMessagingProviderNotFound .WithArgs (cfg .UserRegistrationConfig .EmailProvider )
154
- }
155
- providerCreds := cfg .messaging .FindProviderCredentials (cfg .UserRegistrationConfig .EmailProvider )
156
- if providerCreds == "" {
157
- return errors .ErrPortalConfigMessagingProviderCredentialsNotFound .WithArgs (cfg .UserRegistrationConfig .EmailProvider )
158
- }
159
- if providerCreds != "passwordless" {
160
- if cfg .credentials == nil {
161
- return errors .ErrPortalConfigCredentialsNil
162
- }
163
- if found := cfg .credentials .FindCredential (providerCreds ); ! found {
164
- return errors .ErrPortalConfigCredentialsNotFound .WithArgs (providerCreds )
165
- }
166
- }
167
-
168
- if len (cfg .UserRegistrationConfig .AdminEmails ) < 1 {
169
- return errors .ErrPortalConfigAdminEmailNotFound
170
- }
171
- return nil
172
- }
173
-
174
113
// Validate validates PortalConfig.
175
114
func (cfg * PortalConfig ) Validate () error {
176
115
if cfg .validated {
0 commit comments