-
Notifications
You must be signed in to change notification settings - Fork 5
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
632c21c
commit 9dfb429
Showing
22 changed files
with
548 additions
and
25 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
# AWS SSO with Zoho | ||
|
||
**Type:** Live |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
## Usage | ||
|
||
### Sign-in URL | ||
|
||
For IDP-initiated logins, the `zoho_sign_in_url` variable must be provided. | ||
|
||
This is not found in the Zoho web UI and must be constructed manually. | ||
|
||
It is of the form `https://accounts.zoho.com/samlauthrequest/<domain>?serviceurl=<zoho_service>` where | ||
|
||
- `<domain>` is a domain **that has been verified with Zoho** | ||
|
||
- `<zoho_service>` is the `https` url of a Zoho service (e.g., `https://one.zoho.com`) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
variable "environment" { | ||
description = "The name of the environment the infrastructure is being deployed into. #injected" | ||
type = string | ||
default = null | ||
} | ||
|
||
variable "pf_root_module" { | ||
description = "The name of the root Panfactum module in the module tree. #injected" | ||
type = string | ||
default = "authentik_aws_sso" | ||
} | ||
|
||
variable "pf_module" { | ||
description = "The name of the Panfactum module where the containing resources are directly defined. #injected" | ||
type = string | ||
default = "authentik_aws_sso" | ||
} | ||
|
||
variable "region" { | ||
description = "The region the infrastructure is being deployed into. #injected" | ||
type = string | ||
default = null | ||
} | ||
|
||
variable "extra_tags" { | ||
description = "Extra tags or labels to add to the created resources. #injected" | ||
type = map(string) | ||
default = {} | ||
} | ||
|
||
variable "is_local" { | ||
description = "Whether this module is a part of a local development deployment #injected" | ||
type = bool | ||
default = false | ||
} | ||
|
||
variable "pf_stack_version" { | ||
description = "Which version of the Panfactum stack is being used (git ref) #injected" | ||
type = string | ||
default = "main" | ||
} | ||
|
||
variable "pf_stack_commit" { | ||
description = "The commit hash for the version of the Panfactum stack being used #injected" | ||
type = string | ||
default = "xxxxxxxxxxxxxxxxxxxxxxxxxxx" | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,144 @@ | ||
terraform { | ||
required_providers { | ||
authentik = { | ||
source = "goauthentik/authentik" | ||
version = "2024.2.0" | ||
} | ||
kubernetes = { | ||
source = "hashicorp/kubernetes" | ||
version = "2.27.0" | ||
} | ||
random = { | ||
source = "hashicorp/random" | ||
version = "3.6.0" | ||
} | ||
tls = { | ||
source = "hashicorp/tls" | ||
version = "4.0.5" | ||
} | ||
} | ||
} | ||
|
||
|
||
########################################################################### | ||
## Upload the logo | ||
########################################################################### | ||
|
||
resource "random_id" "logo" { | ||
prefix = "zoho-" | ||
byte_length = 8 | ||
} | ||
|
||
resource "kubernetes_config_map_v1_data" "media" { | ||
metadata { | ||
name = var.media_configmap | ||
namespace = var.authentik_namespace | ||
} | ||
data = { | ||
"${random_id.logo.hex}.svg" = file("${path.module}/zoho.svg") | ||
} | ||
field_manager = random_id.logo.hex | ||
force = true | ||
} | ||
|
||
########################################################################### | ||
## Cert Config | ||
########################################################################### | ||
|
||
// These certs are only used for their random cryptographic | ||
// material to sign the SAML assertions. There is no | ||
// need to use cert-manager to manage them, | ||
// especially since they need to be manually uploaded to AWS | ||
// every time they rotate | ||
resource "tls_private_key" "signing" { | ||
algorithm = "RSA" | ||
rsa_bits = 4096 | ||
} | ||
|
||
resource "tls_self_signed_cert" "signing" { | ||
private_key_pem = tls_private_key.signing.private_key_pem | ||
subject { | ||
common_name = var.authentik_domain | ||
organization = var.organization_name | ||
} | ||
validity_period_hours = 24 * 365 * 10 | ||
allowed_uses = [ | ||
"key_encipherment", | ||
"digital_signature", | ||
"server_auth", | ||
] | ||
} | ||
|
||
resource "authentik_certificate_key_pair" "signing" { | ||
name = "zoho-signing-certs" | ||
certificate_data = tls_self_signed_cert.signing.cert_pem | ||
key_data = tls_private_key.signing.private_key_pem | ||
} | ||
|
||
########################################################################### | ||
## IdP Config | ||
########################################################################### | ||
|
||
|
||
data "authentik_flow" "default-authorization-flow" { | ||
slug = "default-provider-authorization-implicit-consent" | ||
} | ||
|
||
data "authentik_property_mapping_saml" "email" { | ||
managed = "goauthentik.io/providers/saml/email" | ||
} | ||
|
||
resource "authentik_provider_saml" "zoho" { | ||
name = "zoho" | ||
authorization_flow = data.authentik_flow.default-authorization-flow.id | ||
acs_url = var.zoho_acs_url | ||
sp_binding = "post" | ||
issuer = var.zoho_issuer | ||
name_id_mapping = data.authentik_property_mapping_saml.email.id | ||
signing_kp = authentik_certificate_key_pair.signing.id | ||
} | ||
|
||
data "authentik_provider_saml_metadata" "zoho" { | ||
provider_id = authentik_provider_saml.zoho.id | ||
} | ||
|
||
|
||
resource "authentik_application" "zoho" { | ||
name = "zoho" | ||
slug = "zoho" | ||
protocol_provider = authentik_provider_saml.zoho.id | ||
meta_launch_url = var.zoho_sign_in_url | ||
meta_description = var.ui_description | ||
meta_publisher = "Panfactum" | ||
meta_icon = "/media/public/${random_id.logo.hex}.svg" | ||
group = var.ui_group | ||
open_in_new_tab = true | ||
} | ||
|
||
|
||
data "authentik_group" "superusers" { | ||
name = "superusers" | ||
} | ||
|
||
resource "authentik_policy_binding" "superuser_access" { | ||
target = authentik_application.zoho.uuid | ||
group = data.authentik_group.superusers.id | ||
order = 0 | ||
} | ||
|
||
|
||
data "authentik_group" "group" { | ||
for_each = var.allowed_groups | ||
name = each.key | ||
} | ||
|
||
resource "authentik_policy_binding" "access" { | ||
for_each = var.allowed_groups | ||
target = authentik_application.zoho.uuid | ||
group = data.authentik_group.group[each.key].id | ||
order = 10 | ||
} | ||
|
||
|
||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
output "saml_metadata" { | ||
value = data.authentik_provider_saml_metadata.zoho.metadata | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,53 @@ | ||
variable "zoho_acs_url" { | ||
description = "The ACS url provided by Zoho when configuring an external identity provider" | ||
type = string | ||
} | ||
variable "zoho_sign_in_url" { | ||
description = "The sign-in url provided by Zoho when configuring an external identity provider" | ||
type = string | ||
} | ||
|
||
variable "zoho_issuer" { | ||
description = "The issuer provided by Zoho when configuring an external identity provider" | ||
type = string | ||
default = "zoho.com" | ||
} | ||
|
||
variable "authentik_domain" { | ||
description = "The domain name of the authentik instance" | ||
type = string | ||
} | ||
|
||
variable "organization_name" { | ||
description = "The name of your organization" | ||
type = string | ||
} | ||
|
||
variable "ui_description" { | ||
description = "The description to display in the Authentik web dashboard" | ||
type = string | ||
default = "Zoho" | ||
} | ||
|
||
variable "ui_group" { | ||
description = "The section in the Authentik web dashboard that this will appear in" | ||
type = string | ||
default = "Admin" | ||
} | ||
|
||
variable "allowed_groups" { | ||
description = "Only members of these groups can access AWS" | ||
type = set(string) | ||
default = [] | ||
} | ||
|
||
variable "media_configmap" { | ||
description = "The configmap holding the static media that Authentik will use" | ||
type = string | ||
} | ||
|
||
variable "authentik_namespace" { | ||
description = "The kubernetes namespace where Authentik is deployed" | ||
type = string | ||
} | ||
|
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.