go-hep.org/x/hep@v0.38.1/xrootd/xrdproto/auth/host/host.go (about) 1 // Copyright ©2018 The go-hep Authors. All rights reserved. 2 // Use of this source code is governed by a BSD-style 3 // license that can be found in the LICENSE file. 4 5 // Package host contains the implementation for the "host" security provider. 6 package host // import "go-hep.org/x/hep/xrootd/xrdproto/auth/host" 7 8 import ( 9 "os" 10 11 "go-hep.org/x/hep/xrootd/xrdproto/auth" 12 ) 13 14 // Default is a host security provider configured from the current local host. 15 // If the credentials could not be correctly configured, Default will be nil. 16 var Default auth.Auther 17 18 func init() { 19 host, err := os.Hostname() 20 if err != nil { 21 return 22 } 23 Default = &Auth{Hostname: host} 24 } 25 26 // Auth implements the host security provider. 27 type Auth struct { 28 Hostname string 29 } 30 31 // Provider implements auth.Auther 32 func (*Auth) Provider() string { 33 return "host" 34 } 35 36 // Type indicates the host authentication protocol is used. 37 var Type = [4]byte{'h', 'o', 's', 't'} 38 39 // Request implements auth.Auther 40 func (a *Auth) Request(params []string) (*auth.Request, error) { 41 return &auth.Request{Type: Type, Credentials: "host\000" + a.Hostname + "\000"}, nil 42 } 43 44 var ( 45 _ auth.Auther = (*Auth)(nil) 46 )