mirror of
https://github.com/hanzoai/ca.git
synced 2026-11-03 18:08:27 +00:00
386 lines
13 KiB
Go
386 lines
13 KiB
Go
// Code generated by protoc-gen-go-proxy. DO NOT EDIT.
|
|
// source: auth.proto
|
|
|
|
package proxypb
|
|
|
|
import (
|
|
"context"
|
|
|
|
"github.com/effective-security/porto/pkg/retriable"
|
|
"github.com/effective-security/porto/xhttp/correlation"
|
|
"github.com/effective-security/porto/xhttp/httperror"
|
|
"github.com/effective-security/trustyca/api/pb"
|
|
"google.golang.org/grpc"
|
|
"google.golang.org/protobuf/types/known/emptypb"
|
|
)
|
|
|
|
type proxyAuthServer struct {
|
|
srv pb.AuthServer
|
|
}
|
|
|
|
type proxyAuthClient struct {
|
|
remote pb.AuthClient
|
|
callOpts []grpc.CallOption
|
|
}
|
|
|
|
type postproxyAuthClient struct {
|
|
client retriable.PostRequester
|
|
}
|
|
|
|
// AuthServerToClient returns pb.AuthClient
|
|
func AuthServerToClient(srv pb.AuthServer) pb.AuthClient {
|
|
return &proxyAuthServer{srv}
|
|
}
|
|
|
|
// NewAuthClient returns instance of the AuthClient
|
|
func NewAuthClient(conn *grpc.ClientConn, callOpts []grpc.CallOption) pb.AuthServer {
|
|
return &proxyAuthClient{
|
|
remote: pb.NewAuthClient(conn),
|
|
callOpts: callOpts,
|
|
}
|
|
}
|
|
|
|
// NewAuthClientFromProxy returns instance of AuthClient
|
|
func NewAuthClientFromProxy(proxy pb.AuthClient) pb.AuthServer {
|
|
return &proxyAuthClient{
|
|
remote: proxy,
|
|
}
|
|
}
|
|
|
|
// NewAuthClientFromProxy returns instance of AuthClient
|
|
func NewHTTPAuthClient(client retriable.PostRequester) pb.AuthServer {
|
|
return &postproxyAuthClient{
|
|
client: client,
|
|
}
|
|
}
|
|
|
|
// GetProviders returns the list of supported providers
|
|
func (s *proxyAuthServer) GetProviders(ctx context.Context, req *pb.AuthProvidersRequest, opts ...grpc.CallOption) (*pb.AuthProvidersResponse, error) {
|
|
// add correlation ID to outgoing RPC calls
|
|
ctx = correlation.WithMetaFromContext(ctx)
|
|
res, err := s.srv.GetProviders(ctx, req)
|
|
if err != nil {
|
|
return nil, httperror.NewFromPb(err)
|
|
}
|
|
return res, nil
|
|
}
|
|
|
|
// GetProviders returns the list of supported providers
|
|
func (s *proxyAuthClient) GetProviders(ctx context.Context, req *pb.AuthProvidersRequest) (*pb.AuthProvidersResponse, error) {
|
|
// add correlation ID to outgoing RPC calls
|
|
ctx = correlation.WithMetaFromContext(ctx)
|
|
res, err := s.remote.GetProviders(ctx, req, s.callOpts...)
|
|
if err != nil {
|
|
return nil, httperror.NewFromPb(err)
|
|
}
|
|
return res, nil
|
|
}
|
|
|
|
// GetProviders returns the list of supported providers
|
|
func (s *postproxyAuthClient) GetProviders(ctx context.Context, req *pb.AuthProvidersRequest) (*pb.AuthProvidersResponse, error) {
|
|
var res pb.AuthProvidersResponse
|
|
path := pb.Auth_GetProviders_FullMethodName
|
|
_, _, err := s.client.Post(ctx, path, req, &res)
|
|
if err != nil {
|
|
return nil, err
|
|
}
|
|
return &res, nil
|
|
}
|
|
|
|
// GetUserToken returns the user token info
|
|
func (s *proxyAuthServer) GetUserToken(ctx context.Context, req *emptypb.Empty, opts ...grpc.CallOption) (*pb.UserTokenResponse, error) {
|
|
// add correlation ID to outgoing RPC calls
|
|
ctx = correlation.WithMetaFromContext(ctx)
|
|
res, err := s.srv.GetUserToken(ctx, req)
|
|
if err != nil {
|
|
return nil, httperror.NewFromPb(err)
|
|
}
|
|
return res, nil
|
|
}
|
|
|
|
// GetUserToken returns the user token info
|
|
func (s *proxyAuthClient) GetUserToken(ctx context.Context, req *emptypb.Empty) (*pb.UserTokenResponse, error) {
|
|
// add correlation ID to outgoing RPC calls
|
|
ctx = correlation.WithMetaFromContext(ctx)
|
|
res, err := s.remote.GetUserToken(ctx, req, s.callOpts...)
|
|
if err != nil {
|
|
return nil, httperror.NewFromPb(err)
|
|
}
|
|
return res, nil
|
|
}
|
|
|
|
// GetUserToken returns the user token info
|
|
func (s *postproxyAuthClient) GetUserToken(ctx context.Context, req *emptypb.Empty) (*pb.UserTokenResponse, error) {
|
|
var res pb.UserTokenResponse
|
|
path := pb.Auth_GetUserToken_FullMethodName
|
|
_, _, err := s.client.Post(ctx, path, req, &res)
|
|
if err != nil {
|
|
return nil, err
|
|
}
|
|
return &res, nil
|
|
}
|
|
|
|
// RevokeToken revokes the user token
|
|
func (s *proxyAuthServer) RevokeToken(ctx context.Context, req *emptypb.Empty, opts ...grpc.CallOption) (*emptypb.Empty, error) {
|
|
// add correlation ID to outgoing RPC calls
|
|
ctx = correlation.WithMetaFromContext(ctx)
|
|
res, err := s.srv.RevokeToken(ctx, req)
|
|
if err != nil {
|
|
return nil, httperror.NewFromPb(err)
|
|
}
|
|
return res, nil
|
|
}
|
|
|
|
// RevokeToken revokes the user token
|
|
func (s *proxyAuthClient) RevokeToken(ctx context.Context, req *emptypb.Empty) (*emptypb.Empty, error) {
|
|
// add correlation ID to outgoing RPC calls
|
|
ctx = correlation.WithMetaFromContext(ctx)
|
|
res, err := s.remote.RevokeToken(ctx, req, s.callOpts...)
|
|
if err != nil {
|
|
return nil, httperror.NewFromPb(err)
|
|
}
|
|
return res, nil
|
|
}
|
|
|
|
// RevokeToken revokes the user token
|
|
func (s *postproxyAuthClient) RevokeToken(ctx context.Context, req *emptypb.Empty) (*emptypb.Empty, error) {
|
|
var res emptypb.Empty
|
|
path := pb.Auth_RevokeToken_FullMethodName
|
|
_, _, err := s.client.Post(ctx, path, req, &res)
|
|
if err != nil {
|
|
return nil, err
|
|
}
|
|
return &res, nil
|
|
}
|
|
|
|
// Caller returns the caller status.
|
|
func (s *proxyAuthServer) Caller(ctx context.Context, req *emptypb.Empty, opts ...grpc.CallOption) (*pb.CallerStatusResponse, error) {
|
|
// add correlation ID to outgoing RPC calls
|
|
ctx = correlation.WithMetaFromContext(ctx)
|
|
res, err := s.srv.Caller(ctx, req)
|
|
if err != nil {
|
|
return nil, httperror.NewFromPb(err)
|
|
}
|
|
return res, nil
|
|
}
|
|
|
|
// Caller returns the caller status.
|
|
func (s *proxyAuthClient) Caller(ctx context.Context, req *emptypb.Empty) (*pb.CallerStatusResponse, error) {
|
|
// add correlation ID to outgoing RPC calls
|
|
ctx = correlation.WithMetaFromContext(ctx)
|
|
res, err := s.remote.Caller(ctx, req, s.callOpts...)
|
|
if err != nil {
|
|
return nil, httperror.NewFromPb(err)
|
|
}
|
|
return res, nil
|
|
}
|
|
|
|
// Caller returns the caller status.
|
|
func (s *postproxyAuthClient) Caller(ctx context.Context, req *emptypb.Empty) (*pb.CallerStatusResponse, error) {
|
|
var res pb.CallerStatusResponse
|
|
path := pb.Auth_Caller_FullMethodName
|
|
_, _, err := s.client.Post(ctx, path, req, &res)
|
|
if err != nil {
|
|
return nil, err
|
|
}
|
|
return &res, nil
|
|
}
|
|
|
|
// ExchangeCode exchanges the one-time code for a token.
|
|
// The returned token only contains the Access Token.
|
|
// The client should call GetUserToken for full info.
|
|
func (s *proxyAuthServer) ExchangeCode(ctx context.Context, req *pb.ExchangeCodeRequest, opts ...grpc.CallOption) (*pb.Token, error) {
|
|
// add correlation ID to outgoing RPC calls
|
|
ctx = correlation.WithMetaFromContext(ctx)
|
|
res, err := s.srv.ExchangeCode(ctx, req)
|
|
if err != nil {
|
|
return nil, httperror.NewFromPb(err)
|
|
}
|
|
return res, nil
|
|
}
|
|
|
|
// ExchangeCode exchanges the one-time code for a token.
|
|
// The returned token only contains the Access Token.
|
|
// The client should call GetUserToken for full info.
|
|
func (s *proxyAuthClient) ExchangeCode(ctx context.Context, req *pb.ExchangeCodeRequest) (*pb.Token, error) {
|
|
// add correlation ID to outgoing RPC calls
|
|
ctx = correlation.WithMetaFromContext(ctx)
|
|
res, err := s.remote.ExchangeCode(ctx, req, s.callOpts...)
|
|
if err != nil {
|
|
return nil, httperror.NewFromPb(err)
|
|
}
|
|
return res, nil
|
|
}
|
|
|
|
// ExchangeCode exchanges the one-time code for a token.
|
|
// The returned token only contains the Access Token.
|
|
// The client should call GetUserToken for full info.
|
|
func (s *postproxyAuthClient) ExchangeCode(ctx context.Context, req *pb.ExchangeCodeRequest) (*pb.Token, error) {
|
|
var res pb.Token
|
|
path := pb.Auth_ExchangeCode_FullMethodName
|
|
_, _, err := s.client.Post(ctx, path, req, &res)
|
|
if err != nil {
|
|
return nil, err
|
|
}
|
|
return &res, nil
|
|
}
|
|
|
|
// SelectOrg verifies the caller's access to the org and returns a new
|
|
// token scoped to it. This is the only tenant request that carries OrgID.
|
|
func (s *proxyAuthServer) SelectOrg(ctx context.Context, req *pb.SelectOrgRequest, opts ...grpc.CallOption) (*pb.UserTokenResponse, error) {
|
|
// add correlation ID to outgoing RPC calls
|
|
ctx = correlation.WithMetaFromContext(ctx)
|
|
res, err := s.srv.SelectOrg(ctx, req)
|
|
if err != nil {
|
|
return nil, httperror.NewFromPb(err)
|
|
}
|
|
return res, nil
|
|
}
|
|
|
|
// SelectOrg verifies the caller's access to the org and returns a new
|
|
// token scoped to it. This is the only tenant request that carries OrgID.
|
|
func (s *proxyAuthClient) SelectOrg(ctx context.Context, req *pb.SelectOrgRequest) (*pb.UserTokenResponse, error) {
|
|
// add correlation ID to outgoing RPC calls
|
|
ctx = correlation.WithMetaFromContext(ctx)
|
|
res, err := s.remote.SelectOrg(ctx, req, s.callOpts...)
|
|
if err != nil {
|
|
return nil, httperror.NewFromPb(err)
|
|
}
|
|
return res, nil
|
|
}
|
|
|
|
// SelectOrg verifies the caller's access to the org and returns a new
|
|
// token scoped to it. This is the only tenant request that carries OrgID.
|
|
func (s *postproxyAuthClient) SelectOrg(ctx context.Context, req *pb.SelectOrgRequest) (*pb.UserTokenResponse, error) {
|
|
var res pb.UserTokenResponse
|
|
path := pb.Auth_SelectOrg_FullMethodName
|
|
_, _, err := s.client.Post(ctx, path, req, &res)
|
|
if err != nil {
|
|
return nil, err
|
|
}
|
|
return &res, nil
|
|
}
|
|
|
|
// AuthenticateAPIKey returns the user token info.
|
|
// The caller must include the API key in the Authorization header
|
|
// with HMAC SHA256 signature of the request, using API key secret.
|
|
//
|
|
// Date: RFC3339 timestamp
|
|
// Authorization: APIKey {KeyID}:{signature}
|
|
// signature = Base64(HMAC-SHA256(secret, method + timestamp))
|
|
func (s *proxyAuthServer) AuthenticateAPIKey(ctx context.Context, req *emptypb.Empty, opts ...grpc.CallOption) (*pb.UserTokenResponse, error) {
|
|
// add correlation ID to outgoing RPC calls
|
|
ctx = correlation.WithMetaFromContext(ctx)
|
|
res, err := s.srv.AuthenticateAPIKey(ctx, req)
|
|
if err != nil {
|
|
return nil, httperror.NewFromPb(err)
|
|
}
|
|
return res, nil
|
|
}
|
|
|
|
// AuthenticateAPIKey returns the user token info.
|
|
// The caller must include the API key in the Authorization header
|
|
// with HMAC SHA256 signature of the request, using API key secret.
|
|
//
|
|
// Date: RFC3339 timestamp
|
|
// Authorization: APIKey {KeyID}:{signature}
|
|
// signature = Base64(HMAC-SHA256(secret, method + timestamp))
|
|
func (s *proxyAuthClient) AuthenticateAPIKey(ctx context.Context, req *emptypb.Empty) (*pb.UserTokenResponse, error) {
|
|
// add correlation ID to outgoing RPC calls
|
|
ctx = correlation.WithMetaFromContext(ctx)
|
|
res, err := s.remote.AuthenticateAPIKey(ctx, req, s.callOpts...)
|
|
if err != nil {
|
|
return nil, httperror.NewFromPb(err)
|
|
}
|
|
return res, nil
|
|
}
|
|
|
|
// AuthenticateAPIKey returns the user token info.
|
|
// The caller must include the API key in the Authorization header
|
|
// with HMAC SHA256 signature of the request, using API key secret.
|
|
//
|
|
// Date: RFC3339 timestamp
|
|
// Authorization: APIKey {KeyID}:{signature}
|
|
// signature = Base64(HMAC-SHA256(secret, method + timestamp))
|
|
func (s *postproxyAuthClient) AuthenticateAPIKey(ctx context.Context, req *emptypb.Empty) (*pb.UserTokenResponse, error) {
|
|
var res pb.UserTokenResponse
|
|
path := pb.Auth_AuthenticateAPIKey_FullMethodName
|
|
_, _, err := s.client.Post(ctx, path, req, &res)
|
|
if err != nil {
|
|
return nil, err
|
|
}
|
|
return &res, nil
|
|
}
|
|
|
|
// GetAllowedMethods returns the allowed methods for the caller
|
|
func (s *proxyAuthServer) GetAllowedMethods(ctx context.Context, req *emptypb.Empty, opts ...grpc.CallOption) (*pb.ServiceAccessInfo, error) {
|
|
// add correlation ID to outgoing RPC calls
|
|
ctx = correlation.WithMetaFromContext(ctx)
|
|
res, err := s.srv.GetAllowedMethods(ctx, req)
|
|
if err != nil {
|
|
return nil, httperror.NewFromPb(err)
|
|
}
|
|
return res, nil
|
|
}
|
|
|
|
// GetAllowedMethods returns the allowed methods for the caller
|
|
func (s *proxyAuthClient) GetAllowedMethods(ctx context.Context, req *emptypb.Empty) (*pb.ServiceAccessInfo, error) {
|
|
// add correlation ID to outgoing RPC calls
|
|
ctx = correlation.WithMetaFromContext(ctx)
|
|
res, err := s.remote.GetAllowedMethods(ctx, req, s.callOpts...)
|
|
if err != nil {
|
|
return nil, httperror.NewFromPb(err)
|
|
}
|
|
return res, nil
|
|
}
|
|
|
|
// GetAllowedMethods returns the allowed methods for the caller
|
|
func (s *postproxyAuthClient) GetAllowedMethods(ctx context.Context, req *emptypb.Empty) (*pb.ServiceAccessInfo, error) {
|
|
var res pb.ServiceAccessInfo
|
|
path := pb.Auth_GetAllowedMethods_FullMethodName
|
|
_, _, err := s.client.Post(ctx, path, req, &res)
|
|
if err != nil {
|
|
return nil, err
|
|
}
|
|
return &res, nil
|
|
}
|
|
|
|
// GetCallerScope returns the caller's resolved scope in the selected org:
|
|
// the org role, project roles, token scopes, and per method the roles
|
|
// and scopes it requires.
|
|
func (s *proxyAuthServer) GetCallerScope(ctx context.Context, req *emptypb.Empty, opts ...grpc.CallOption) (*pb.CallerScope, error) {
|
|
// add correlation ID to outgoing RPC calls
|
|
ctx = correlation.WithMetaFromContext(ctx)
|
|
res, err := s.srv.GetCallerScope(ctx, req)
|
|
if err != nil {
|
|
return nil, httperror.NewFromPb(err)
|
|
}
|
|
return res, nil
|
|
}
|
|
|
|
// GetCallerScope returns the caller's resolved scope in the selected org:
|
|
// the org role, project roles, token scopes, and per method the roles
|
|
// and scopes it requires.
|
|
func (s *proxyAuthClient) GetCallerScope(ctx context.Context, req *emptypb.Empty) (*pb.CallerScope, error) {
|
|
// add correlation ID to outgoing RPC calls
|
|
ctx = correlation.WithMetaFromContext(ctx)
|
|
res, err := s.remote.GetCallerScope(ctx, req, s.callOpts...)
|
|
if err != nil {
|
|
return nil, httperror.NewFromPb(err)
|
|
}
|
|
return res, nil
|
|
}
|
|
|
|
// GetCallerScope returns the caller's resolved scope in the selected org:
|
|
// the org role, project roles, token scopes, and per method the roles
|
|
// and scopes it requires.
|
|
func (s *postproxyAuthClient) GetCallerScope(ctx context.Context, req *emptypb.Empty) (*pb.CallerScope, error) {
|
|
var res pb.CallerScope
|
|
path := pb.Auth_GetCallerScope_FullMethodName
|
|
_, _, err := s.client.Post(ctx, path, req, &res)
|
|
if err != nil {
|
|
return nil, err
|
|
}
|
|
return &res, nil
|
|
}
|