go-hep.org/x/hep@v0.38.1/xrootd/xrdproto/auth/auth.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 auth contains the structures describing auth request. 6 package auth // import "go-hep.org/x/hep/xrootd/xrdproto/auth" 7 8 import ( 9 "go-hep.org/x/hep/xrootd/internal/xrdenc" 10 ) 11 12 // RequestID is the id of the request, it is sent as part of message. 13 // See xrootd protocol specification for details: http://xrootd.org/doc/dev45/XRdv310.pdf, 2.3 Client Request Format. 14 const RequestID uint16 = 3000 15 16 // Request holds the auth request parameters. 17 type Request struct { 18 _ [12]byte 19 Type [4]byte 20 Credentials string 21 } 22 23 // ReqID implements xrdproto.Request.ReqID. 24 func (req *Request) ReqID() uint16 { return RequestID } 25 26 // ShouldSign implements xrdproto.Request.ShouldSign. 27 func (req *Request) ShouldSign() bool { return false } 28 29 // MarshalXrd implements xrdproto.Marshaler. 30 func (o Request) MarshalXrd(wBuffer *xrdenc.WBuffer) error { 31 wBuffer.Next(12) 32 wBuffer.WriteBytes(o.Type[:]) 33 wBuffer.WriteStr(o.Credentials) 34 return nil 35 } 36 37 // UnmarshalXrd implements xrdproto.Unmarshaler. 38 func (o *Request) UnmarshalXrd(rBuffer *xrdenc.RBuffer) error { 39 rBuffer.Skip(12) 40 rBuffer.ReadBytes(o.Type[:]) 41 o.Credentials = rBuffer.ReadStr() 42 return nil 43 } 44 45 // Auther is the interface that must be implemented by a security provider. 46 type Auther interface { 47 Provider() string // Provider returns the name of the security provider. 48 Request(params []string) (*Request, error) // Request forms an authorization Request according to passed parameters. 49 }