Skip to content

Commit

Permalink
allow eos to use keytab for authentication rather than gw (#355)
Browse files Browse the repository at this point in the history
* allow eos to use keytab for authentication rather than gw

* bail out if keytab is not accesible
  • Loading branch information
labkode committed Nov 7, 2019
1 parent fa6c31c commit 8eb2c1e
Show file tree
Hide file tree
Showing 2 changed files with 35 additions and 0 deletions.
15 changes: 15 additions & 0 deletions pkg/eosclient/eosclient.go
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,9 @@ type Options struct {
// This is the case when access to EOS is done from FUSE under apache or www-data.
ForceSingleUserMode bool

// UseKeyTabAuth changes will authenticate requests by using an EOS keytab.
UseKeytab bool

// SingleUsername is the username to use when connecting to EOS.
// Defaults to apache
SingleUsername string
Expand All @@ -71,6 +74,13 @@ type Options struct {
// Location on the local fs where to store reads.
// Defaults to os.TempDir()
CacheDirectory string

// Keytab is the location of the EOS keytab file.
Keytab string

// SecProtocol is the comma separated list of security protocols used by xrootd.
// For example: "sss, unix"
SecProtocol string
}

func (opt *Options) init() {
Expand Down Expand Up @@ -128,6 +138,11 @@ func (c *Client) execute(ctx context.Context, cmd *exec.Cmd) (string, string, er
"EOS_MGM_URL=" + c.opt.URL,
}

if c.opt.UseKeytab {
cmd.Env = append(cmd.Env, "XrdSecPROTOCOL="+c.opt.SecProtocol)
cmd.Env = append(cmd.Env, "XrdSecSSSKT="+c.opt.Keytab)
}

err := cmd.Run()

var exitStatus int
Expand Down
20 changes: 20 additions & 0 deletions pkg/storage/fs/eos/eos.go
Original file line number Diff line number Diff line change
Expand Up @@ -105,6 +105,15 @@ type config struct {
// ForceSingleUserMode will force connections to EOS to use SingleUsername
ForceSingleUserMode bool `mapstructure:"force_single_user_mode"`

// UseKeyTabAuth changes will authenticate requests by using an EOS keytab.
UseKeytab bool `mapstrucuture:"use_keytab"`

// SecProtocol specifies the xrootd security protocol to use between the server and EOS.
SecProtocol string `mapstructure:"sec_protocol"`

// Keytab specifies the location of the keytab to use to authenticate to EOS.
Keytab string `mapstructure:"keytab"`

// SingleUsername is the username to use when SingleUserMode is enabled
SingleUsername string `mapstructure:"single_username"`
}
Expand Down Expand Up @@ -153,13 +162,24 @@ func New(m map[string]interface{}) (storage.FS, error) {
}
c.init()

// bail out if keytab is not found.
if c.UseKeytab {
if _, err := os.Stat(c.Keytab); err != nil {
err = errors.Wrapf(err, "eos: keytab not accesible at location: %s", err)
return nil, err
}
}

eosClientOpts := &eosclient.Options{
XrdcopyBinary: c.XrdcopyBinary,
URL: c.MasterURL,
EosBinary: c.EosBinary,
CacheDirectory: c.CacheDirectory,
ForceSingleUserMode: c.ForceSingleUserMode,
SingleUsername: c.SingleUsername,
UseKeytab: c.UseKeytab,
Keytab: c.Keytab,
SecProtocol: c.SecProtocol,
}

eosClient := eosclient.New(eosClientOpts)
Expand Down

0 comments on commit 8eb2c1e

Please sign in to comment.