aboutsummaryrefslogtreecommitdiff
path: root/README.md
diff options
context:
space:
mode:
authorMike Crute <mike@crute.us>2021-11-16 21:50:31 -0800
committerMike Crute <mike@crute.us>2021-11-17 07:56:17 -0800
commit73ab23b5f74174ec6b6a988103306eeec389d5a8 (patch)
treeed56d604a22d36ca9bf658064442d29f0e0a18b0 /README.md
parentcc58a3da7d647de8520e33dc4356672d2ed1a366 (diff)
downloadcloud-identity-broker-73ab23b5f74174ec6b6a988103306eeec389d5a8.tar.bz2
cloud-identity-broker-73ab23b5f74174ec6b6a988103306eeec389d5a8.tar.xz
cloud-identity-broker-73ab23b5f74174ec6b6a988103306eeec389d5a8.zip
Add some docs
Diffstat (limited to 'README.md')
-rw-r--r--README.md205
1 files changed, 203 insertions, 2 deletions
diff --git a/README.md b/README.md
index ca08bbd..1a892a5 100644
--- a/README.md
+++ b/README.md
@@ -1,6 +1,207 @@
1# Cloud Identity Broker 1# Cloud Identity Broker
2 2
3// TODO: https://docs.gitlab.com/ee/api/jobs.html#get-job-tokens-job 3This is a cloud identity broker. Identity brokers exist to bridge
4// TODO: Admin UI 4authentication from one system into authentication to another system. In the
5case of this broker it bridges GitHub and GitLab authentication into temporary
6credentials for cloud providers. The broker has an interactive API that can be
7used in a web browser as well as a JSON/REST API that can be consumed
8programmatically.
5 9
10The reason this broker exists is to provide one secured location for long-lived
11cloud provider credentials that can be easily consumed from development
12environments and build systems while limiting the scope of access and time frame
13of access those systems have to cloud resources. This helps to increase the
14security of those accounts and reduce the risk of abuse. All access through the
15broker is chained to an authenticated and authorized user account and all
16access through those user accounts are logged for auditing. All credentials
17returned by the broker have a strict time limit after which they are useless.
6 18
19This broker started life as a piece of internal infrastructure specific to AWS
20that has been re-written and open sourced with the goal to support multiple
21clouds.
22
23For documentation the REST API look at the `README_BROKER.md` file.
24
25## Contributing
26
27Contributions are welcomed. Please send contributions to mike-at-crute-dot-us
28either through email in `git format-patch` format or send a link to a git repo
29and branch name that the author can pull and merge.
30
31If you're reading this on one of the author's git forge accounts (GitHub,
32GitLab, sr.ht, etc...) feel free to open a pull/merge request with your
33changes.
34
35The author reserves the right to request changes to contributions before
36merging them or to not merge them at all but will endeavour to be reasonable in
37those requests.
38
39## Building
40
41This requires Go 1.17 or newer to build. Provided that a simple `make` should
42create a `cloud-identity-broker` binary that's ready to use.
43
44The built binary embeds all of the templates in production mode and will
45require nothing more than the binary itself to run, if running in `--debug`
46mode then the `templates` folder must be available.
47
48## Running
49
50It's complicated, so probably don't?
51
52The application requires some bits of infrastructure to be in place for it to
53run but then can be exposed directly to the internet or put behind a reverse
54proxy. You will need:
55
56- [Mongodb](https://www.mongodb.com/)
57- [Vault](https://www.hashicorp.com/products/vault)
58- [GitHub Oauth Application](https://docs.github.com/en/developers/apps/building-oauth-apps/creating-an-oauth-app)
59- [SSL certificates](https://letsencrypt.org/).
60
61Once the requisite infrastructure (see below) is configured, run the binary
62like so:
63
64```
65VAULT_ROLE_ID="..." \
66VAULT_SECRET_ID="..." \
67VAULT_ADDR="https://your-vault-addr:8200" \
68 ./cloud-identity-broker \
69 --mongodb-uri="mongodb://your-mongodb-host:27017/your-db-name?authSource=admin" \
70 --mongodb-vault-path="database/static-creds/your-cred-name" \
71 --github-oauth-vault-path="service/service-name/github-oauth" \
72 web
73```
74
75### SSL Certificates
76
77SSL certificates of a cipher type compatible with Go's SSL library are required
78to run the binary, even in development mode. Obtain those certificates however
79you would normal do so.
80
81Both a key and certificate are required to be stored in the directory
82identified by `--tls-cache-dir` (which defaults to `./ssl/`). Both files should
83be of PEM format with the certificate named `cert.pem` and the key named
84`key.pem`.
85
86### Vault Setup
87
88Configure Vault per the manufacturers instructions. Create an AppRole for the
89identity broker and provide the credentials to the binary using the standard
90Vault environment variables.
91
92The binary will need access to a set of GitHub Oauth client credentials for a
93GitHub Oauth application that is used to authenticate users to the broker.
94Setup an application on GitHub and store the client ID and client secret in a
95JSON document in Vault the vault KV backend with the following format:
96
97```
98{
99 "client-id": "your client id",
100 "client-secret": "your client secret"
101}
102```
103
104Provide the path to this material with the `--github-oauth-vault-path` command
105line argument. You should omit the `kv/data/` prefix to the path.
106
107For each AWS cloud account to which the broker provides access a JSON document
108must be stored in the Vault KV backend. The format of this document is as
109follows. The path to this document is provided (with the `kv/data/` prefix
110omitted) in the `VaultMaterial` field of the `Account` record for the account
111in Mongodb.
112
113```
114{
115 "AccessKeyId": "...",
116 "SecretAccessKey": "...",
117 "Roles": {
118 "account-short-name": {
119 "ARN": "arn:aws:iam::...:role/...",
120 "ExternalId": "..."
121 }
122 }
123}
124```
125
126The fields are:
127
128- `AccessKeyId` which is the access key ID of an IAM user that can assume roles
129 in the target account.
130- `SecretAccessKey` is the secret key for the IAM user identified by the access
131 key ID.
132- `Roles` is a mapping of account `ShortName` to an AWS ARN and ExternalId used
133 for assuming roles. The `ARN` is the role to be assumed and the `ExternalId`
134 is the External ID configured in the role trust policy.
135
136Note that this application does **not** use the AWS Vault backend to assume
137roles due to limitations AWS places on roles assumed using assumed role
138credentials and not user credentials.
139
140Finally the broker will need access to a Mongodb credential. Currently this
141requires a static credential but in the future a dynamic credential will be
142acceptable. Create this credential and pass it in the `--mongodb-vault-path`
143argument. It should have the form `database/static-creds/your-cred-name`.
144
145### Mongodb Setup
146
147The application needs a Mongodb database with at least a `users` collection
148created. The rest are optional.
149
150To create the `users` collection insert a record to the collection that
151contains your GitHub username as the `_id` field and has `IsAdmin` set to true.
152For example:
153
154```
155db.users.insert({ "_id": "mcrute", "IsAdmin": true })
156```
157
158This is adequate to allow login via GitHub for the named user. All other fields
159will be populated automatically by the app.
160
161To create allowed AWS accounts for use in the broker add them to the `accounts`
162collection. Those records have the following form:
163
164```
165{
166 "_id": "acocunt-short-name",
167 "AccountNumber": 12345,
168 "AccountType": "aws",
169 "ConsoleSessionDuration": 21600000000000,
170 "DefaultRegion": "us-west-2",
171 "Name": "Some Description",
172 "Users": [
173 "username1",
174 "username2"
175 ],
176 "VaultMaterial": "some/path/as/above"
177}
178```
179
180- `_id` is the short name of the account. This must also map into a Vault
181 material per above.
182- `AccountNumber` is the AWS account number for the account being brokered.
183- `AccountType` is the string `aws` for now
184- `ConsoleSessionDuration` is the number of nanoseconds a console session can
185 exist before timing out. (Nanoseconds are silly, yes; it's a serialized
186 time.Time)
187- `DefaultRegion` is the region considered default, this is just used as an
188 indicator in the JSON API.
189- `Name` a longer form, descriptive name of the account.
190- `Users` a case-sensitive list of GitHub user names that have access to this
191 account
192- `VaultMaterial` the path to the Vault material that contains the account
193 credentials document, as above.
194
195## To Do
196
197- Allow GitLab CI jobs to auth using [job tokens](https://docs.gitlab.com/ee/api/jobs.html#get-job-tokens-job)
198- Implement an Admin UI, all admin ops are directly on the DB at the moment
199- Support dynamic mongodb credentials
200- Support for other clouds
201 - GCP
202 - OCI
203 - Azure
204
205## Contributors
206
207- [Mike Crute](https://mike.crute.us)