go.chromium.org/luci@v0.0.0-20240309015107-7cdc2e660f33/tokenserver/api/admin/v1/config.proto (about)

     1  // Copyright 2016 The LUCI Authors. All rights reserved.
     2  // Use of this source code is governed under the Apache License, Version 2.0
     3  // that can be found in the LICENSE file.
     4  
     5  syntax = "proto3";
     6  
     7  package tokenserver.admin;
     8  
     9  option go_package = "go.chromium.org/luci/tokenserver/api/admin/v1;admin";
    10  
    11  
    12  // TokenServerConfig is read from tokenserver.cfg in luci-config.
    13  message TokenServerConfig {
    14    // List of CAs we trust.
    15    repeated CertificateAuthorityConfig certificate_authority = 1;
    16  }
    17  
    18  
    19  // CertificateAuthorityConfig defines a single CA we trust.
    20  //
    21  // Such CA issues certificates for nodes that use The Token Service. Each node
    22  // has a private key and certificate with Common Name set to the FQDN of this
    23  // node, e.g. "CN=slave43-c1.c.chromecompute.google.com.internal".
    24  //
    25  // The Token Server uses this CN to derive an identity string for a machine. It
    26  // splits FQDN into a hostname ("slave43-c1") and a domain name
    27  // ("c.chromecompute.google.com.internal"), searches for a domain name in
    28  // "known_domains" set, and, if it is present, uses parameters described there
    29  // for generating a token that contains machine's FQDN and certificate serial
    30  // number (among other things, see MachineTokenBody in machine_token.proto).
    31  message CertificateAuthorityConfig {
    32    int64  unique_id = 6; // ID of this CA, will be embedded into tokens.
    33    string cn = 1;        // CA Common Name, must match Subject CN in the cert
    34    string cert_path = 2; // path to the root certificate file in luci-config
    35    string crl_url = 3;   // where to fetch CRL from
    36    bool   use_oauth = 4; // true to send Authorization header when fetching CRL
    37    repeated string oauth_scopes = 7; // OAuth scopes to use when fetching CRL
    38  
    39    // KnownDomains describes parameters to use for each particular domain.
    40    repeated DomainConfig known_domains = 5;
    41  }
    42  
    43  
    44  // DomainConfig is used inside CertificateAuthorityConfig.
    45  message DomainConfig {
    46    reserved 2, 3, 4, 6; // deleted fields, do not reuse.
    47  
    48    // Domain is domain names of hosts this config applies to.
    49    //
    50    // Machines that reside in a subdomain of given domain are also considered
    51    // part of it, e.g. both FQDNs "host.example.com" and "host.abc.example.com"
    52    // match domain "example.com".
    53    repeated string domain = 1;
    54  
    55    // MachineTokenLifetime is how long generated machine tokens live, in seconds.
    56    //
    57    // If 0, machine tokens are not allowed.
    58    int64 machine_token_lifetime = 5;
    59  }
    60  
    61  
    62  // DelegationPermissions is read from delegation.cfg in luci-config.
    63  message DelegationPermissions {
    64    // Rules specify what calls to MintDelegationToken are allowed.
    65    //
    66    // Rules are evaluated independently. One and only one rule should match the
    67    // request to allow the operation. If none rules or more than one rule match,
    68    // the request will be denied.
    69    //
    70    // See DelegationRule comments for more details.
    71    repeated DelegationRule rules = 1;
    72  }
    73  
    74  
    75  // DelegationRule describes a single allowed case of using delegation tokens.
    76  //
    77  // An incoming MintDelegationTokenRequest is basically a tuple of:
    78  //  * 'requestor_id' - an identity of whoever makes the request.
    79  //  * 'delegated_identity' - an identity to delegate.
    80  //  * 'audience' - a set of identities that will be able to use the token.
    81  //  * 'services' - a set of services that should accept the token.
    82  //
    83  // A request matches a rule iff:
    84  //  * 'requestor_id' is in 'requestor' set.
    85  //  * 'delegated_identity' is in 'allowed_to_impersonate' set.
    86  //  * 'audience' is a subset of 'allowed_audience' set.
    87  //  * 'services' is a subset of 'target_service' set.
    88  //
    89  // The presence of a matching rule permits to mint the token. The rule also
    90  // provides an upper bound on allowed validity_duration, and the rule's name
    91  // is logged in the audit trail.
    92  message DelegationRule {
    93    // A descriptive name of this rule, for the audit log.
    94    string name = 1;
    95  
    96    // Email of developers that own this rule, to know who to contact.
    97    repeated string owner = 2;
    98  
    99    // A set of callers to which this rule applies.
   100    //
   101    // Matched against verified credentials of a caller of MintDelegationToken.
   102    //
   103    // Each element is either:
   104    //  * An identity string ("user:<email>").
   105    //  * A group reference ("group:<name>").
   106    //
   107    // The groups specified here are expanded when MintDelegationTokenRequest is
   108    // evaluated.
   109    repeated string requestor = 3;
   110  
   111    // Identities that are allowed to be delegated/impersonated by the requestor.
   112    //
   113    // Matched against 'delegated_identity' field of MintDelegationTokenRequest.
   114    //
   115    // Each element is either:
   116    //  * An identity string ("user:<email>").
   117    //  * A group reference ("group:<name>").
   118    //  * A special identifier "REQUESTOR" that is substituted by the requestor
   119    //    identity when evaluating the rule.
   120    //
   121    // "REQUESTOR" allows one to generate tokens that delegate their own identity
   122    // to some target audience.
   123    //
   124    // The groups specified here are expanded when MintDelegationTokenRequest is
   125    // evaluated.
   126    repeated string allowed_to_impersonate = 4;
   127  
   128    // A set of identities that should be able to use the new token.
   129    //
   130    // Matched against 'audience' field of MintDelegationTokenRequest.
   131    //
   132    // Each element is either:
   133    //  * An identity string ("user:<email>").
   134    //  * A group reference ("group:<name>").
   135    //  * A special identifier "REQUESTOR" that is substituted by the requestor
   136    //    identity when evaluating the rule.
   137    //  * A special token "*" that means "any bearer can use the new token,
   138    //    including anonymous".
   139    //
   140    // "REQUESTOR" is typically used here for rules that allow requestors to
   141    // impersonate someone else. The corresponding tokens have the requestor as
   142    // the only allowed audience.
   143    //
   144    // The groups specified here are NOT expanded when MintDelegationTokenRequest
   145    // is evaluated. To match the rule, MintDelegationTokenRequest must specify
   146    // subset of 'allowed_audience' groups explicitly in 'audience' field.
   147    repeated string allowed_audience = 5;
   148  
   149    // A set of services that should be able to accept the new token.
   150    //
   151    // Matched against 'services' field of MintDelegationTokenRequest.
   152    //
   153    // Each element is either:
   154    //  * A service identity string ("service:<id>").
   155    //  * A special token "*" that mean "any LUCI service should accept the
   156    //    token".
   157    repeated string target_service = 6;
   158  
   159    // Maximum allowed validity duration (sec) of minted delegation tokens.
   160    //
   161    // Default is 12 hours.
   162    int64 max_validity_duration = 7;
   163  }
   164  
   165  
   166  // ServiceAccountsProjectMapping defines what service accounts belong to what
   167  // LUCI projects.
   168  //
   169  // Used by MintServiceAccountToken RPC as a final authorization step, after
   170  // checking that the usage of the service account is allowed by Realms ACLs.
   171  //
   172  // This is a stop gap solution until the Token Server learns to use
   173  // project-scoped accounts when calling Cloud IAM. Once this happens, we can
   174  // move information contained in ServiceAccountsProjectMapping into Cloud IAM
   175  // permissions.
   176  //
   177  // This message is stored as project_owned_accounts.cfg in luci-config.
   178  message ServiceAccountsProjectMapping {
   179    message Mapping {
   180      // Names of LUCI projects.
   181      repeated string project = 1;
   182      // Emails of service accounts allowed to be used by all these projects.
   183      repeated string service_account = 2;
   184    }
   185  
   186    // Each entry maps a bunch of service accounts to one or more projects.
   187    repeated Mapping mapping = 1;
   188  
   189    // A list of LUCI project names for which service account impersonation should
   190    // be done using LUCI project-scoped account as a delegate. This allows to
   191    // move "LUCI project => allowed service account" mapping into IAM policies,
   192    // making `mapping` above obsolete.
   193    //
   194    // If a LUCI project belongs to this list, it must not have any entries in
   195    // the `mapping` field above.
   196    repeated string use_project_scoped_account = 2;
   197  }