go.chromium.org/luci@v0.0.0-20240309015107-7cdc2e660f33/common/proto/sidecar/auth_grpc.pb.go (about) 1 // Copyright 2023 The LUCI Authors. 2 // 3 // Licensed under the Apache License, Version 2.0 (the "License"); 4 // you may not use this file except in compliance with the License. 5 // You may obtain a copy of the License at 6 // 7 // http://www.apache.org/licenses/LICENSE-2.0 8 // 9 // Unless required by applicable law or agreed to in writing, software 10 // distributed under the License is distributed on an "AS IS" BASIS, 11 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 // See the License for the specific language governing permissions and 13 // limitations under the License. 14 15 // Code generated by protoc-gen-go-grpc. DO NOT EDIT. 16 // versions: 17 // - protoc-gen-go-grpc v1.3.0 18 // - protoc v3.21.7 19 // source: go.chromium.org/luci/common/proto/sidecar/auth.proto 20 21 package sidecar 22 23 import ( 24 context "context" 25 grpc "google.golang.org/grpc" 26 codes "google.golang.org/grpc/codes" 27 status "google.golang.org/grpc/status" 28 ) 29 30 // This is a compile-time assertion to ensure that this generated file 31 // is compatible with the grpc package it is being compiled against. 32 // Requires gRPC-Go v1.32.0 or later. 33 const _ = grpc.SupportPackageIsVersion7 34 35 const ( 36 Auth_Authenticate_FullMethodName = "/luci.sidecar.Auth/Authenticate" 37 Auth_IsMember_FullMethodName = "/luci.sidecar.Auth/IsMember" 38 Auth_HasPermission_FullMethodName = "/luci.sidecar.Auth/HasPermission" 39 ) 40 41 // AuthClient is the client API for Auth service. 42 // 43 // 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. 44 type AuthClient interface { 45 // Authenticate receives metadata of the incoming call and uses it to 46 // authenticate the caller, i.e. it extracts appropriate credentials and 47 // verifies they are valid. 48 // 49 // Optionally checks if the authenticated identity is a member of groups 50 // given by `groups` request field, returning groups the identity is a member 51 // of in `groups` response field (which will be a subset of groups passed in 52 // the request). This is useful for implementing simple broad group-based 53 // authorization checks skipping extra RPCs. For more flexible checks see 54 // IsMember and HasPermission RPCs. 55 // 56 // Returns: 57 // - OK if the server understood the request and performed the 58 // authentication. The outcome (which can include an error if credentials 59 // are invalid) is available as part of AuthenticateResponse. OK is 60 // returned as well if the request doesn't have credentials attached at 61 // all or they were invalid. In that case AuthenticateResponse contains 62 // `anonymous` or `error` outcomes respectively. 63 // - UNAUTHENTICATED if the call to the sidecar server itself failed due to 64 // invalid (corrupted, expired, etc) RPC credentials, i.e. credentials of 65 // the sidecar client itself, not credentials inside AuthenticateRequest. 66 // This response MUST be presented as INTERNAL error to the end user, 67 // since it indicates some internal misconfiguration between the 68 // application server and the sidecar service, unrelated to credentials 69 // sent by the end-user. 70 // - PERMISSION_DENIED if the call to the sidecar server itself is not 71 // allowed. This response MUST also be presented as INTERNAL error to 72 // the end user. 73 // - INTERNAL on transient internal errors that SHOULD be retried. 74 Authenticate(ctx context.Context, in *AuthenticateRequest, opts ...grpc.CallOption) (*AuthenticateResponse, error) 75 // IsMember checks if an identity belongs to any of the given groups. 76 // 77 // Returns: 78 // - OK with the outcome of the check (which may be negative) if the check 79 // was performed successfully. 80 // - INVALID_ARGUMENT if the request is malformed. 81 // - UNAUTHENTICATED if the call to the sidecar server failed due to invalid 82 // (corrupted, expired, etc) RPC credentials. This response MUST be 83 // presented as INTERNAL error to the end user, since it indicates some 84 // internal misconfiguration between the application server and the 85 // sidecar service. 86 // - PERMISSION_DENIED if the call to the sidecar server itself is not 87 // allowed. This response MUST also be presented as INTERNAL error to 88 // the end user. 89 // - INTERNAL on transient internal errors that SHOULD be retried. 90 IsMember(ctx context.Context, in *IsMemberRequest, opts ...grpc.CallOption) (*IsMemberResponse, error) 91 // HasPermission check if an identity has a permission in a realm. 92 // 93 // Can only check permissions registered when the sidecar server was started 94 // via `-sidecar-subscribe-to-permission` command line flag. Checks for any 95 // other permission will end up with INVALID_ARGUMENT error. 96 // 97 // Returns: 98 // - OK with the outcome of the check (which may be negative) if the check 99 // was performed successfully. 100 // - INVALID_ARGUMENT if the request is malformed or the specified 101 // permission was not registered with the sidecar server via 102 // `-sidecar-subscribe-to-permission` command line flag. 103 // - UNAUTHENTICATED if the call to the sidecar server failed due to invalid 104 // (corrupted, expired, etc) RPC credentials. This response MUST be 105 // presented as INTERNAL error to the end user, since it indicates some 106 // internal misconfiguration between the application server and the 107 // sidecar service. 108 // - PERMISSION_DENIED if the call to the sidecar server itself is not 109 // allowed. This response MUST also be presented as INTERNAL error to 110 // the end user. 111 // - INTERNAL on transient internal errors that SHOULD be retried. 112 HasPermission(ctx context.Context, in *HasPermissionRequest, opts ...grpc.CallOption) (*HasPermissionResponse, error) 113 } 114 115 type authClient struct { 116 cc grpc.ClientConnInterface 117 } 118 119 func NewAuthClient(cc grpc.ClientConnInterface) AuthClient { 120 return &authClient{cc} 121 } 122 123 func (c *authClient) Authenticate(ctx context.Context, in *AuthenticateRequest, opts ...grpc.CallOption) (*AuthenticateResponse, error) { 124 out := new(AuthenticateResponse) 125 err := c.cc.Invoke(ctx, Auth_Authenticate_FullMethodName, in, out, opts...) 126 if err != nil { 127 return nil, err 128 } 129 return out, nil 130 } 131 132 func (c *authClient) IsMember(ctx context.Context, in *IsMemberRequest, opts ...grpc.CallOption) (*IsMemberResponse, error) { 133 out := new(IsMemberResponse) 134 err := c.cc.Invoke(ctx, Auth_IsMember_FullMethodName, in, out, opts...) 135 if err != nil { 136 return nil, err 137 } 138 return out, nil 139 } 140 141 func (c *authClient) HasPermission(ctx context.Context, in *HasPermissionRequest, opts ...grpc.CallOption) (*HasPermissionResponse, error) { 142 out := new(HasPermissionResponse) 143 err := c.cc.Invoke(ctx, Auth_HasPermission_FullMethodName, in, out, opts...) 144 if err != nil { 145 return nil, err 146 } 147 return out, nil 148 } 149 150 // AuthServer is the server API for Auth service. 151 // All implementations must embed UnimplementedAuthServer 152 // for forward compatibility 153 type AuthServer interface { 154 // Authenticate receives metadata of the incoming call and uses it to 155 // authenticate the caller, i.e. it extracts appropriate credentials and 156 // verifies they are valid. 157 // 158 // Optionally checks if the authenticated identity is a member of groups 159 // given by `groups` request field, returning groups the identity is a member 160 // of in `groups` response field (which will be a subset of groups passed in 161 // the request). This is useful for implementing simple broad group-based 162 // authorization checks skipping extra RPCs. For more flexible checks see 163 // IsMember and HasPermission RPCs. 164 // 165 // Returns: 166 // - OK if the server understood the request and performed the 167 // authentication. The outcome (which can include an error if credentials 168 // are invalid) is available as part of AuthenticateResponse. OK is 169 // returned as well if the request doesn't have credentials attached at 170 // all or they were invalid. In that case AuthenticateResponse contains 171 // `anonymous` or `error` outcomes respectively. 172 // - UNAUTHENTICATED if the call to the sidecar server itself failed due to 173 // invalid (corrupted, expired, etc) RPC credentials, i.e. credentials of 174 // the sidecar client itself, not credentials inside AuthenticateRequest. 175 // This response MUST be presented as INTERNAL error to the end user, 176 // since it indicates some internal misconfiguration between the 177 // application server and the sidecar service, unrelated to credentials 178 // sent by the end-user. 179 // - PERMISSION_DENIED if the call to the sidecar server itself is not 180 // allowed. This response MUST also be presented as INTERNAL error to 181 // the end user. 182 // - INTERNAL on transient internal errors that SHOULD be retried. 183 Authenticate(context.Context, *AuthenticateRequest) (*AuthenticateResponse, error) 184 // IsMember checks if an identity belongs to any of the given groups. 185 // 186 // Returns: 187 // - OK with the outcome of the check (which may be negative) if the check 188 // was performed successfully. 189 // - INVALID_ARGUMENT if the request is malformed. 190 // - UNAUTHENTICATED if the call to the sidecar server failed due to invalid 191 // (corrupted, expired, etc) RPC credentials. This response MUST be 192 // presented as INTERNAL error to the end user, since it indicates some 193 // internal misconfiguration between the application server and the 194 // sidecar service. 195 // - PERMISSION_DENIED if the call to the sidecar server itself is not 196 // allowed. This response MUST also be presented as INTERNAL error to 197 // the end user. 198 // - INTERNAL on transient internal errors that SHOULD be retried. 199 IsMember(context.Context, *IsMemberRequest) (*IsMemberResponse, error) 200 // HasPermission check if an identity has a permission in a realm. 201 // 202 // Can only check permissions registered when the sidecar server was started 203 // via `-sidecar-subscribe-to-permission` command line flag. Checks for any 204 // other permission will end up with INVALID_ARGUMENT error. 205 // 206 // Returns: 207 // - OK with the outcome of the check (which may be negative) if the check 208 // was performed successfully. 209 // - INVALID_ARGUMENT if the request is malformed or the specified 210 // permission was not registered with the sidecar server via 211 // `-sidecar-subscribe-to-permission` command line flag. 212 // - UNAUTHENTICATED if the call to the sidecar server failed due to invalid 213 // (corrupted, expired, etc) RPC credentials. This response MUST be 214 // presented as INTERNAL error to the end user, since it indicates some 215 // internal misconfiguration between the application server and the 216 // sidecar service. 217 // - PERMISSION_DENIED if the call to the sidecar server itself is not 218 // allowed. This response MUST also be presented as INTERNAL error to 219 // the end user. 220 // - INTERNAL on transient internal errors that SHOULD be retried. 221 HasPermission(context.Context, *HasPermissionRequest) (*HasPermissionResponse, error) 222 mustEmbedUnimplementedAuthServer() 223 } 224 225 // UnimplementedAuthServer must be embedded to have forward compatible implementations. 226 type UnimplementedAuthServer struct { 227 } 228 229 func (UnimplementedAuthServer) Authenticate(context.Context, *AuthenticateRequest) (*AuthenticateResponse, error) { 230 return nil, status.Errorf(codes.Unimplemented, "method Authenticate not implemented") 231 } 232 func (UnimplementedAuthServer) IsMember(context.Context, *IsMemberRequest) (*IsMemberResponse, error) { 233 return nil, status.Errorf(codes.Unimplemented, "method IsMember not implemented") 234 } 235 func (UnimplementedAuthServer) HasPermission(context.Context, *HasPermissionRequest) (*HasPermissionResponse, error) { 236 return nil, status.Errorf(codes.Unimplemented, "method HasPermission not implemented") 237 } 238 func (UnimplementedAuthServer) mustEmbedUnimplementedAuthServer() {} 239 240 // UnsafeAuthServer may be embedded to opt out of forward compatibility for this service. 241 // Use of this interface is not recommended, as added methods to AuthServer will 242 // result in compilation errors. 243 type UnsafeAuthServer interface { 244 mustEmbedUnimplementedAuthServer() 245 } 246 247 func RegisterAuthServer(s grpc.ServiceRegistrar, srv AuthServer) { 248 s.RegisterService(&Auth_ServiceDesc, srv) 249 } 250 251 func _Auth_Authenticate_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { 252 in := new(AuthenticateRequest) 253 if err := dec(in); err != nil { 254 return nil, err 255 } 256 if interceptor == nil { 257 return srv.(AuthServer).Authenticate(ctx, in) 258 } 259 info := &grpc.UnaryServerInfo{ 260 Server: srv, 261 FullMethod: Auth_Authenticate_FullMethodName, 262 } 263 handler := func(ctx context.Context, req interface{}) (interface{}, error) { 264 return srv.(AuthServer).Authenticate(ctx, req.(*AuthenticateRequest)) 265 } 266 return interceptor(ctx, in, info, handler) 267 } 268 269 func _Auth_IsMember_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { 270 in := new(IsMemberRequest) 271 if err := dec(in); err != nil { 272 return nil, err 273 } 274 if interceptor == nil { 275 return srv.(AuthServer).IsMember(ctx, in) 276 } 277 info := &grpc.UnaryServerInfo{ 278 Server: srv, 279 FullMethod: Auth_IsMember_FullMethodName, 280 } 281 handler := func(ctx context.Context, req interface{}) (interface{}, error) { 282 return srv.(AuthServer).IsMember(ctx, req.(*IsMemberRequest)) 283 } 284 return interceptor(ctx, in, info, handler) 285 } 286 287 func _Auth_HasPermission_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { 288 in := new(HasPermissionRequest) 289 if err := dec(in); err != nil { 290 return nil, err 291 } 292 if interceptor == nil { 293 return srv.(AuthServer).HasPermission(ctx, in) 294 } 295 info := &grpc.UnaryServerInfo{ 296 Server: srv, 297 FullMethod: Auth_HasPermission_FullMethodName, 298 } 299 handler := func(ctx context.Context, req interface{}) (interface{}, error) { 300 return srv.(AuthServer).HasPermission(ctx, req.(*HasPermissionRequest)) 301 } 302 return interceptor(ctx, in, info, handler) 303 } 304 305 // Auth_ServiceDesc is the grpc.ServiceDesc for Auth service. 306 // It's only intended for direct use with grpc.RegisterService, 307 // and not to be introspected or modified (even as a copy) 308 var Auth_ServiceDesc = grpc.ServiceDesc{ 309 ServiceName: "luci.sidecar.Auth", 310 HandlerType: (*AuthServer)(nil), 311 Methods: []grpc.MethodDesc{ 312 { 313 MethodName: "Authenticate", 314 Handler: _Auth_Authenticate_Handler, 315 }, 316 { 317 MethodName: "IsMember", 318 Handler: _Auth_IsMember_Handler, 319 }, 320 { 321 MethodName: "HasPermission", 322 Handler: _Auth_HasPermission_Handler, 323 }, 324 }, 325 Streams: []grpc.StreamDesc{}, 326 Metadata: "go.chromium.org/luci/common/proto/sidecar/auth.proto", 327 }