Skip to content

Commit ab5b82b

Browse files
authored
Add logic for copy/paste SSO metadata (#68)
* Add logic for copy/paste SSO metadata Related ticket: fleetdm/fleet#26614 Copying metadata from an IdP and using it to populate a secret value results in malformed yaml. Added logic to add the appropriate number of spaces to the beginning of lines 2+, which results in a properly blocked multiline string. * Add instructions for SSO metadata
1 parent 6e99843 commit ab5b82b

File tree

2 files changed

+14
-5
lines changed

2 files changed

+14
-5
lines changed

README.md

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -10,11 +10,10 @@ This is the starter repository for using [Fleet](https://fleetdm.com) with a Git
1010

1111
2. Add `FLEET_URL` and `FLEET_API_TOKEN` secrets to your new repository's secrets. Learn how [here](https://docs.github.com/en/actions/security-guides/using-secrets-in-github-actions#creating-secrets-for-a-repository). Set `FLEET_URL` to your Fleet instance's URL (ex. https://organization.fleet.com). [Create an API-only user](https://fleetdm.com/docs/using-fleet/fleetctl-cli#create-api-only-user) with the "GitOps" role and set `FLEET_API_TOKEN` to your user's API token. If you're using Fleet Free, set the API-only user's role to global admin.
1212

13-
3. Add `FLEET_GLOBAL_ENROLL_SECRET` secret to your new repository's secrets. The enroll secret must be an alphanumeric string of at least 32 and at most 255 characters.
14-
- If you have a Premium Fleet license, also add `FLEET_WORKSTATIONS_ENROLL_SECRET` and `FLEET_WORKSTATIONS_CANARY_ENROLL_SECRET`.
15-
- If you do not have a Premium Fleet license, delete the `teams` directory.
13+
4. If you are using secrets to manage SSO metadata for Fleet SSO login or MDM SSO login, uncomment lines 22 and 23 in `gitops.sh`.
14+
- If you are using different variable names for your secrets, edit the appropriate line to reflect the correct variable name.
1615

17-
4. In GitHub, enable the `Apply latest configuration to Fleet` GitHub Actions workflow, and run workflow manually. Now, when anyone pushes a new commit to the default branch, the action will run and update Fleet. For pull requests, the workflow will do a dry run only.
16+
5. In GitHub, enable the `Apply latest configuration to Fleet` GitHub Actions workflow, and run workflow manually. Now, when anyone pushes a new commit to the default branch, the action will run and update Fleet. For pull requests, the workflow will do a dry run only.
1817

1918
## GitLab setup
2019

@@ -25,8 +24,11 @@ This is the starter repository for using [Fleet](https://fleetdm.com) with a Git
2524
3. Add `FLEET_GLOBAL_ENROLL_SECRET` secret as a masked CI/CD variable. The enroll secret must be an alphanumeric string of at least 32 and at most 255 characters.
2625
- If you have a Premium Fleet license, also add `FLEET_WORKSTATIONS_ENROLL_SECRET` and `FLEET_WORKSTATIONS_CANARY_ENROLL_SECRET`.
2726
- If you do not have a Premium Fleet license, delete the `teams` directory.
27+
28+
4. If you are using secrets to manage SSO metadata for Fleet SSO login or MDM SSO login, uncomment lines 22 and 23 in `gitops.sh`.
29+
- If you are using different variable names for your secrets, edit the appropriate line to reflect the correct variable name.
2830

29-
4. Now, when anyone pushes a new commit to the default branch, the pipeline will run and update Fleet. For merge requests, the pipeline will do a dry run only.
31+
5. Now, when anyone pushes a new commit to the default branch, the pipeline will run and update Fleet. For merge requests, the pipeline will do a dry run only.
3032

3133
## Configuration options
3234

gitops.sh

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,13 @@ FLEET_DELETE_OTHER_TEAMS="${FLEET_DELETE_OTHER_TEAMS:-true}"
1515
# Validate that global file contains org_settings
1616
grep -Exq "^org_settings:.*" "$FLEET_GLOBAL_FILE"
1717

18+
# Copy/pasting raw SSO metadata into GitHub secrets will result in malformed yaml.
19+
# Adds spaces to all but the first line of metadata keeps the multiline string in bounds.
20+
# See README for more information
21+
22+
# FLEET_SSO_METADATA=$( sed '2,$s/^/ /' <<< "${FLEET_MDM_SSO_METADATA}")
23+
# FLEET_MDM_SSO_METADATA=$( sed '2,$s/^/ /' <<< "${FLEET_MDM_SSO_METADATA}")
24+
1825
if compgen -G "$FLEET_GITOPS_DIR"/teams/*.yml > /dev/null; then
1926
# Validate that every team has a unique name.
2027
# This is a limited check that assumes all team files contain the phrase: `name: <team_name>`

0 commit comments

Comments
 (0)