You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: docs/2.0/docs/pipelines/concepts/cloud-auth.md
+57Lines changed: 57 additions & 0 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -71,3 +71,60 @@ The AWS IAM Role in the Management Account must have permissions to provision ne
71
71
Each child account (e.g., `dev`, `stage`, `prod`, etc.) contains an AWS IAM role that Pipelines can assume from GitHub Actions or GitLab CI using OIDC. This role is automatically provisioned during the [account baseline process](/2.0/docs/accountfactory/guides/vend-aws-account). Once the role is established in the child account, users can submit pull requests/merge requests to add, modify, or delete resources in that account.
72
72
73
73
When a pull request/merge request is created or synchronized, or when changes are pushed to the `main` branch, Pipelines detects the changes, maps them to the appropriate account, assumes the role in the child account, and executes a `terragrunt plan` (for pull requests/merge requests) or `terragrunt apply` (for pushes to `main`).
74
+
75
+
### Fundamentals of OIDC for Publicly Available and Private CI/CD platforms
76
+
77
+
### JWT Token Issuers
78
+
A JWT token is a base64-encoded JSON object that contains three parts: a header, a payload, and a signature. The header typically contains metadata about the token, such as the algorithm used to sign it. The payload contains the claims or assertions made by the issuer, such as the subject (user), audience (intended recipient), and expiration time. The signature is used to verify that the token was issued by a trusted authority and has not been tampered with.
79
+
80
+
Critically, the issuer is a URL that is both specified inside the token, and is used by consumers of the token to fetch the public key used to validate the signature of that same token. Assuming the public key is fetched via HTTPS, there is a valid trust chain that the token was in fact issued by the expected issuer and you have typical cryptographic guarantees it wasn't substituted or tampered with.
81
+
82
+
Typically the issuer is the hostname of the CI/CD platform, such as `https://gitlab.com`, and thus oidc configuration (and public keys) can be fetched from the publicly available route, `https://gitlab.com/.well-known/openid-configuration` etc.
83
+
84
+
If, however, your CI/CD platform is hosted privately, you will need to host the public key and OIDC configuration in a publicly accessible location, such as an S3 bucket, and update the issuer in your CI/CD configuration to point to that location. The diagrams below illustrate both approaches - fetching the keys directly from your CI/CD platform via a public route, or fetching the keys from a public S3 bucket.
85
+
86
+
87
+
#### Publicly Available CI/CD Platforms
88
+
```mermaid
89
+
sequenceDiagram
90
+
participant SCM as SCM (GitLab/GitHub etc.)
91
+
participant SCMPublicRoute as SCM Hostname e.g. gitlab.com
92
+
participant AWSIdP as AWS IdP & STS
93
+
94
+
SCM->>SCM: Generate a public/private key pair
95
+
SCM->>SCM: Generate a JWT and sign with the private key
96
+
SCM->AWSIdP: Send JWT to AWS requesting a role
97
+
AWSIdP->>SCMPublicRoute: Fetch public key via HTTPS <br>(which validates that the SCM is who it says it is)
98
+
SCMPublicRoute->>AWSIdP: Return the public key
99
+
AWSIdP->>AWSIdP: Validate signature on JWT using public key to validate that it was generated by the Issuer
100
+
AWSIdP->>AWSIdP: Inspect JWT Content and ensure it passes trust policies
101
+
AWSIdP->>SCM: Return temporary tokens for the role requested
102
+
103
+
```
104
+
105
+
#### Non-Publicly Available CI/CD Platforms
106
+
107
+
This diagram follows the [recommended approach](https://docs.gitlab.com/ci/cloud_services/aws/#configure-a-non-public-gitlab-instance) from GitLab for private CI/CD platform instances. The guidance is to host the public key in a publicly accessible S3 bucket and update the issuer in the CI/CD configuration.
108
+
109
+
A common alternative approach to re-hosting the public key and OIDC configuration is to update the application firewalls to specifically allow requests to the `.well-known/openid-configuration` endpoint and the JWKS endpoint from the AWS IdP.
110
+
111
+
```mermaid
112
+
sequenceDiagram
113
+
participant SCM as SCM (GitLab/GitHub etc.)
114
+
participant SCMPublicRoute as Public S3 Bucket (e.g. acme-public.s3.com)
115
+
participant AWSIdP as AWS IdP & STS
116
+
117
+
118
+
SCM->>SCM: Generate a public/private key pair
119
+
SCM->>SCMPublicRoute: Publish public key to S3
120
+
SCM->>AwsIdP: Update provider URL in AWS IdP to S3 bucket public URL
121
+
SCM->>SCM: Update issuer to hostname of S3 bucket public URL
122
+
SCM->>SCM: Generate a JWT with updated issuer and sign with the private key
123
+
SCM->>AWSIdP: Send JWT to AWS requesting a role
124
+
AWSIdP->>SCMPublicRoute: Fetch public key via HTTPS <br>(HTTPS is important as it validates that the host is in fact the issuer)
125
+
SCMPublicRoute->>AWSIdP: Return the public key
126
+
AWSIdP->>AWSIdP: Validate signature on JWT using public key to validate that it was generated by the Issuer
127
+
AWSIdP->>AWSIdP: Inspect JWT Content and ensure it passes trust policies
128
+
AWSIdP->>SCM: Return temporary tokens for the role requested
0 commit comments