Skip to content

Commit 463b3d9

Browse files
authored
feat: Added ALB authentication feature with OpenID Connect (eg, Auth0) (#122)
1 parent 08885d1 commit 463b3d9

File tree

3 files changed

+28
-0
lines changed

3 files changed

+28
-0
lines changed

README.md

+20
Original file line numberDiff line numberDiff line change
@@ -100,6 +100,25 @@ Make sure that both private and public subnets were created in the same set of a
100100

101101
If all provided subnets are public (no NAT gateway) then `ecs_service_assign_public_ip` should be set to `true`.
102102

103+
104+
### Secure Atlantis with ALB Built-in Authentication and Auth0
105+
106+
You can use service like [Auth0](https://www.auth0.com) to secure access to Atlantis and require authentication on ALB. To enable this, you need to create Auth0 application and provide correct arguments to Atlantis module. Make sure to update application hostname, client id and client secret:
107+
108+
```
109+
alb_authenticate_oidc = {
110+
issuer = "https://youruser.eu.auth0.com/"
111+
token_endpoint = "https://youruser.eu.auth0.com/oauth/token"
112+
user_info_endpoint = "https://youruser.eu.auth0.com/userinfo"
113+
authorization_endpoint = "https://youruser.eu.auth0.com/authorize"
114+
authentication_request_extra_params = {}
115+
client_id = "clientid"
116+
client_secret = "secret123"
117+
}
118+
```
119+
120+
Read more in [this post](https://medium.com/@sandrinodm/securing-your-applications-with-aws-alb-built-in-authentication-and-auth0-310ad84c8595).
121+
103122
## Notes
104123

105124
1. AWS Route53 zone is not created by this module, so zone specified as a value in `route53_zone_name` should be created before using this module. Check documentation for [aws_route53_zone](https://www.terraform.io/docs/providers/aws/r/route53_zone.html).
@@ -130,6 +149,7 @@ No requirements.
130149
| Name | Description | Type | Default | Required |
131150
|------|-------------|------|---------|:--------:|
132151
| acm\_certificate\_domain\_name | Route53 domain name to use for ACM certificate. Route53 zone for this domain should be created in advance. Specify if it is different from value in `route53_zone_name` | `string` | `""` | no |
152+
| alb\_authenticate\_oidc | Map of Authenticate OIDC parameters to protect ALB (eg, using Auth0). See https://www.terraform.io/docs/providers/aws/r/lb_listener.html#authenticate-oidc-action | `any` | `{}` | no |
133153
| alb\_ingress\_cidr\_blocks | List of IPv4 CIDR ranges to use on all ingress rules of the ALB. | `list(string)` | <pre>[<br> "0.0.0.0/0"<br>]</pre> | no |
134154
| alb\_log\_bucket\_name | S3 bucket (externally created) for storing load balancer access logs. Required if alb\_logging\_enabled is true. | `string` | `""` | no |
135155
| alb\_log\_location\_prefix | S3 prefix within the log\_bucket\_name under which logs are stored. | `string` | `""` | no |

main.tf

+2
Original file line numberDiff line numberDiff line change
@@ -199,6 +199,8 @@ module "alb" {
199199
port = 443
200200
protocol = "HTTPS"
201201
certificate_arn = var.certificate_arn == "" ? module.acm.this_acm_certificate_arn : var.certificate_arn
202+
action_type = length(keys(var.alb_authenticate_oidc)) > 0 ? "authenticate-oidc" : "forward"
203+
authenticate_oidc = var.alb_authenticate_oidc
202204
},
203205
]
204206

variables.tf

+6
Original file line numberDiff line numberDiff line change
@@ -90,6 +90,12 @@ variable "alb_logging_enabled" {
9090
default = false
9191
}
9292

93+
variable "alb_authenticate_oidc" {
94+
description = "Map of Authenticate OIDC parameters to protect ALB (eg, using Auth0). See https://www.terraform.io/docs/providers/aws/r/lb_listener.html#authenticate-oidc-action"
95+
type = any
96+
default = {}
97+
}
98+
9399
# ACM
94100
variable "certificate_arn" {
95101
description = "ARN of certificate issued by AWS ACM. If empty, a new ACM certificate will be created and validated using Route53 DNS"

0 commit comments

Comments
 (0)