auth.proto 6.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164
  1. // Copyright 2016 Google Inc.
  2. //
  3. // Licensed under the Apache License, Version 2.0 (the "License");
  4. // you may not use this file except in compliance with the License.
  5. // You may obtain a copy of the License at
  6. //
  7. // http://www.apache.org/licenses/LICENSE-2.0
  8. //
  9. // Unless required by applicable law or agreed to in writing, software
  10. // distributed under the License is distributed on an "AS IS" BASIS,
  11. // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  12. // See the License for the specific language governing permissions and
  13. // limitations under the License.
  14. syntax = "proto3";
  15. package google.api;
  16. import "google/api/annotations.proto";
  17. option java_multiple_files = true;
  18. option java_outer_classname = "AuthProto";
  19. option java_package = "com.google.api";
  20. option objc_class_prefix = "GAPI";
  21. // `Authentication` defines the authentication configuration for an API.
  22. //
  23. // Example for an API targeted for external use:
  24. //
  25. // name: calendar.googleapis.com
  26. // authentication:
  27. // rules:
  28. // - selector: "*"
  29. // oauth:
  30. // canonical_scopes: https://www.googleapis.com/auth/calendar
  31. //
  32. // - selector: google.calendar.Delegate
  33. // oauth:
  34. // canonical_scopes: https://www.googleapis.com/auth/calendar.read
  35. message Authentication {
  36. // A list of authentication rules that apply to individual API methods.
  37. //
  38. // **NOTE:** All service configuration rules follow "last one wins" order.
  39. repeated AuthenticationRule rules = 3;
  40. // Defines a set of authentication providers that a service supports.
  41. repeated AuthProvider providers = 4;
  42. }
  43. // Authentication rules for the service.
  44. //
  45. // By default, if a method has any authentication requirements, every request
  46. // must include a valid credential matching one of the requirements.
  47. // It's an error to include more than one kind of credential in a single
  48. // request.
  49. //
  50. // If a method doesn't have any auth requirements, request credentials will be
  51. // ignored.
  52. message AuthenticationRule {
  53. // Selects the methods to which this rule applies.
  54. //
  55. // Refer to [selector][google.api.DocumentationRule.selector] for syntax details.
  56. string selector = 1;
  57. // The requirements for OAuth credentials.
  58. OAuthRequirements oauth = 2;
  59. // Whether to allow requests without a credential. The credential can be
  60. // an OAuth token, Google cookies (first-party auth) or EndUserCreds.
  61. //
  62. // For requests without credentials, if the service control environment is
  63. // specified, each incoming request **must** be associated with a service
  64. // consumer. This can be done by passing an API key that belongs to a consumer
  65. // project.
  66. bool allow_without_credential = 5;
  67. // Requirements for additional authentication providers.
  68. repeated AuthRequirement requirements = 7;
  69. }
  70. // Configuration for an anthentication provider, including support for
  71. // [JSON Web Token (JWT)](https://tools.ietf.org/html/draft-ietf-oauth-json-web-token-32).
  72. message AuthProvider {
  73. // The unique identifier of the auth provider. It will be referred to by
  74. // `AuthRequirement.provider_id`.
  75. //
  76. // Example: "bookstore_auth".
  77. string id = 1;
  78. // Identifies the principal that issued the JWT. See
  79. // https://tools.ietf.org/html/draft-ietf-oauth-json-web-token-32#section-4.1.1
  80. // Usually a URL or an email address.
  81. //
  82. // Example: https://securetoken.google.com
  83. // Example: 1234567-compute@developer.gserviceaccount.com
  84. string issuer = 2;
  85. // URL of the provider's public key set to validate signature of the JWT. See
  86. // [OpenID Discovery](https://openid.net/specs/openid-connect-discovery-1_0.html#ProviderMetadata).
  87. // Optional if the key set document:
  88. // - can be retrieved from
  89. // [OpenID Discovery](https://openid.net/specs/openid-connect-discovery-1_0.html
  90. // of the issuer.
  91. // - can be inferred from the email domain of the issuer (e.g. a Google service account).
  92. //
  93. // Example: https://www.googleapis.com/oauth2/v1/certs
  94. string jwks_uri = 3;
  95. }
  96. // OAuth scopes are a way to define data and permissions on data. For example,
  97. // there are scopes defined for "Read-only access to Google Calendar" and
  98. // "Access to Cloud Platform". Users can consent to a scope for an application,
  99. // giving it permission to access that data on their behalf.
  100. //
  101. // OAuth scope specifications should be fairly coarse grained; a user will need
  102. // to see and understand the text description of what your scope means.
  103. //
  104. // In most cases: use one or at most two OAuth scopes for an entire family of
  105. // products. If your product has multiple APIs, you should probably be sharing
  106. // the OAuth scope across all of those APIs.
  107. //
  108. // When you need finer grained OAuth consent screens: talk with your product
  109. // management about how developers will use them in practice.
  110. //
  111. // Please note that even though each of the canonical scopes is enough for a
  112. // request to be accepted and passed to the backend, a request can still fail
  113. // due to the backend requiring additional scopes or permissions.
  114. message OAuthRequirements {
  115. // The list of publicly documented OAuth scopes that are allowed access. An
  116. // OAuth token containing any of these scopes will be accepted.
  117. //
  118. // Example:
  119. //
  120. // canonical_scopes: https://www.googleapis.com/auth/calendar,
  121. // https://www.googleapis.com/auth/calendar.read
  122. string canonical_scopes = 1;
  123. }
  124. // User-defined authentication requirements, including support for
  125. // [JSON Web Token (JWT)](https://tools.ietf.org/html/draft-ietf-oauth-json-web-token-32).
  126. message AuthRequirement {
  127. // [id][google.api.AuthProvider.id] from authentication provider.
  128. //
  129. // Example:
  130. //
  131. // provider_id: bookstore_auth
  132. string provider_id = 1;
  133. // The list of JWT
  134. // [audiences](https://tools.ietf.org/html/draft-ietf-oauth-json-web-token-32#section-4.1.3).
  135. // that are allowed to access. A JWT containing any of these audiences will
  136. // be accepted. When this setting is absent, only JWTs with audience
  137. // "https://[Service_name][google.api.Service.name]/[API_name][google.protobuf.Api.name]"
  138. // will be accepted. For example, if no audiences are in the setting,
  139. // LibraryService API will only accept JWTs with the following audience
  140. // "https://library-example.googleapis.com/google.example.library.v1.LibraryService".
  141. //
  142. // Example:
  143. //
  144. // audiences: bookstore_android.apps.googleusercontent.com,
  145. // bookstore_web.apps.googleusercontent.com
  146. string audiences = 2;
  147. }