--- url: "https://grpc.io/docs/languages/go/alts/" titulek: "ALTS authentication | Go | gRPC" h1: "ALTS authentication" popis: "An overview of gRPC authentication in Go using Application Layer Transport Security (ALTS)." jazyk: "en" kanonicka: "https://grpc.io/docs/languages/go/alts/" drobecky: ["Docs", "Languages", "Go", "ALTS"] zdroj: "live" wayback_snapshot: "" stazeno: "2026-09-13 21:00:12" znaku: 4912 slov: 445 kodovani: "utf-8" sha256: "c1c0e2e5ecc995ae8c0ff212c32a97cc6c48eebea7b94cdc416669951648eb28" --- # ALTS authentication An overview of gRPC authentication in Go using Application Layer Transport Security (ALTS). Contents # ALTS authentication An overview of gRPC authentication in Go using Application Layer Transport Security (ALTS). ### Overview Application Layer Transport Security (ALTS) is a mutual authentication and transport encryption system developed by Google. It is used for securing RPC communications within Google’s infrastructure. ALTS is similar to mutual TLS but has been designed and optimized to meet the needs of Google’s production environments. For more information, take a look at the [ALTS whitepaper](https://cloud.google.com/security/encryption-in-transit/application-layer-transport-security). ALTS in gRPC has the following features: - Create gRPC servers & clients with ALTS as the transport security protocol. - ALTS connections are end-to-end protected with privacy and integrity. - Applications can access peer information such as the peer service account. - Client authorization and server authorization support. - Minimal code changes to enable ALTS. gRPC users can configure their applications to use ALTS as a transport security protocol with few lines of code. Note that ALTS is fully supported for connections between GCP and Google if the application runs on [Compute Engine](https://cloud.google.com/compute) or [Google Kubernetes Engine (GKE)](https://cloud.google.com/kubernetes-engine). ALTS does not support workload-to-workload authentication between GCP workloads. ### gRPC Client with ALTS Transport Security Protocol gRPC clients can use ALTS credentials to connect to servers, as illustrated in the following code excerpt: ``` import ( "google.golang.org/grpc" "google.golang.org/grpc/credentials/alts" ) altsTC := alts.NewClientCreds(alts.DefaultClientOptions()) conn, err := grpc.NewClient(serverAddr, grpc.WithTransportCredentials(altsTC)) ``` ### gRPC Server with ALTS Transport Security Protocol gRPC servers can use ALTS credentials to allow clients to connect to them, as illustrated next: ``` import ( "google.golang.org/grpc" "google.golang.org/grpc/credentials/alts" ) altsTC := alts.NewServerCreds(alts.DefaultServerOptions()) server := grpc.NewServer(grpc.Creds(altsTC)) ``` ### Server Authorization gRPC has built-in server authorization support using ALTS. A gRPC client using ALTS can set the expected server service accounts prior to establishing a connection. Then, at the end of the handshake, server authorization guarantees that the server identity matches one of the service accounts specified by the client. Otherwise, the connection fails. ``` import ( "google.golang.org/grpc" "google.golang.org/grpc/credentials/alts" ) clientOpts := alts.DefaultClientOptions() clientOpts.TargetServiceAccounts = []string{expectedServerSA} altsTC := alts.NewClientCreds(clientOpts) conn, err := grpc.NewClient(serverAddr, grpc.WithTransportCredentials(altsTC)) ``` ### Client Authorization On a successful connection, the peer information (e.g., client’s service account) is stored in the [AltsContext](https://github.com/grpc/grpc/blob/master/src/proto/grpc/gcp/altscontext.proto). gRPC provides a utility library for client authorization check. Assuming that the server knows the expected client identity (e.g., `foo@iam.gserviceaccount.com`), it can run the following example codes to authorize the incoming RPC. ``` import ( "google.golang.org/grpc" "google.golang.org/grpc/credentials/alts" ) err := alts.ClientAuthorizationCheck(ctx, []string{"foo@iam.gserviceaccount.com"}) ``` Last modified May 21, 2024: [Update Go documentation to use NewClient instead of Dial (#1295) (708f7a1)](https://github.com/grpc/grpc.io/commit/708f7a1ce944347a07ba6828ea3164b8cbe7746d) [View page source](https://github.com/grpc/grpc.io/tree/main/content/en/docs/languages/go/alts.md) [Edit this page](https://github.com/grpc/grpc.io/edit/main/content/en/docs/languages/go/alts.md) [Create child page](https://github.com/grpc/grpc.io/new/main/content/en/docs/languages/go/alts.md?filename=change-me.md&value=---%0Atitle%3A+%22Long+Page+Title%22%0AlinkTitle%3A+%22Short+Nav+Title%22%0Aweight%3A+100%0Adescription%3A+%3E-%0A+++++Page+description+for+heading+and+indexes.%0A---%0A%0A%23%23+Heading%0A%0AEdit+this+template+to+create+your+new+page.%0A%0A%2A+Give+it+a+good+name%2C+ending+in+%60.md%60+-+e.g.+%60getting-started.md%60%0A%2A+Edit+the+%22front+matter%22+section+at+the+top+of+the+page+%28weight+controls+how+its+ordered+amongst+other+pages+in+the+same+directory%3B+lowest+number+first%29.%0A%2A+Add+a+good+commit+message+at+the+bottom+of+the+page+%28%3C80+characters%3B+use+the+extended+description+field+for+more+detail%29.%0A%2A+Create+a+new+branch+so+you+can+preview+your+new+file+and+request+a+review+via+Pull+Request.%0A) [Create documentation issue](https://github.com/grpc/grpc.io/issues/new?title=ALTS%20authentication) [Create project issue](https://github.com/grpc/grpc.io/issues/new)