Skip to content

Commit f02652e

Browse files
feat: Initial release (#9)
Co-authored-by: spbsoluble <[email protected]>
1 parent 982fc94 commit f02652e

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

45 files changed

+4915
-1
lines changed

.github/config/.terraform.lock.hcl

+25
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

.github/config/MODULE.MD

+41
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
## Requirements
2+
3+
| Name | Version |
4+
|------|---------|
5+
| <a name="requirement_terraform"></a> [terraform](#requirement\_terraform) | >= 1.0 |
6+
| <a name="requirement_github"></a> [github](#requirement\_github) | >=6.2 |
7+
8+
## Providers
9+
10+
| Name | Version |
11+
|------|---------|
12+
| <a name="provider_github"></a> [github](#provider\_github) | 6.3.1 |
13+
14+
## Modules
15+
16+
| Name | Source | Version |
17+
|------|--------|---------|
18+
| <a name="module_keyfactor_github_test_environment_12_3_0_kc"></a> [keyfactor\_github\_test\_environment\_12\_3\_0\_kc](#module\_keyfactor\_github\_test\_environment\_12\_3\_0\_kc) | git::ssh://[email protected]/Keyfactor/terraform-module-keyfactor-github-test-environment-ad.git | main |
19+
| <a name="module_keyfactor_github_test_environment_ad_10_5_0"></a> [keyfactor\_github\_test\_environment\_ad\_10\_5\_0](#module\_keyfactor\_github\_test\_environment\_ad\_10\_5\_0) | git::ssh://[email protected]/Keyfactor/terraform-module-keyfactor-github-test-environment-ad.git | main |
20+
21+
## Resources
22+
23+
| Name | Type |
24+
|------|------|
25+
| [github_repository.repo](https://registry.terraform.io/providers/integrations/github/latest/docs/data-sources/repository) | data source |
26+
27+
## Inputs
28+
29+
| Name | Description | Type | Default | Required |
30+
|------|-------------|------|---------|:--------:|
31+
| <a name="input_keyfactor_auth_token_url_12_3_0_KC"></a> [keyfactor\_auth\_token\_url\_12\_3\_0\_KC](#input\_keyfactor\_auth\_token\_url\_12\_3\_0\_KC) | The hostname of the KeyCloak instance to authenticate to for a Keyfactor Command access token | `string` | `"https://int-oidc-lab.eastus2.cloudapp.azure.com:8444/realms/Keyfactor/protocol/openid-connect/token"` | no |
32+
| <a name="input_keyfactor_client_id_12_3_0"></a> [keyfactor\_client\_id\_12\_3\_0](#input\_keyfactor\_client\_id\_12\_3\_0) | The client ID to authenticate with the Keyfactor instance using Keycloak client credentials | `string` | n/a | yes |
33+
| <a name="input_keyfactor_client_secret_12_3_0"></a> [keyfactor\_client\_secret\_12\_3\_0](#input\_keyfactor\_client\_secret\_12\_3\_0) | The client secret to authenticate with the Keyfactor instance using Keycloak client credentials | `string` | n/a | yes |
34+
| <a name="input_keyfactor_hostname_10_5_0"></a> [keyfactor\_hostname\_10\_5\_0](#input\_keyfactor\_hostname\_10\_5\_0) | The hostname of the Keyfactor instance | `string` | `"integrations1050-lab.kfdelivery.com"` | no |
35+
| <a name="input_keyfactor_hostname_12_3_0_KC"></a> [keyfactor\_hostname\_12\_3\_0\_KC](#input\_keyfactor\_hostname\_12\_3\_0\_KC) | The hostname of the Keyfactor instance | `string` | `"int-oidc-lab.eastus2.cloudapp.azure.com"` | no |
36+
| <a name="input_keyfactor_password_10_5_0"></a> [keyfactor\_password\_10\_5\_0](#input\_keyfactor\_password\_10\_5\_0) | The password to authenticate with the Keyfactor instance | `string` | n/a | yes |
37+
| <a name="input_keyfactor_username_10_5_0"></a> [keyfactor\_username\_10\_5\_0](#input\_keyfactor\_username\_10\_5\_0) | The username to authenticate with the Keyfactor instance | `string` | n/a | yes |
38+
39+
## Outputs
40+
41+
No outputs.

.github/config/Makefile

+26
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
.DEFAULT_GOAL := help
2+
3+
##@ Utility
4+
help: ## Display this help
5+
@awk 'BEGIN {FS = ":.*##"; printf "\nUsage:\n make \033[36m\033[0m\n"} /^[a-zA-Z_-]+:.*?##/ { printf " \033[36m%-15s\033[0m %s\n", $$1, $$2 } /^##@/ { printf "\n\033[1m%s\033[0m\n", substr($$0, 5) } ' $(MAKEFILE_LIST)
6+
7+
deps: ## Install deps for macos
8+
@brew install pre-commit tflint terraform terraform-docs
9+
10+
docs: ## Run terraform-docs to update module docs.
11+
@terraform-docs markdown . > MODULE.MD
12+
@terraform-docs markdown table --output-file README.md --output-mode inject .
13+
14+
lint: ## Run tflint
15+
@tflint
16+
17+
validate: ## Run terraform validate
18+
@terraform init --upgrade
19+
@terraform validate
20+
21+
precommit/add: ## Install pre-commit hook
22+
@pre-commit install
23+
24+
precommit/remove: ## Uninstall pre-commit hook
25+
@pre-commit uninstall
26+

.github/config/README.md

+91
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,91 @@
1+
# GitHub Test Environment Setup
2+
3+
This code sets up GitHub environments for testing against Keyfactor Command instances that are configured to use
4+
Active Directory or Keycloak for authentication.
5+
6+
## Requirements
7+
8+
1. Terraform >= 1.0
9+
2. GitHub Provider >= 6.2
10+
3. Keyfactor Command instance(s) configured to use Active Directory or Keycloak for authentication
11+
4. AD or Keycloak credentials for authenticating to the Keyfactor Command instance(s)
12+
5. A GitHub token with access and permissions to the repository where the environments will be created
13+
14+
## Adding a new environment
15+
16+
Modify the `environments.tf` file to include the new environment module. The module should be named appropriately.
17+
Example:
18+
19+
### Active Directory Environment
20+
21+
```hcl
22+
module "keyfactor_github_test_environment_ad_10_5_0" {
23+
source = "git::ssh://[email protected]/Keyfactor/terraform-module-keyfactor-github-test-environment-ad.git?ref=main"
24+
25+
gh_environment_name = "KFC_10_5_0" # Keyfactor Command 10.5.0 environment using Active Directory(/Basic Auth)
26+
gh_repo_name = data.github_repository.repo.name
27+
keyfactor_hostname = var.keyfactor_hostname_10_5_0
28+
keyfactor_username = var.keyfactor_username_AD
29+
keyfactor_password = var.keyfactor_password_AD
30+
}
31+
```
32+
33+
### oAuth Client Environment
34+
35+
```hcl
36+
module "keyfactor_github_test_environment_12_3_0_kc" {
37+
source = "git::ssh://[email protected]/Keyfactor/terraform-module-keyfactor-github-test-environment-kc.git?ref=main"
38+
39+
gh_environment_name = "KFC_12_3_0_KC" # Keyfactor Command 12.3.0 environment using Keycloak
40+
gh_repo_name = data.github_repository.repo.name
41+
keyfactor_hostname = var.keyfactor_hostname_12_3_0_OAUTH
42+
keyfactor_auth_token_url = var.keyfactor_auth_token_url
43+
keyfactor_client_id = var.keyfactor_client_id
44+
keyfactor_client_secret = var.keyfactor_client_secret
45+
keyfactor_tls_skip_verify = true
46+
}
47+
```
48+
49+
<!-- BEGIN_TF_DOCS -->
50+
## Requirements
51+
52+
| Name | Version |
53+
|------|---------|
54+
| <a name="requirement_terraform"></a> [terraform](#requirement\_terraform) | >= 1.0 |
55+
| <a name="requirement_github"></a> [github](#requirement\_github) | >=6.2 |
56+
57+
## Providers
58+
59+
| Name | Version |
60+
|------|---------|
61+
| <a name="provider_github"></a> [github](#provider\_github) | 6.3.1 |
62+
63+
## Modules
64+
65+
| Name | Source | Version |
66+
|------|--------|---------|
67+
| <a name="module_keyfactor_github_test_environment_12_3_0_kc"></a> [keyfactor\_github\_test\_environment\_12\_3\_0\_kc](#module\_keyfactor\_github\_test\_environment\_12\_3\_0\_kc) | git::ssh://[email protected]/Keyfactor/terraform-module-keyfactor-github-test-environment-ad.git | main |
68+
| <a name="module_keyfactor_github_test_environment_ad_10_5_0"></a> [keyfactor\_github\_test\_environment\_ad\_10\_5\_0](#module\_keyfactor\_github\_test\_environment\_ad\_10\_5\_0) | git::ssh://[email protected]/Keyfactor/terraform-module-keyfactor-github-test-environment-ad.git | main |
69+
70+
## Resources
71+
72+
| Name | Type |
73+
|------|------|
74+
| [github_repository.repo](https://registry.terraform.io/providers/integrations/github/latest/docs/data-sources/repository) | data source |
75+
76+
## Inputs
77+
78+
| Name | Description | Type | Default | Required |
79+
|------|-------------|------|---------|:--------:|
80+
| <a name="input_keyfactor_auth_token_url_12_3_0_KC"></a> [keyfactor\_auth\_token\_url\_12\_3\_0\_KC](#input\_keyfactor\_auth\_token\_url\_12\_3\_0\_KC) | The hostname of the KeyCloak instance to authenticate to for a Keyfactor Command access token | `string` | `"https://int-oidc-lab.eastus2.cloudapp.azure.com:8444/realms/Keyfactor/protocol/openid-connect/token"` | no |
81+
| <a name="input_keyfactor_client_id_12_3_0"></a> [keyfactor\_client\_id\_12\_3\_0](#input\_keyfactor\_client\_id\_12\_3\_0) | The client ID to authenticate with the Keyfactor instance using Keycloak client credentials | `string` | n/a | yes |
82+
| <a name="input_keyfactor_client_secret_12_3_0"></a> [keyfactor\_client\_secret\_12\_3\_0](#input\_keyfactor\_client\_secret\_12\_3\_0) | The client secret to authenticate with the Keyfactor instance using Keycloak client credentials | `string` | n/a | yes |
83+
| <a name="input_keyfactor_hostname_10_5_0"></a> [keyfactor\_hostname\_10\_5\_0](#input\_keyfactor\_hostname\_10\_5\_0) | The hostname of the Keyfactor instance | `string` | `"integrations1050-lab.kfdelivery.com"` | no |
84+
| <a name="input_keyfactor_hostname_12_3_0_KC"></a> [keyfactor\_hostname\_12\_3\_0\_KC](#input\_keyfactor\_hostname\_12\_3\_0\_KC) | The hostname of the Keyfactor instance | `string` | `"int-oidc-lab.eastus2.cloudapp.azure.com"` | no |
85+
| <a name="input_keyfactor_password_10_5_0"></a> [keyfactor\_password\_10\_5\_0](#input\_keyfactor\_password\_10\_5\_0) | The password to authenticate with the Keyfactor instance | `string` | n/a | yes |
86+
| <a name="input_keyfactor_username_10_5_0"></a> [keyfactor\_username\_10\_5\_0](#input\_keyfactor\_username\_10\_5\_0) | The username to authenticate with the Keyfactor instance | `string` | n/a | yes |
87+
88+
## Outputs
89+
90+
No outputs.
91+
<!-- END_TF_DOCS -->

.github/config/environments.tf

+35
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
module "keyfactor_github_test_environment_ad_10_5_0" {
2+
source = "git::ssh://[email protected]/Keyfactor/terraform-module-keyfactor-github-test-environment-ad.git?ref=main"
3+
4+
gh_environment_name = "KFC_10_5_0"
5+
gh_repo_name = data.github_repository.repo.name
6+
keyfactor_hostname = var.keyfactor_hostname_10_5_0
7+
keyfactor_username = var.keyfactor_username_10_5_0
8+
keyfactor_password = var.keyfactor_password_10_5_0
9+
keyfactor_config_file = base64encode(file("${path.module}/command_config.json"))
10+
}
11+
12+
# module "keyfactor_github_test_environment_11_5_0_kc" {
13+
# source = "git::ssh://[email protected]/Keyfactor/terraform-module-keyfactor-github-test-environment-kc.git?ref=main"
14+
#
15+
# gh_environment_name = "KFC_11_5_0_KC"
16+
# gh_repo_name = data.github_repository.repo.name
17+
# keyfactor_hostname = var.keyfactor_hostname_11_5_0_KC
18+
# keyfactor_client_id = var.keyfactor_client_id_11_5_0
19+
# keyfactor_client_secret = var.keyfactor_client_secret_11_5_0
20+
# keyfactor_auth_hostname = var.keyfactor_auth_hostname_11_5_0_KC
21+
# keyfactor_tls_skip_verify = true
22+
# }
23+
24+
module "keyfactor_github_test_environment_12_3_0_kc" {
25+
source = "git::ssh://[email protected]/Keyfactor/terraform-module-keyfactor-github-test-environment-ad.git?ref=main"
26+
27+
gh_environment_name = "KFC_12_3_0_KC"
28+
gh_repo_name = data.github_repository.repo.name
29+
keyfactor_hostname = var.keyfactor_hostname_12_3_0_KC
30+
keyfactor_auth_token_url = var.keyfactor_auth_token_url_12_3_0_KC
31+
keyfactor_client_id = var.keyfactor_client_id_12_3_0
32+
keyfactor_client_secret = var.keyfactor_client_secret_12_3_0
33+
keyfactor_tls_skip_verify = true
34+
keyfactor_config_file = base64encode(file("${path.module}/command_config.json"))
35+
}

.github/config/providers.tf

+20
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
terraform {
2+
required_version = ">= 1.0"
3+
required_providers {
4+
github = {
5+
source = "integrations/github"
6+
version = ">=6.2"
7+
}
8+
}
9+
backend "azurerm" {
10+
resource_group_name = "integrations-infra"
11+
storage_account_name = "integrationstfstate"
12+
container_name = "tfstate"
13+
key = "github/repos/keyfactor-auth-client-go.tfstate"
14+
}
15+
}
16+
17+
provider "github" {
18+
# Configuration options
19+
owner = "Keyfactor"
20+
}

.github/config/repo.tf

+3
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
data "github_repository" "repo" {
2+
name = "keyfactor-auth-client-go"
3+
}

.github/config/variables.tf

+38
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
variable "keyfactor_hostname_10_5_0" {
2+
description = "The hostname of the Keyfactor instance"
3+
type = string
4+
default = "integrations1050-lab.kfdelivery.com"
5+
}
6+
7+
variable "keyfactor_username_10_5_0" {
8+
description = "The username to authenticate with the Keyfactor instance"
9+
type = string
10+
}
11+
12+
variable "keyfactor_password_10_5_0" {
13+
description = "The password to authenticate with the Keyfactor instance"
14+
type = string
15+
}
16+
17+
variable "keyfactor_client_id_12_3_0" {
18+
description = "The client ID to authenticate with the Keyfactor instance using Keycloak client credentials"
19+
type = string
20+
}
21+
22+
variable "keyfactor_client_secret_12_3_0" {
23+
description = "The client secret to authenticate with the Keyfactor instance using Keycloak client credentials"
24+
type = string
25+
}
26+
27+
variable "keyfactor_hostname_12_3_0_KC" {
28+
description = "The hostname of the Keyfactor instance"
29+
type = string
30+
default = "int-oidc-lab.eastus2.cloudapp.azure.com"
31+
}
32+
33+
variable "keyfactor_auth_token_url_12_3_0_KC" {
34+
description = "The hostname of the KeyCloak instance to authenticate to for a Keyfactor Command access token"
35+
type = string
36+
default = "https://int-oidc-lab.eastus2.cloudapp.azure.com:8444/realms/Keyfactor/protocol/openid-connect/token"
37+
}
38+

.github/dependabot.yml

+12
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
# See GitHub's documentation for more information on this file:
2+
# https://docs.github.com/en/code-security/supply-chain-security/keeping-your-dependencies-updated-automatically/configuration-options-for-dependency-updates
3+
version: 2
4+
updates:
5+
- package-ecosystem: "github-actions"
6+
directory: "/"
7+
schedule:
8+
interval: "daily"
9+
- package-ecosystem: "gomod"
10+
directory: "/"
11+
schedule:
12+
interval: "daily"

.github/workflows/go_tests.yml

+49
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,49 @@
1+
name: Go Test Workflow
2+
3+
on:
4+
push:
5+
workflow_dispatch:
6+
7+
jobs:
8+
test:
9+
name: Run tests
10+
runs-on: kf-auth-client-runner-set
11+
strategy:
12+
matrix:
13+
environment: [ "KFC_10_5_0", "KFC_12_3_0_KC"]
14+
environment: ${{ matrix.environment }}
15+
steps:
16+
- name: Check out code
17+
uses: actions/checkout@v3
18+
19+
- name: Set up Go
20+
uses: actions/setup-go@v3
21+
with:
22+
go-version: 1.22
23+
24+
- name: Get Public IP
25+
run: curl -s https://api.ipify.org
26+
27+
- name: Validate lab cert is present
28+
run: |
29+
cat lib/certs/int-oidc-lab.eastus2.cloudapp.azure.com.crt
30+
31+
- name: Run tests
32+
run: |
33+
if [ -n "${{ secrets.KEYFACTOR_AUTH_CONFIG_B64 }}" ]; then
34+
mkdir -p ~/.keyfactor
35+
echo "${{ secrets.KEYFACTOR_AUTH_CONFIG_B64 }}" | base64 --decode > ~/.keyfactor/command_config.json
36+
fi
37+
go test -v -cover ./auth_providers/...
38+
env:
39+
KEYFACTOR_PASSWORD: ${{ secrets.KEYFACTOR_PASSWORD }}
40+
KEYFACTOR_USERNAME: ${{ secrets.KEYFACTOR_USERNAME }}
41+
KEYFACTOR_AUTH_CONFIG_B64: ${{ secrets.KEYFACTOR_AUTH_CONFIG_B64 }}
42+
KEYFACTOR_AUTH_CLIENT_ID: ${{ secrets.KEYFACTOR_AUTH_CLIENT_ID }}
43+
KEYFACTOR_AUTH_CLIENT_SECRET: ${{ secrets.KEYFACTOR_AUTH_CLIENT_SECRET }}
44+
KEYFACTOR_AUTH_TOKEN_URL: ${{ vars.KEYFACTOR_AUTH_TOKEN_URL }}
45+
KEYFACTOR_HOSTNAME: ${{ vars.KEYFACTOR_HOSTNAME }}
46+
KEYFACTOR_AUTH_HOSTNAME: ${{ vars.KEYFACTOR_AUTH_HOSTNAME }}
47+
KEYFACTOR_SKIP_VERIFY: ${{ vars.KEYFACTOR_SKIP_VERIFY }}
48+
TEST_KEYFACTOR_AD_AUTH: ${{ vars.TEST_KEYFACTOR_AD_AUTH }}
49+
TEST_KEYFACTOR_KC_AUTH: ${{ vars.TEST_KEYFACTOR_KC_AUTH }}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
name: Keyfactor Bootstrap Workflow
2+
3+
on:
4+
workflow_dispatch:
5+
pull_request:
6+
types: [ opened, closed, synchronize, edited, reopened ]
7+
push:
8+
create:
9+
branches:
10+
- 'release-*.*'
11+
12+
jobs:
13+
call-starter-workflow:
14+
uses: keyfactor/actions/.github/workflows/starter.yml@v3
15+
secrets:
16+
token: ${{ secrets.V2BUILDTOKEN}}
17+
APPROVE_README_PUSH: ${{ secrets.APPROVE_README_PUSH}}
18+
gpg_key: ${{ secrets.KF_GPG_PRIVATE_KEY }}
19+
gpg_pass: ${{ secrets.KF_GPG_PASSPHRASE }}
20+
scan_token: ${{ secrets.SAST_TOKEN }}

0 commit comments

Comments
 (0)