diff --git a/commons/config.go b/commons/config.go index 27ce782..0a67fce 100644 --- a/commons/config.go +++ b/commons/config.go @@ -9,6 +9,7 @@ import ( "strings" "time" + irodsclient_types "github.com/cyverse/go-irodsclient/irods/types" irodsfs_common_utils "github.com/cyverse/irodsfs-common/utils" irodsfs_common_vpath "github.com/cyverse/irodsfs-common/vpath" @@ -27,10 +28,8 @@ const ( MetadataCacheTimeoutDefault time.Duration = 5 * time.Minute MetadataCacheCleanupTimeDefault time.Duration = 5 * time.Minute - AuthSchemePAM string = "pam" - AuthSchemeNative string = "native" - AuthSchemeDefault string = AuthSchemeNative - CSNegotiationDefault string = "CS_NEG_REFUSE" // Require TCP + AuthSchemeDefault string = string(irodsclient_types.AuthSchemeNative) + CSNegotiationDefault string = string(irodsclient_types.CSNegotiationRequireTCP) EncryptionKeySizeDefault int = 32 EncryptionAlgorithmDefault string = "AES-256-CBC" SaltSizeDefault int = 8 @@ -409,8 +408,9 @@ func (config *Config) Validate() error { return fmt.Errorf("connection max must be equal or greater than 1") } - if config.AuthScheme != AuthSchemePAM && config.AuthScheme != AuthSchemeNative { - return fmt.Errorf("unknown auth scheme - %v", config.AuthScheme) + authScheme, err := irodsclient_types.GetAuthScheme(config.AuthScheme) + if err != nil { + return err } if config.ClientServerNegotiation { @@ -419,7 +419,7 @@ func (config *Config) Validate() error { } } - if config.AuthScheme == AuthSchemePAM { + if authScheme == irodsclient_types.AuthSchemePAM { if _, err := os.Stat(config.CACertificateFile); os.IsNotExist(err) { return fmt.Errorf("SSL CA Certificate file error - %v", err) } diff --git a/go.mod b/go.mod index 2731ee1..666ddba 100644 --- a/go.mod +++ b/go.mod @@ -3,10 +3,10 @@ module github.com/cyverse/irodsfs go 1.18 require ( - github.com/cyverse/go-irodsclient v0.10.2 - github.com/cyverse/irodsfs-common v0.0.0-20221205194134-22e3bba8bbaf + github.com/cyverse/go-irodsclient v0.10.3 + github.com/cyverse/irodsfs-common v0.0.0-20221206163048-f6bb170e716f github.com/cyverse/irodsfs-monitor v0.0.0-20220809235922-daf13261a2dc - github.com/cyverse/irodsfs-pool v0.6.1 + github.com/cyverse/irodsfs-pool v0.6.2 github.com/hanwen/go-fuse/v2 v2.1.0 github.com/pkg/profile v1.7.0 github.com/rs/xid v1.3.0 diff --git a/go.sum b/go.sum index 13b609d..147b613 100644 --- a/go.sum +++ b/go.sum @@ -14,14 +14,14 @@ github.com/cncf/udpa/go v0.0.0-20191209042840-269d4d468f6f/go.mod h1:M8M6+tZqaGX github.com/cncf/udpa/go v0.0.0-20201120205902-5459f2c99403/go.mod h1:WmhPx2Nbnhtbo57+VJT5O0JRkEi1Wbu0z5j0R8u5Hbk= github.com/cncf/xds/go v0.0.0-20210312221358-fbca930ec8ed/go.mod h1:eXthEFrGJvWHgFFCl3hGmgk+/aYT6PnTQLykKQRLhEs= github.com/cpuguy83/go-md2man/v2 v2.0.2/go.mod h1:tgQtvFlXSQOSOSIRvRPT7W67SCa46tRHOmNcaadrF8o= -github.com/cyverse/go-irodsclient v0.10.2 h1:97SJJfOE/V7xwB61ENUCWU3mFVvhzz/J0ZnAv48yUKY= -github.com/cyverse/go-irodsclient v0.10.2/go.mod h1:UaBJ8f9cRQYx3kkmbfWMDlZGQ4AF5k5oV2X27BGiO4o= -github.com/cyverse/irodsfs-common v0.0.0-20221205194134-22e3bba8bbaf h1:tmp965KPpfIc9XOM2Fqto0Do1wUaslqjRcg8p1OKMCQ= -github.com/cyverse/irodsfs-common v0.0.0-20221205194134-22e3bba8bbaf/go.mod h1:d7J76Fn2qn1XfJBwBCyM7hdTN8xuESUmDRUpNfLUsDs= +github.com/cyverse/go-irodsclient v0.10.3 h1:H6IfbEz+k/w5ASzzPUz/sfdGCBe4zHvuXPmZOdgHvQE= +github.com/cyverse/go-irodsclient v0.10.3/go.mod h1:UaBJ8f9cRQYx3kkmbfWMDlZGQ4AF5k5oV2X27BGiO4o= +github.com/cyverse/irodsfs-common v0.0.0-20221206163048-f6bb170e716f h1:3H5Sg5QzOrTK8vlwroiA2PL1E3LHzviaXmN27/dPzJY= +github.com/cyverse/irodsfs-common v0.0.0-20221206163048-f6bb170e716f/go.mod h1:BQ3WyOnsYRO/A3uaEYJkUkbDNhz5AsABWuJer6Asrj0= github.com/cyverse/irodsfs-monitor v0.0.0-20220809235922-daf13261a2dc h1:gIpG0ETQOEZloFwB5iU2zljVsoUDTpUEl/3WF19gLNk= github.com/cyverse/irodsfs-monitor v0.0.0-20220809235922-daf13261a2dc/go.mod h1:8UE1mT26+0vAsqS9UJ6Q/vlKq3da6FLdt5p6Tt1AIC4= -github.com/cyverse/irodsfs-pool v0.6.1 h1:gZvs/KxF5L7K7imAWgzcgxgijqZ0wn7UrnRUNjgUhVw= -github.com/cyverse/irodsfs-pool v0.6.1/go.mod h1:0mIBlStCBVIRn7+ptKH52tQp2NiNuNr3nRjxd4J8Dmg= +github.com/cyverse/irodsfs-pool v0.6.2 h1:qdfhF8jMFHzdnpnOGAkaaDiDOK9+DJJefb1AYNq86aw= +github.com/cyverse/irodsfs-pool v0.6.2/go.mod h1:NAglpjI39L506KsB/u0ludcqPRIYphSjiQP+kF4QIMs= github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c= github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= diff --git a/irodsfs/fs.go b/irodsfs/fs.go index 5452d48..b3b0e5e 100644 --- a/irodsfs/fs.go +++ b/irodsfs/fs.go @@ -78,15 +78,25 @@ func NewFileSystem(config *commons.Config) (*IRODSFS, error) { defer irodsfs_common_utils.StackTraceFromPanic(logger) + authScheme, err := irodsclient_types.GetAuthScheme(config.AuthScheme) + if err != nil { + return nil, err + } + + csNegotiation, err := irodsclient_types.GetCSNegotiationRequire(config.CSNegotiationPolicy) + if err != nil { + return nil, err + } + account, err := irodsclient_types.CreateIRODSProxyAccount(config.Host, config.Port, config.ClientUser, config.Zone, config.ProxyUser, config.Zone, - irodsclient_types.AuthScheme(config.AuthScheme), config.Password, config.Resource) + authScheme, config.Password, config.Resource) if err != nil { logger.WithError(err).Error("failed to create IRODS Account") return nil, fmt.Errorf("failed to create IRODS Account - %v", err) } - if irodsclient_types.AuthScheme(config.AuthScheme) == irodsclient_types.AuthSchemePAM { + if authScheme == irodsclient_types.AuthSchemePAM { sslConfig, err := irodsclient_types.CreateIRODSSSLConfig(config.CACertificateFile, config.EncryptionKeySize, config.EncryptionAlgorithm, config.SaltSize, config.HashRounds) if err != nil { @@ -106,7 +116,7 @@ func NewFileSystem(config *commons.Config) (*IRODSFS, error) { } account.SetSSLConfiguration(sslConfig) - account.SetCSNegotiation(config.ClientServerNegotiation, irodsclient_types.CSNegotiationRequire(config.CSNegotiationPolicy)) + account.SetCSNegotiation(config.ClientServerNegotiation, csNegotiation) } } @@ -182,7 +192,7 @@ func NewFileSystem(config *commons.Config) (*IRODSFS, error) { Zone: config.Zone, ClientUser: config.ClientUser, ProxyUser: config.ProxyUser, - AuthScheme: config.AuthScheme, + AuthScheme: string(authScheme), ReadAheadMax: config.ReadAheadMax, OperationTimeout: time.Duration(config.OperationTimeout).String(), ConnectionIdleTimeout: time.Duration(config.ConnectionIdleTimeout).String(),