Go-specific ALTS authentication page from template (#537)

- Contributes to #527
- Also included are minor tweaks to the C++-ALTS page
This commit is contained in:
Patrice Chalin 2020-11-23 16:04:31 -05:00 committed by GitHub
parent 7851780af3
commit c1d97fbe94
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 61 additions and 53 deletions

View File

@ -27,7 +27,10 @@ protocol with few lines of code. gRPC ALTS is supported in C++, Java, Go, and
Python. Python.
Details are covered in this page, or in the following language-specific Details are covered in this page, or in the following language-specific
page: [C++ ALTS]({{< relref "docs/languages/cpp/alts" >}}). pages:
- [ALTS in C++]({{< relref "docs/languages/cpp/alts" >}})
- [ALTS in Go]({{< relref "docs/languages/go/alts" >}})
Note that ALTS is fully functional if the application runs on Note that ALTS is fully functional if the application runs on
[Google Cloud Platform](https://cloud.google.com). ALTS could be run on any [Google Cloud Platform](https://cloud.google.com). ALTS could be run on any
@ -49,18 +52,6 @@ ManagedChannel managedChannel =
AltsChannelBuilder.forTarget(serverAddress).build(); AltsChannelBuilder.forTarget(serverAddress).build();
``` ```
#### Go
```go
import (
"google.golang.org/grpc"
"google.golang.org/grpc/credentials/alts"
)
altsTC := alts.NewClientCreds(alts.DefaultClientOptions())
conn, err := grpc.Dial(serverAddr, grpc.WithTransportCredentials(altsTC))
```
#### Python #### Python
```python ```python
@ -87,18 +78,6 @@ Server server = AltsServerBuilder.forPort(<port>)
``` ```
#### Go
```go
import (
"google.golang.org/grpc"
"google.golang.org/grpc/credentials/alts"
)
altsTC := alts.NewServerCreds(alts.DefaultServerOptions())
server := grpc.NewServer(grpc.Creds(altsTC))
```
#### Python #### Python
```python ```python
@ -130,20 +109,6 @@ ManagedChannel channel =
.build(); .build();
``` ```
#### Go
```go
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.Dial(serverAddr, grpc.WithTransportCredentials(altsTC))
```
### Client Authorization ### Client Authorization
On a successful connection, the peer information (e.g., clients service On a successful connection, the peer information (e.g., clients service
@ -165,14 +130,3 @@ ServerCall<?, ?> call;
Status status = AuthorizationUtil.clientAuthorizationCheck( Status status = AuthorizationUtil.clientAuthorizationCheck(
call, Lists.newArrayList("foo@iam.gserviceaccount.com")); call, Lists.newArrayList("foo@iam.gserviceaccount.com"));
``` ```
#### Go
```go
import (
"google.golang.org/grpc"
"google.golang.org/grpc/credentials/alts"
)
err := alts.ClientAuthorizationCheck(ctx, []string{"foo@iam.gserviceaccount.com"})
```

View File

@ -1,10 +1,11 @@
--- ---
title: ALTS authentication title: ALTS authentication in C++
short: ALTS short: ALTS
layout: auth_alts layout: auth_alts
description: > description: >
An overview of gRPC authentication in C++ using Application Layer Transport An overview of gRPC authentication in C++ using Application Layer Transport
Security (ALTS). Security (ALTS).
weight: 75
spelling: cSpell:ignore Authz creds grpcpp spelling: cSpell:ignore Authz creds grpcpp
code: code:
client_credentials: | client_credentials: |

View File

@ -4,9 +4,9 @@ layout: prog_lang_home
api_path: https://pkg.go.dev/google.golang.org/grpc api_path: https://pkg.go.dev/google.golang.org/grpc
content: content:
- learn_more: - learn_more:
- "[Examples]($src_repo_url/tree/master/examples)" - "[ALTS authentication](alts/)"
- "[Additional docs]($src_repo_url/tree/master/Documentation)" - "[Additional docs]($src_repo_url/tree/master/Documentation)"
- "[Installation]($src_repo_url#installation)" - "[Examples]($src_repo_url/tree/master/examples)"
- "[FAQ]($src_repo_url#faq)" - "[FAQ]($src_repo_url#faq)"
- reference: - reference:
- "[API](api/)" - "[API](api/)"
@ -14,6 +14,7 @@ content:
- other: - other:
- $src_repo_link - $src_repo_link
- "[Performance benchmark](https://performance-dot-grpc-testing.appspot.com/explore?dashboard=5652536396611584&widget=490377658&container=1286539696)" - "[Performance benchmark](https://performance-dot-grpc-testing.appspot.com/explore?dashboard=5652536396611584&widget=490377658&container=1286539696)"
- "[Installation]($src_repo_url#installation)"
spelling: cSpell:ignore Isberner Klerk Malte youtube spelling: cSpell:ignore Isberner Klerk Malte youtube
--- ---

View File

@ -0,0 +1,52 @@
---
title: ALTS authentication in Go
short: ALTS
layout: auth_alts
description: >
An overview of gRPC authentication in Go using Application Layer Transport
Security (ALTS).
weight: 75
spelling: cSpell:ignore creds
code:
client_credentials: |
```go
import (
"google.golang.org/grpc"
"google.golang.org/grpc/credentials/alts"
)
altsTC := alts.NewClientCreds(alts.DefaultClientOptions())
conn, err := grpc.Dial(serverAddr, grpc.WithTransportCredentials(altsTC))
```
server_credentials: |
```go
import (
"google.golang.org/grpc"
"google.golang.org/grpc/credentials/alts"
)
altsTC := alts.NewServerCreds(alts.DefaultServerOptions())
server := grpc.NewServer(grpc.Creds(altsTC))
```
server_authorization: |
```go
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.Dial(serverAddr, grpc.WithTransportCredentials(altsTC))
```
client_authorization: |
```go
import (
"google.golang.org/grpc"
"google.golang.org/grpc/credentials/alts"
)
err := alts.ClientAuthorizationCheck(ctx, []string{"foo@iam.gserviceaccount.com"})
```
---