github.com/keybase/client/go@v0.0.0-20241007131713-f10651d043c8/protocol/gregor1/auth.go (about)

     1  // Auto-generated to Go types and interfaces using avdl-compiler v1.4.10 (https://github.com/keybase/node-avdl-compiler)
     2  //   Input file: avdl/gregor1/auth.avdl
     3  
     4  package gregor1
     5  
     6  import (
     7  	"github.com/keybase/go-framed-msgpack-rpc/rpc"
     8  	context "golang.org/x/net/context"
     9  	"time"
    10  )
    11  
    12  type AuthResult struct {
    13  	Uid      UID       `codec:"uid" json:"uid"`
    14  	Username string    `codec:"username" json:"username"`
    15  	Sid      SessionID `codec:"sid" json:"sid"`
    16  	IsAdmin  bool      `codec:"isAdmin" json:"isAdmin"`
    17  }
    18  
    19  func (o AuthResult) DeepCopy() AuthResult {
    20  	return AuthResult{
    21  		Uid:      o.Uid.DeepCopy(),
    22  		Username: o.Username,
    23  		Sid:      o.Sid.DeepCopy(),
    24  		IsAdmin:  o.IsAdmin,
    25  	}
    26  }
    27  
    28  type AuthenticateSessionTokenArg struct {
    29  	Session SessionToken `codec:"session" json:"session"`
    30  }
    31  
    32  type AuthInterface interface {
    33  	AuthenticateSessionToken(context.Context, SessionToken) (AuthResult, error)
    34  }
    35  
    36  func AuthProtocol(i AuthInterface) rpc.Protocol {
    37  	return rpc.Protocol{
    38  		Name: "gregor.1.auth",
    39  		Methods: map[string]rpc.ServeHandlerDescription{
    40  			"authenticateSessionToken": {
    41  				MakeArg: func() interface{} {
    42  					var ret [1]AuthenticateSessionTokenArg
    43  					return &ret
    44  				},
    45  				Handler: func(ctx context.Context, args interface{}) (ret interface{}, err error) {
    46  					typedArgs, ok := args.(*[1]AuthenticateSessionTokenArg)
    47  					if !ok {
    48  						err = rpc.NewTypeError((*[1]AuthenticateSessionTokenArg)(nil), args)
    49  						return
    50  					}
    51  					ret, err = i.AuthenticateSessionToken(ctx, typedArgs[0].Session)
    52  					return
    53  				},
    54  			},
    55  		},
    56  	}
    57  }
    58  
    59  type AuthClient struct {
    60  	Cli rpc.GenericClient
    61  }
    62  
    63  func (c AuthClient) AuthenticateSessionToken(ctx context.Context, session SessionToken) (res AuthResult, err error) {
    64  	__arg := AuthenticateSessionTokenArg{Session: session}
    65  	err = c.Cli.Call(ctx, "gregor.1.auth.authenticateSessionToken", []interface{}{__arg}, &res, 0*time.Millisecond)
    66  	return
    67  }