1- // Copyright 2018 Google LLC.
1+ // Copyright 2015 Google LLC
22//
33// Licensed under the Apache License, Version 2.0 (the "License");
44// you may not use this file except in compliance with the License.
@@ -16,18 +16,16 @@ syntax = "proto3";
1616
1717package google.api ;
1818
19- import "google/api/annotations.proto" ;
20-
2119option go_package = "google.golang.org/genproto/googleapis/api/serviceconfig;serviceconfig" ;
2220option java_multiple_files = true ;
2321option java_outer_classname = "AuthProto" ;
2422option java_package = "com.google.api" ;
2523option objc_class_prefix = "GAPI" ;
2624
27-
28- // `Authentication` defines the authentication configuration for an API.
25+ // `Authentication` defines the authentication configuration for API methods
26+ // provided by an API service .
2927//
30- // Example for an API targeted for external use :
28+ // Example:
3129//
3230// name: calendar.googleapis.com
3331// authentication:
@@ -39,6 +37,9 @@ option objc_class_prefix = "GAPI";
3937// - selector: "*"
4038// requirements:
4139// provider_id: google_calendar_auth
40+ // - selector: google.calendar.Delegate
41+ // oauth:
42+ // canonical_scopes: https://www.googleapis.com/auth/calendar.read
4243message Authentication {
4344 // A list of authentication rules that apply to individual API methods.
4445 //
@@ -68,14 +69,37 @@ message AuthenticationRule {
6869 OAuthRequirements oauth = 2 ;
6970
7071 // If true, the service accepts API keys without any other credential.
72+ // This flag only applies to HTTP and gRPC requests.
7173 bool allow_without_credential = 5 ;
7274
7375 // Requirements for additional authentication providers.
7476 repeated AuthRequirement requirements = 7 ;
7577}
7678
77- // Configuration for an anthentication provider, including support for
78- // [JSON Web Token (JWT)](https://tools.ietf.org/html/draft-ietf-oauth-json-web-token-32).
79+ // Specifies a location to extract JWT from an API request.
80+ message JwtLocation {
81+ oneof in {
82+ // Specifies HTTP header name to extract JWT token.
83+ string header = 1 ;
84+
85+ // Specifies URL query parameter name to extract JWT token.
86+ string query = 2 ;
87+ }
88+
89+ // The value prefix. The value format is "value_prefix{token}"
90+ // Only applies to "in" header type. Must be empty for "in" query type.
91+ // If not empty, the header value has to match (case sensitive) this prefix.
92+ // If not matched, JWT will not be extracted. If matched, JWT will be
93+ // extracted after the prefix is removed.
94+ //
95+ // For example, for "Authorization: Bearer {JWT}",
96+ // value_prefix="Bearer " with a space at the end.
97+ string value_prefix = 3 ;
98+ }
99+
100+ // Configuration for an authentication provider, including support for
101+ // [JSON Web Token
102+ // (JWT)](https://tools.ietf.org/html/draft-ietf-oauth-json-web-token-32).
79103message AuthProvider {
80104 // The unique identifier of the auth provider. It will be referred to by
81105 // `AuthRequirement.provider_id`.
@@ -92,34 +116,60 @@ message AuthProvider {
92116 string issuer = 2 ;
93117
94118 // URL of the provider's public key set to validate signature of the JWT. See
95- // [OpenID Discovery](https://openid.net/specs/openid-connect-discovery-1_0.html#ProviderMetadata).
119+ // [OpenID
120+ // Discovery](https://openid.net/specs/openid-connect-discovery-1_0.html#ProviderMetadata).
96121 // Optional if the key set document:
97122 // - can be retrieved from
98- // [OpenID Discovery](https://openid.net/specs/openid-connect-discovery-1_0.html
123+ // [OpenID
124+ // Discovery](https://openid.net/specs/openid-connect-discovery-1_0.html)
99125 // of the issuer.
100- // - can be inferred from the email domain of the issuer (e.g. a Google service account).
126+ // - can be inferred from the email domain of the issuer (e.g. a Google
127+ // service account).
101128 //
102129 // Example: https://www.googleapis.com/oauth2/v1/certs
103130 string jwks_uri = 3 ;
104131
105132 // The list of JWT
106133 // [audiences](https://tools.ietf.org/html/draft-ietf-oauth-json-web-token-32#section-4.1.3).
107134 // that are allowed to access. A JWT containing any of these audiences will
108- // be accepted. When this setting is absent, only JWTs with audience
109- // "https://[Service_name][google.api.Service.name]/[API_name][google.protobuf.Api.name]"
110- // will be accepted. For example, if no audiences are in the setting,
111- // LibraryService API will only accept JWTs with the following audience
112- // "https://library-example.googleapis.com/google.example.library.v1.LibraryService".
135+ // be accepted. When this setting is absent, JWTs with audiences:
136+ // - "https://[service.name]/[google.protobuf.Api.name]"
137+ // - "https://[service.name]/"
138+ // will be accepted.
139+ // For example, if no audiences are in the setting, LibraryService API will
140+ // accept JWTs with the following audiences:
141+ // -
142+ // https://library-example.googleapis.com/google.example.library.v1.LibraryService
143+ // - https://library-example.googleapis.com/
113144 //
114145 // Example:
115146 //
116147 // audiences: bookstore_android.apps.googleusercontent.com,
117148 // bookstore_web.apps.googleusercontent.com
118149 string audiences = 4 ;
119150
120- // Redirect URL if JWT token is required but no present or is expired.
151+ // Redirect URL if JWT token is required but not present or is expired.
121152 // Implement authorizationUrl of securityDefinitions in OpenAPI spec.
122153 string authorization_url = 5 ;
154+
155+ // Defines the locations to extract the JWT.
156+ //
157+ // JWT locations can be either from HTTP headers or URL query parameters.
158+ // The rule is that the first match wins. The checking order is: checking
159+ // all headers first, then URL query parameters.
160+ //
161+ // If not specified, default to use following 3 locations:
162+ // 1) Authorization: Bearer
163+ // 2) x-goog-iap-jwt-assertion
164+ // 3) access_token query parameter
165+ //
166+ // Default locations can be specified as followings:
167+ // jwt_locations:
168+ // - header: Authorization
169+ // value_prefix: "Bearer "
170+ // - header: x-goog-iap-jwt-assertion
171+ // - query: access_token
172+ repeated JwtLocation jwt_locations = 6 ;
123173}
124174
125175// OAuth scopes are a way to define data and permissions on data. For example,
@@ -152,7 +202,8 @@ message OAuthRequirements {
152202}
153203
154204// User-defined authentication requirements, including support for
155- // [JSON Web Token (JWT)](https://tools.ietf.org/html/draft-ietf-oauth-json-web-token-32).
205+ // [JSON Web Token
206+ // (JWT)](https://tools.ietf.org/html/draft-ietf-oauth-json-web-token-32).
156207message AuthRequirement {
157208 // [id][google.api.AuthProvider.id] from authentication provider.
158209 //
0 commit comments