Skip to content

Commit

Permalink
Skeleton of new Azure OIDC RPC call
Browse files Browse the repository at this point in the history
  • Loading branch information
mvbrock committed Jan 18, 2025
1 parent 244fe67 commit 45218d2
Show file tree
Hide file tree
Showing 9 changed files with 340 additions and 142 deletions.
11 changes: 11 additions & 0 deletions api/client/client.go
Original file line number Diff line number Diff line change
Expand Up @@ -4829,6 +4829,17 @@ func (c *Client) GenerateAWSOIDCToken(ctx context.Context, integration string) (
return resp.GetToken(), nil
}

func (c *Client) GenerateAzureOIDCToken(ctx context.Context, integration string) (string, error) {
resp, err := c.integrationsClient().GenerateAzureOIDCToken(ctx, &integrationpb.GenerateAzureOIDCTokenRequest{
Integration: integration,
})
if err != nil {
return "", trace.Wrap(err)
}

return resp.GetToken(), nil
}

// PluginsClient returns an unadorned Plugins client, using the underlying
// Auth gRPC connection.
// Clients connecting to non-Enterprise clusters, or older Teleport versions,
Expand Down
395 changes: 255 additions & 140 deletions api/gen/proto/go/teleport/integration/v1/integration_service.pb.go

Large diffs are not rendered by default.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

17 changes: 17 additions & 0 deletions api/proto/teleport/integration/v1/integration_service.proto
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,9 @@ service IntegrationService {
// GenerateAWSOIDCToken generates a token to be used when executing an AWS OIDC Integration action.
rpc GenerateAWSOIDCToken(GenerateAWSOIDCTokenRequest) returns (GenerateAWSOIDCTokenResponse);

// GenerateAzureOIDCToken generates a token to be used when executing an Azure OIDC Integration action.
rpc GenerateAzureOIDCToken(GenerateAzureOIDCTokenRequest) returns (GenerateAzureOIDCTokenResponse);

// GenerateGitHubUserCert signs a SSH certificate for GitHub integration.
rpc GenerateGitHubUserCert(GenerateGitHubUserCertRequest) returns (GenerateGitHubUserCertResponse);

Expand Down Expand Up @@ -119,6 +122,20 @@ message GenerateAWSOIDCTokenResponse {
string token = 1;
}

// GenerateAzureOIDCTokenRequest are the parameters used to request an AWS OIDC
// Integration token.
message GenerateAzureOIDCTokenRequest {
// Integration is the Azure OIDC Integration name.
// Required.
string integration = 2;
}

// GenerateAzureOIDCTokenResponse contains a signed Azure OIDC Integration token.
message GenerateAzureOIDCTokenResponse {
// Token is the signed JWT ready to be used
string token = 1;
}

// GenerateGitHubUserCertRequest is a request to sign a client certificate used by
// GitHub integration to authenticate with GitHub enterprise.
message GenerateGitHubUserCertRequest {
Expand Down
5 changes: 5 additions & 0 deletions lib/auth/auth.go
Original file line number Diff line number Diff line change
Expand Up @@ -749,6 +749,11 @@ func (r *Services) GenerateAWSOIDCToken(ctx context.Context, integration string)
return r.IntegrationsTokenGenerator.GenerateAWSOIDCToken(ctx, integration)
}

// GenerateAzureOIDCToken generates a token to be used to execute an AWS OIDC Integration action.
func (r *Services) GenerateAzureOIDCToken(ctx context.Context, integration string) (string, error) {
return r.IntegrationsTokenGenerator.GenerateAzureOIDCToken(ctx, integration)
}

var (
generateRequestsCount = prometheus.NewCounter(
prometheus.CounterOpts{
Expand Down
7 changes: 7 additions & 0 deletions lib/auth/authclient/api.go
Original file line number Diff line number Diff line change
Expand Up @@ -804,6 +804,9 @@ type DiscoveryAccessPoint interface {
// GenerateAWSOIDCToken generates a token to be used to execute an AWS OIDC Integration action.
GenerateAWSOIDCToken(ctx context.Context, integration string) (string, error)

// GenerateAzureOIDCToken generates a token to be used to execute an Azure OIDC Integration action.
GenerateAzureOIDCToken(ctx context.Context, integration string) (string, error)

// EnrollEKSClusters enrolls EKS clusters into Teleport by installing teleport-kube-agent chart on the clusters.
EnrollEKSClusters(context.Context, *integrationpb.EnrollEKSClustersRequest, ...grpc.CallOption) (*integrationpb.EnrollEKSClustersResponse, error)

Expand Down Expand Up @@ -1484,6 +1487,10 @@ func (w *DiscoveryWrapper) GenerateAWSOIDCToken(ctx context.Context, integration
return w.NoCache.GenerateAWSOIDCToken(ctx, integration)
}

func (w *DiscoveryWrapper) GenerateAzureOIDCToken(ctx context.Context, integration string) (string, error) {
return w.NoCache.GenerateAzureOIDCToken(ctx, integration)
}

// EnrollEKSClusters enrolls EKS clusters into Teleport by installing teleport-kube-agent chart on the clusters.
func (w *DiscoveryWrapper) EnrollEKSClusters(ctx context.Context, req *integrationpb.EnrollEKSClustersRequest, _ ...grpc.CallOption) (*integrationpb.EnrollEKSClustersResponse, error) {
return w.NoCache.EnrollEKSClusters(ctx, req)
Expand Down
3 changes: 3 additions & 0 deletions lib/auth/authclient/clt.go
Original file line number Diff line number Diff line change
Expand Up @@ -1703,6 +1703,9 @@ type ClientI interface {
// GenerateAWSOIDCToken generates a token to be used to execute an AWS OIDC Integration action.
GenerateAWSOIDCToken(ctx context.Context, integration string) (string, error)

// GenerateAzureOIDCToken generates a token to be used to execute an Azure OIDC Integration action.
GenerateAzureOIDCToken(ctx context.Context, integration string) (string, error)

// ResetAuthPreference resets cluster auth preference to defaults.
ResetAuthPreference(ctx context.Context) error

Expand Down
2 changes: 0 additions & 2 deletions lib/auth/integration/integrationv1/azureoidc.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,9 @@ package integrationv1

import (
"context"
"fmt"
integrationpb "github.com/gravitational/teleport/api/gen/proto/go/teleport/integration/v1"
)

func (s *Service) GenerateAzureOIDCToken(ctx context.Context, req *integrationpb.GenerateAzureOIDCTokenRequest) (*integrationpb.GenerateAzureOIDCTokenResponse, error) {
fmt.Printf("============= GENERATING AZURE TOKEN?!\n")
return nil, nil
}
2 changes: 2 additions & 0 deletions lib/services/integration.go
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,8 @@ type IntegrationsGetter interface {
type IntegrationsTokenGenerator interface {
// GenerateAWSOIDCToken generates a token to be used to execute an AWS OIDC Integration action.
GenerateAWSOIDCToken(ctx context.Context, integration string) (string, error)
// GenerateAzureOIDCToken generates a token to be used to execute an Azure OIDC Integration action.
GenerateAzureOIDCToken(ctx context.Context, integration string) (string, error)
}

// MarshalIntegration marshals the Integration resource to JSON.
Expand Down

0 comments on commit 45218d2

Please sign in to comment.