Skip to content

Latest commit

 

History

History
61 lines (53 loc) · 1.93 KB

alts.md

File metadata and controls

61 lines (53 loc) · 1.93 KB
title linkTitle description weight spelling code
ALTS authentication
ALTS
An overview of gRPC authentication in C++ using Application Layer Transport Security (ALTS).
75
cSpell:ignore Authz creds grpcpp
client_credentials server_credentials server_authorization client_authorization
```cpp #include <grpcpp/grpcpp.h> #include <grpcpp/security/credentials.h> using grpc::experimental::AltsCredentials; using grpc::experimental::AltsCredentialsOptions; auto creds = AltsCredentials(AltsCredentialsOptions()); std::shared_ptr<grpc::Channel> channel = CreateChannel(server_address, creds); ```
```cpp #include <grpcpp/security/server_credentials.h> #include <grpcpp/server.h> #include <grpcpp/server_builder.h> using grpc::experimental::AltsServerCredentials; using grpc::experimental::AltsServerCredentialsOptions; grpc::ServerBuilder builder; builder.RegisterService(&service); auto creds = AltsServerCredentials(AltsServerCredentialsOptions()); builder.AddListeningPort("[::]:<port>", creds); std::unique_ptr<Server> server(builder.BuildAndStart()); ```
```cpp #include <grpcpp/grpcpp.h> #include <grpcpp/security/credentials.h> using grpc::experimental::AltsCredentials; using grpc::experimental::AltsCredentialsOptions; AltsCredentialsOptions opts; opts.target_service_accounts.push_back("expected_server_service_account1"); opts.target_service_accounts.push_back("expected_server_service_account2"); auto creds = AltsCredentials(opts); std::shared_ptr<grpc::Channel> channel = CreateChannel(server_address, creds); ```
```cpp #include <grpcpp/server_context.h> #include <grpcpp/security/alts_util.h> grpc::ServerContext* context; grpc::Status status = experimental::AltsClientAuthzCheck( context->auth_context(), {"[email protected]"}); ```

{{% docs/auth_alts %}}