package security import ( "somehole.com/common/security/authentication" "somehole.com/common/security/authorization" "somehole.com/common/security/identity" "somehole.com/common/security/signature" ) type Config struct { Signer signature.Keypair } type SecurityService struct { config Config *authentication.SessionService *authorization.AuditService *authorization.AuthorizationService *identity.IdentityService *signature.SignatureService } func NewSecurityService(config ...Config) (srv *SecurityService) { cfg := Config{} if len(config) == 1 { cfg = config[0] } signatureService, err := signature.NewSignatureService(&cfg.Signer) if err != nil { return } identityService := identity.NewIdentityService() sessionService := authentication.NewSessionService() auditService := authorization.NewAuditService() authorizationService := authorization.NewAuthorizationService(auditService) srv = &SecurityService{ config: cfg, SessionService: sessionService, AuditService: auditService, AuthorizationService: authorizationService, IdentityService: identityService, SignatureService: signatureService, } return }