Skip to content

Commit d16aa4f

Browse files
authored
improvement: user-auth allow customizing UI url (#57)
1 parent defcc33 commit d16aa4f

File tree

3 files changed

+19
-13
lines changed

3 files changed

+19
-13
lines changed

modules/user_auth/README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,7 @@ No requirements.
4040
| frontend\_service\_domain | Domain of the frontend | `string` | n/a | yes |
4141
| jwks\_content | The content of a JWKS file for Oathkeeper | `string` | n/a | yes |
4242
| k8s\_local\_exec\_context | Custom resource (Oathkeeper Rules are created using local-exec with kubectl), if not specified it will target your current context from kubeconfig | `string` | `""` | no |
43+
| kratos\_default\_redirect\_ui\_path | Setting the default path after self-service flows(login/signup/verify/settings), kratos will redirect you to frontend | `string` | `"/dashboard"` | no |
4344
| kratos\_secret\_name | Secret name for kratos to access Database credentials, created from pre-k8s script | `string` | n/a | yes |
4445
| kratos\_values\_override | a map of parameters to override the kratos-values.yml | `map(any)` | `{}` | no |
4546
| kubectl\_extra\_args | Arguments that will be passed to kubectl when using the local executor in cases where the terraform k8s support is not enough | `string` | n/a | yes |

modules/user_auth/main.tf

Lines changed: 12 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ locals {
1414
}
1515
}
1616

17+
default_flow_return_url = "https://${var.frontend_service_domain}${var.kratos_default_redirect_ui_path}"
1718
kratos_values_override = {
1819
secret = {
1920
nameOverride = var.kratos_secret_name
@@ -36,40 +37,40 @@ locals {
3637
settings = {
3738
ui_url = "https://${var.frontend_service_domain}/auth/settings"
3839
after = {
39-
default_browser_return_url = "https://${var.frontend_service_domain}/dashboard"
40+
default_browser_return_url = local.default_flow_return_url
4041
}
4142
}
4243

4344
verification = {
4445
ui_url = "https://${var.frontend_service_domain}/auth/verify"
4546
after = {
46-
default_browser_return_url = "https://${var.frontend_service_domain}/dashboard"
47+
default_browser_return_url = local.default_flow_return_url
4748
}
4849
}
4950

5051
recovery = {
5152
ui_url = "https://${var.frontend_service_domain}/auth/recovery"
5253
after = {
53-
default_browser_return_url = "https://${var.frontend_service_domain}/dashboard"
54+
default_browser_return_url = local.default_flow_return_url
5455
}
5556
}
5657

5758
login = {
5859
ui_url = "https://${var.frontend_service_domain}/auth/login"
5960
after = {
60-
default_browser_return_url = "https://${var.frontend_service_domain}/dashboard"
61+
default_browser_return_url = local.default_flow_return_url
6162
}
6263
}
6364

6465
registration = {
6566
ui_url = "https://${var.frontend_service_domain}/auth/registration"
6667
after = {
67-
default_browser_return_url = "https://${var.frontend_service_domain}/dashboard"
68+
default_browser_return_url = local.default_flow_return_url
6869
password = {
69-
default_browser_return_url = "https://${var.frontend_service_domain}/dashboard"
70+
default_browser_return_url = local.default_flow_return_url
7071
}
7172
oidc = {
72-
default_browser_return_url = "https://${var.frontend_service_domain}/dashboard"
73+
default_browser_return_url = local.default_flow_return_url
7374
}
7475
}
7576
}
@@ -94,8 +95,6 @@ locals {
9495
proxy = {
9596
hosts = [var.backend_service_domain]
9697
tls = {
97-
// HCL doesnt allow map inside a list, you will get the following error with a list
98-
// `<.host>: can't evaluate field host in type interface {}`
9998
"0" = {
10099
host = [var.backend_service_domain]
101100
}
@@ -162,8 +161,8 @@ resource "null_resource" "external_secret_custom_resource" {
162161
}
163162

164163
module "kratos_config" {
165-
source = "cloudposse/config/yaml"
166-
version = "0.7.0"
164+
source = "cloudposse/config/yaml"
165+
version = "0.7.0"
167166

168167
map_config_local_base_path = "${path.module}/files"
169168
map_config_paths = ["kratos-values.yml"]
@@ -217,8 +216,8 @@ resource "null_resource" "oathkeeper_kratos_proxy_rules" {
217216
}
218217

219218
module "oathkeeper_config" {
220-
source = "cloudposse/config/yaml"
221-
version = "0.7.0"
219+
source = "cloudposse/config/yaml"
220+
version = "0.7.0"
222221

223222
map_config_local_base_path = "${path.module}/files"
224223
map_config_paths = ["oathkeeper-values.yml"]

modules/user_auth/variables.tf

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -87,3 +87,9 @@ variable "oathkeeper_values_override" {
8787
type = map(any)
8888
default = {}
8989
}
90+
91+
variable "kratos_default_redirect_ui_path" {
92+
description = "Setting the default path after self-service flows(login/signup/verify/settings), kratos will redirect you to frontend"
93+
type = string
94+
default = "/dashboard"
95+
}

0 commit comments

Comments
 (0)