go.chromium.org/luci@v0.0.0-20250314024836-d9a61d0730e6/tokenserver/api/minter/v1/token_minter_grpc.pb.go (about)

     1  // Copyright 2016 The LUCI Authors. All rights reserved.
     2  // Use of this source code is governed under the Apache License, Version 2.0
     3  // that can be found in the LICENSE file.
     4  
     5  // Code generated by protoc-gen-go-grpc. DO NOT EDIT.
     6  // versions:
     7  // - protoc-gen-go-grpc v1.5.1
     8  // - protoc             v5.29.3
     9  // source: go.chromium.org/luci/tokenserver/api/minter/v1/token_minter.proto
    10  
    11  package minter
    12  
    13  import (
    14  	context "context"
    15  	grpc "google.golang.org/grpc"
    16  	codes "google.golang.org/grpc/codes"
    17  	status "google.golang.org/grpc/status"
    18  )
    19  
    20  // This is a compile-time assertion to ensure that this generated file
    21  // is compatible with the grpc package it is being compiled against.
    22  // Requires gRPC-Go v1.64.0 or later.
    23  const _ = grpc.SupportPackageIsVersion9
    24  
    25  const (
    26  	TokenMinter_MintMachineToken_FullMethodName        = "/tokenserver.minter.TokenMinter/MintMachineToken"
    27  	TokenMinter_MintDelegationToken_FullMethodName     = "/tokenserver.minter.TokenMinter/MintDelegationToken"
    28  	TokenMinter_MintProjectToken_FullMethodName        = "/tokenserver.minter.TokenMinter/MintProjectToken"
    29  	TokenMinter_MintServiceAccountToken_FullMethodName = "/tokenserver.minter.TokenMinter/MintServiceAccountToken"
    30  )
    31  
    32  // TokenMinterClient is the client API for TokenMinter service.
    33  //
    34  // For semantics around ctx use and closing/ending streaming RPCs, please refer to https://pkg.go.dev/google.golang.org/grpc/?tab=doc#ClientConn.NewStream.
    35  //
    36  // TokenMinter implements main API of the token server.
    37  //
    38  // It provides an interface for generating:
    39  //
    40  //   - Machine tokens: short lived stateless tokens used in Swarming bot
    41  //     authentication protocol. They are derived from PKI keys deployed on bots,
    42  //     and consumed primarily by Swarming. See MintMachineToken.
    43  //   - Delegation tokens: these are involved whenever a service calls other
    44  //     service on behalf of a user. They are passed via 'X-Delegation-Token-V1'
    45  //     HTTP header along with a credentials of the impersonating user.
    46  //     See MintDelegationToken.
    47  //   - OAuth2 access tokens of project-scoped accounts: these are OAuth2 access
    48  //     tokens that represents an identity associated with a LUCI project. See
    49  //     MintProjectToken.
    50  //   - Service accounts tokens: these are OAuth2 access tokens and ID tokens of
    51  //     service accounts "residing" within various LUCI projects. They are
    52  //     ultimately used by LUCI tasks as task service accounts.
    53  //     See MintServiceAccountToken.
    54  //
    55  // RPCs that were deprecated and removed:
    56  //
    57  //   - MintOAuthTokenGrant and MintOAuthTokenViaGrant: were deprecated by
    58  //     MintServiceAccountToken. Used (also now removed) service_accounts.cfg
    59  //     config file.
    60  type TokenMinterClient interface {
    61  	// MintMachineToken generates a new token for an authenticated machine.
    62  	//
    63  	// It checks that provided certificate was signed by some trusted CA, and it
    64  	// is still valid (non-expired and hasn't been revoked). It then checks that
    65  	// the request was signed by the corresponding private key. Finally it checks
    66  	// that the caller is authorized to generate requested kind of token.
    67  	//
    68  	// If everything checks out, it generates and returns a new machine token.
    69  	//
    70  	// On fatal error it returns detailed error response via same
    71  	// MintMachineTokenResponse. On transient errors it returns generic
    72  	// grpc.Internal error.
    73  	MintMachineToken(ctx context.Context, in *MintMachineTokenRequest, opts ...grpc.CallOption) (*MintMachineTokenResponse, error)
    74  	// MintDelegationToken generates a new bearer delegation token.
    75  	//
    76  	// Such token can be sent in 'X-Delegation-Token-V1' header (alongside regular
    77  	// credentials like OAuth2 access token) to convey that the caller should be
    78  	// authentication as 'delegated_identity' specified in the token.
    79  	//
    80  	// The delegation tokens are subject to multiple restrictions (embedded in
    81  	// the token):
    82  	//   - They have expiration time.
    83  	//   - They are usable only if presented with a credential of someone from
    84  	//     the 'audience' list.
    85  	//   - They are usable only on services specified in the 'services' list.
    86  	//
    87  	// The token server must be configured in advance with all expected
    88  	// combinations of (caller identity, delegated identity, audience, service)
    89  	// tuples. See DelegationRule in config.proto.
    90  	MintDelegationToken(ctx context.Context, in *MintDelegationTokenRequest, opts ...grpc.CallOption) (*MintDelegationTokenResponse, error)
    91  	// MintProjectToken mints an OAuth2 access token that represents an identity
    92  	// associated with a LUCI project.
    93  	//
    94  	// Project-scoped tokens prevent accidental cross-project identity confusion
    95  	// when LUCI services access project specific resources such as a source code
    96  	// repository.
    97  	MintProjectToken(ctx context.Context, in *MintProjectTokenRequest, opts ...grpc.CallOption) (*MintProjectTokenResponse, error)
    98  	// MintServiceAccountToken mints an OAuth2 access token or OpenID ID token
    99  	// that belongs to some service account using LUCI Realms for authorization.
   100  	//
   101  	// As an input it takes a service account email and a name of a LUCI Realm the
   102  	// caller is operating in. To authorize the call the token server checks the
   103  	// following conditions:
   104  	//  1. The caller has luci.serviceAccounts.mintToken permission in the
   105  	//     realm, allowing them to "impersonate" all service accounts belonging
   106  	//     to this realm.
   107  	//  2. The service account has luci.serviceAccounts.existInRealm permission
   108  	//     in the realm. This makes the account "belong" to the realm.
   109  	//  3. Realm's LUCI project is allowed to impersonate this service account:
   110  	//     a. Legacy approach being deprecated: realm's LUCI project is NOT listed
   111  	//     in `use_project_scoped_account` set in project_owned_accounts.cfg
   112  	//     global config file, but it has service accounts associated with it
   113  	//     there via `mapping` field. In that case LUCI Token Server will check
   114  	//     `mapping` and then use its own service account when minting tokens.
   115  	//     b. New approach being rolled out: realm's LUCI project is listed in
   116  	//     `use_project_scoped_account` set in project_owned_accounts.cfg
   117  	//     global config file. In that case LUCI Token Server will use
   118  	//     project-scoped account associated with this LUCI project when
   119  	//     minting service account tokens. This essentially shifts mapping
   120  	//     between LUCI projects and service accounts they can use into
   121  	//     service account IAM policies.
   122  	//
   123  	// Check (3) makes sure different LUCI projects can't arbitrarily use each
   124  	// others accounts by adding them to their respective realms.cfg. See also
   125  	// comments for ServiceAccountsProjectMapping in api/admin/v1/config.proto.
   126  	MintServiceAccountToken(ctx context.Context, in *MintServiceAccountTokenRequest, opts ...grpc.CallOption) (*MintServiceAccountTokenResponse, error)
   127  }
   128  
   129  type tokenMinterClient struct {
   130  	cc grpc.ClientConnInterface
   131  }
   132  
   133  func NewTokenMinterClient(cc grpc.ClientConnInterface) TokenMinterClient {
   134  	return &tokenMinterClient{cc}
   135  }
   136  
   137  func (c *tokenMinterClient) MintMachineToken(ctx context.Context, in *MintMachineTokenRequest, opts ...grpc.CallOption) (*MintMachineTokenResponse, error) {
   138  	cOpts := append([]grpc.CallOption{grpc.StaticMethod()}, opts...)
   139  	out := new(MintMachineTokenResponse)
   140  	err := c.cc.Invoke(ctx, TokenMinter_MintMachineToken_FullMethodName, in, out, cOpts...)
   141  	if err != nil {
   142  		return nil, err
   143  	}
   144  	return out, nil
   145  }
   146  
   147  func (c *tokenMinterClient) MintDelegationToken(ctx context.Context, in *MintDelegationTokenRequest, opts ...grpc.CallOption) (*MintDelegationTokenResponse, error) {
   148  	cOpts := append([]grpc.CallOption{grpc.StaticMethod()}, opts...)
   149  	out := new(MintDelegationTokenResponse)
   150  	err := c.cc.Invoke(ctx, TokenMinter_MintDelegationToken_FullMethodName, in, out, cOpts...)
   151  	if err != nil {
   152  		return nil, err
   153  	}
   154  	return out, nil
   155  }
   156  
   157  func (c *tokenMinterClient) MintProjectToken(ctx context.Context, in *MintProjectTokenRequest, opts ...grpc.CallOption) (*MintProjectTokenResponse, error) {
   158  	cOpts := append([]grpc.CallOption{grpc.StaticMethod()}, opts...)
   159  	out := new(MintProjectTokenResponse)
   160  	err := c.cc.Invoke(ctx, TokenMinter_MintProjectToken_FullMethodName, in, out, cOpts...)
   161  	if err != nil {
   162  		return nil, err
   163  	}
   164  	return out, nil
   165  }
   166  
   167  func (c *tokenMinterClient) MintServiceAccountToken(ctx context.Context, in *MintServiceAccountTokenRequest, opts ...grpc.CallOption) (*MintServiceAccountTokenResponse, error) {
   168  	cOpts := append([]grpc.CallOption{grpc.StaticMethod()}, opts...)
   169  	out := new(MintServiceAccountTokenResponse)
   170  	err := c.cc.Invoke(ctx, TokenMinter_MintServiceAccountToken_FullMethodName, in, out, cOpts...)
   171  	if err != nil {
   172  		return nil, err
   173  	}
   174  	return out, nil
   175  }
   176  
   177  // TokenMinterServer is the server API for TokenMinter service.
   178  // All implementations must embed UnimplementedTokenMinterServer
   179  // for forward compatibility.
   180  //
   181  // TokenMinter implements main API of the token server.
   182  //
   183  // It provides an interface for generating:
   184  //
   185  //   - Machine tokens: short lived stateless tokens used in Swarming bot
   186  //     authentication protocol. They are derived from PKI keys deployed on bots,
   187  //     and consumed primarily by Swarming. See MintMachineToken.
   188  //   - Delegation tokens: these are involved whenever a service calls other
   189  //     service on behalf of a user. They are passed via 'X-Delegation-Token-V1'
   190  //     HTTP header along with a credentials of the impersonating user.
   191  //     See MintDelegationToken.
   192  //   - OAuth2 access tokens of project-scoped accounts: these are OAuth2 access
   193  //     tokens that represents an identity associated with a LUCI project. See
   194  //     MintProjectToken.
   195  //   - Service accounts tokens: these are OAuth2 access tokens and ID tokens of
   196  //     service accounts "residing" within various LUCI projects. They are
   197  //     ultimately used by LUCI tasks as task service accounts.
   198  //     See MintServiceAccountToken.
   199  //
   200  // RPCs that were deprecated and removed:
   201  //
   202  //   - MintOAuthTokenGrant and MintOAuthTokenViaGrant: were deprecated by
   203  //     MintServiceAccountToken. Used (also now removed) service_accounts.cfg
   204  //     config file.
   205  type TokenMinterServer interface {
   206  	// MintMachineToken generates a new token for an authenticated machine.
   207  	//
   208  	// It checks that provided certificate was signed by some trusted CA, and it
   209  	// is still valid (non-expired and hasn't been revoked). It then checks that
   210  	// the request was signed by the corresponding private key. Finally it checks
   211  	// that the caller is authorized to generate requested kind of token.
   212  	//
   213  	// If everything checks out, it generates and returns a new machine token.
   214  	//
   215  	// On fatal error it returns detailed error response via same
   216  	// MintMachineTokenResponse. On transient errors it returns generic
   217  	// grpc.Internal error.
   218  	MintMachineToken(context.Context, *MintMachineTokenRequest) (*MintMachineTokenResponse, error)
   219  	// MintDelegationToken generates a new bearer delegation token.
   220  	//
   221  	// Such token can be sent in 'X-Delegation-Token-V1' header (alongside regular
   222  	// credentials like OAuth2 access token) to convey that the caller should be
   223  	// authentication as 'delegated_identity' specified in the token.
   224  	//
   225  	// The delegation tokens are subject to multiple restrictions (embedded in
   226  	// the token):
   227  	//   - They have expiration time.
   228  	//   - They are usable only if presented with a credential of someone from
   229  	//     the 'audience' list.
   230  	//   - They are usable only on services specified in the 'services' list.
   231  	//
   232  	// The token server must be configured in advance with all expected
   233  	// combinations of (caller identity, delegated identity, audience, service)
   234  	// tuples. See DelegationRule in config.proto.
   235  	MintDelegationToken(context.Context, *MintDelegationTokenRequest) (*MintDelegationTokenResponse, error)
   236  	// MintProjectToken mints an OAuth2 access token that represents an identity
   237  	// associated with a LUCI project.
   238  	//
   239  	// Project-scoped tokens prevent accidental cross-project identity confusion
   240  	// when LUCI services access project specific resources such as a source code
   241  	// repository.
   242  	MintProjectToken(context.Context, *MintProjectTokenRequest) (*MintProjectTokenResponse, error)
   243  	// MintServiceAccountToken mints an OAuth2 access token or OpenID ID token
   244  	// that belongs to some service account using LUCI Realms for authorization.
   245  	//
   246  	// As an input it takes a service account email and a name of a LUCI Realm the
   247  	// caller is operating in. To authorize the call the token server checks the
   248  	// following conditions:
   249  	//  1. The caller has luci.serviceAccounts.mintToken permission in the
   250  	//     realm, allowing them to "impersonate" all service accounts belonging
   251  	//     to this realm.
   252  	//  2. The service account has luci.serviceAccounts.existInRealm permission
   253  	//     in the realm. This makes the account "belong" to the realm.
   254  	//  3. Realm's LUCI project is allowed to impersonate this service account:
   255  	//     a. Legacy approach being deprecated: realm's LUCI project is NOT listed
   256  	//     in `use_project_scoped_account` set in project_owned_accounts.cfg
   257  	//     global config file, but it has service accounts associated with it
   258  	//     there via `mapping` field. In that case LUCI Token Server will check
   259  	//     `mapping` and then use its own service account when minting tokens.
   260  	//     b. New approach being rolled out: realm's LUCI project is listed in
   261  	//     `use_project_scoped_account` set in project_owned_accounts.cfg
   262  	//     global config file. In that case LUCI Token Server will use
   263  	//     project-scoped account associated with this LUCI project when
   264  	//     minting service account tokens. This essentially shifts mapping
   265  	//     between LUCI projects and service accounts they can use into
   266  	//     service account IAM policies.
   267  	//
   268  	// Check (3) makes sure different LUCI projects can't arbitrarily use each
   269  	// others accounts by adding them to their respective realms.cfg. See also
   270  	// comments for ServiceAccountsProjectMapping in api/admin/v1/config.proto.
   271  	MintServiceAccountToken(context.Context, *MintServiceAccountTokenRequest) (*MintServiceAccountTokenResponse, error)
   272  	mustEmbedUnimplementedTokenMinterServer()
   273  }
   274  
   275  // UnimplementedTokenMinterServer must be embedded to have
   276  // forward compatible implementations.
   277  //
   278  // NOTE: this should be embedded by value instead of pointer to avoid a nil
   279  // pointer dereference when methods are called.
   280  type UnimplementedTokenMinterServer struct{}
   281  
   282  func (UnimplementedTokenMinterServer) MintMachineToken(context.Context, *MintMachineTokenRequest) (*MintMachineTokenResponse, error) {
   283  	return nil, status.Errorf(codes.Unimplemented, "method MintMachineToken not implemented")
   284  }
   285  func (UnimplementedTokenMinterServer) MintDelegationToken(context.Context, *MintDelegationTokenRequest) (*MintDelegationTokenResponse, error) {
   286  	return nil, status.Errorf(codes.Unimplemented, "method MintDelegationToken not implemented")
   287  }
   288  func (UnimplementedTokenMinterServer) MintProjectToken(context.Context, *MintProjectTokenRequest) (*MintProjectTokenResponse, error) {
   289  	return nil, status.Errorf(codes.Unimplemented, "method MintProjectToken not implemented")
   290  }
   291  func (UnimplementedTokenMinterServer) MintServiceAccountToken(context.Context, *MintServiceAccountTokenRequest) (*MintServiceAccountTokenResponse, error) {
   292  	return nil, status.Errorf(codes.Unimplemented, "method MintServiceAccountToken not implemented")
   293  }
   294  func (UnimplementedTokenMinterServer) mustEmbedUnimplementedTokenMinterServer() {}
   295  func (UnimplementedTokenMinterServer) testEmbeddedByValue()                     {}
   296  
   297  // UnsafeTokenMinterServer may be embedded to opt out of forward compatibility for this service.
   298  // Use of this interface is not recommended, as added methods to TokenMinterServer will
   299  // result in compilation errors.
   300  type UnsafeTokenMinterServer interface {
   301  	mustEmbedUnimplementedTokenMinterServer()
   302  }
   303  
   304  func RegisterTokenMinterServer(s grpc.ServiceRegistrar, srv TokenMinterServer) {
   305  	// If the following call pancis, it indicates UnimplementedTokenMinterServer was
   306  	// embedded by pointer and is nil.  This will cause panics if an
   307  	// unimplemented method is ever invoked, so we test this at initialization
   308  	// time to prevent it from happening at runtime later due to I/O.
   309  	if t, ok := srv.(interface{ testEmbeddedByValue() }); ok {
   310  		t.testEmbeddedByValue()
   311  	}
   312  	s.RegisterService(&TokenMinter_ServiceDesc, srv)
   313  }
   314  
   315  func _TokenMinter_MintMachineToken_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) {
   316  	in := new(MintMachineTokenRequest)
   317  	if err := dec(in); err != nil {
   318  		return nil, err
   319  	}
   320  	if interceptor == nil {
   321  		return srv.(TokenMinterServer).MintMachineToken(ctx, in)
   322  	}
   323  	info := &grpc.UnaryServerInfo{
   324  		Server:     srv,
   325  		FullMethod: TokenMinter_MintMachineToken_FullMethodName,
   326  	}
   327  	handler := func(ctx context.Context, req interface{}) (interface{}, error) {
   328  		return srv.(TokenMinterServer).MintMachineToken(ctx, req.(*MintMachineTokenRequest))
   329  	}
   330  	return interceptor(ctx, in, info, handler)
   331  }
   332  
   333  func _TokenMinter_MintDelegationToken_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) {
   334  	in := new(MintDelegationTokenRequest)
   335  	if err := dec(in); err != nil {
   336  		return nil, err
   337  	}
   338  	if interceptor == nil {
   339  		return srv.(TokenMinterServer).MintDelegationToken(ctx, in)
   340  	}
   341  	info := &grpc.UnaryServerInfo{
   342  		Server:     srv,
   343  		FullMethod: TokenMinter_MintDelegationToken_FullMethodName,
   344  	}
   345  	handler := func(ctx context.Context, req interface{}) (interface{}, error) {
   346  		return srv.(TokenMinterServer).MintDelegationToken(ctx, req.(*MintDelegationTokenRequest))
   347  	}
   348  	return interceptor(ctx, in, info, handler)
   349  }
   350  
   351  func _TokenMinter_MintProjectToken_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) {
   352  	in := new(MintProjectTokenRequest)
   353  	if err := dec(in); err != nil {
   354  		return nil, err
   355  	}
   356  	if interceptor == nil {
   357  		return srv.(TokenMinterServer).MintProjectToken(ctx, in)
   358  	}
   359  	info := &grpc.UnaryServerInfo{
   360  		Server:     srv,
   361  		FullMethod: TokenMinter_MintProjectToken_FullMethodName,
   362  	}
   363  	handler := func(ctx context.Context, req interface{}) (interface{}, error) {
   364  		return srv.(TokenMinterServer).MintProjectToken(ctx, req.(*MintProjectTokenRequest))
   365  	}
   366  	return interceptor(ctx, in, info, handler)
   367  }
   368  
   369  func _TokenMinter_MintServiceAccountToken_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) {
   370  	in := new(MintServiceAccountTokenRequest)
   371  	if err := dec(in); err != nil {
   372  		return nil, err
   373  	}
   374  	if interceptor == nil {
   375  		return srv.(TokenMinterServer).MintServiceAccountToken(ctx, in)
   376  	}
   377  	info := &grpc.UnaryServerInfo{
   378  		Server:     srv,
   379  		FullMethod: TokenMinter_MintServiceAccountToken_FullMethodName,
   380  	}
   381  	handler := func(ctx context.Context, req interface{}) (interface{}, error) {
   382  		return srv.(TokenMinterServer).MintServiceAccountToken(ctx, req.(*MintServiceAccountTokenRequest))
   383  	}
   384  	return interceptor(ctx, in, info, handler)
   385  }
   386  
   387  // TokenMinter_ServiceDesc is the grpc.ServiceDesc for TokenMinter service.
   388  // It's only intended for direct use with grpc.RegisterService,
   389  // and not to be introspected or modified (even as a copy)
   390  var TokenMinter_ServiceDesc = grpc.ServiceDesc{
   391  	ServiceName: "tokenserver.minter.TokenMinter",
   392  	HandlerType: (*TokenMinterServer)(nil),
   393  	Methods: []grpc.MethodDesc{
   394  		{
   395  			MethodName: "MintMachineToken",
   396  			Handler:    _TokenMinter_MintMachineToken_Handler,
   397  		},
   398  		{
   399  			MethodName: "MintDelegationToken",
   400  			Handler:    _TokenMinter_MintDelegationToken_Handler,
   401  		},
   402  		{
   403  			MethodName: "MintProjectToken",
   404  			Handler:    _TokenMinter_MintProjectToken_Handler,
   405  		},
   406  		{
   407  			MethodName: "MintServiceAccountToken",
   408  			Handler:    _TokenMinter_MintServiceAccountToken_Handler,
   409  		},
   410  	},
   411  	Streams:  []grpc.StreamDesc{},
   412  	Metadata: "go.chromium.org/luci/tokenserver/api/minter/v1/token_minter.proto",
   413  }