-
Notifications
You must be signed in to change notification settings - Fork 101
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[WIP] Proposal make oathkeeper fully configurable #96
base: master
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -2,34 +2,45 @@ locals { | |
config_mount_path = "/etc/config" | ||
secrets_mount_path = "/etc/secrets" | ||
access_rules_path = "${path.module}/access-rule-oathkeeper.yaml" | ||
} | ||
|
||
data "template_file" "oathkeeper-access-rules"{ | ||
template = file("%{if var.access_rules_path == null}${path.module}/access-rule-oathkeeper.yaml%{else}${var.access_rules_path}%{ endif }") | ||
vars = { | ||
hostname = var.hostname | ||
enable_registration = var.enable_registration | ||
configuration_defaults = yamldecode(file("config-oathkeeper.yaml")) | ||
configuration_default_overrides = { | ||
errors={ | ||
handlers={ | ||
redirect={ | ||
config={ | ||
to="${var.protocol}://${var.hostname}/profile/auth/login" | ||
} | ||
} | ||
} | ||
} | ||
mutators={ | ||
id_token={ | ||
config={ | ||
issuer_url="${var.protocol}://${var.hostname}" | ||
jwk_urls="file://${local.secrets_mount_path}/id_token.jwks.json" | ||
} | ||
} | ||
} | ||
Comment on lines
+6
to
+23
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Hm, I don't really like this. In my opinion, what would be ideal is to, when you need to override something, not touch OML code, but touch a separate yaml data file with the keys you want to override. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. All in all, if we can load an yaml for this local instead of writing into it, then it would be solved There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Then that yaml can be somewhere in the user's project root and OML lives as a submodule, like we do for omigami. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I don't fully understand these comments....
This is exactly the point of this PR you have complete control over ory from outside OML now. E.g. if I wanted to touch some config other than hostname or protocol. I can do that like this:
I never have to touche OML's main.tf nor any other files to do that. I can even load that custom config from a yaml file if I already have an oathkeeper configuration and want to hand over controller of ory to OML. I guess there are a few fine tuning decisions to make as in should we keep support for There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Okay, so as aligned in conversation, the user won't need to change |
||
} | ||
} | ||
|
||
data "template_file" "oathkeeper-config"{ | ||
template = file("${path.module}/config-oathkeeper.yaml") | ||
vars = { | ||
hostname = var.hostname | ||
protocol = var.protocol | ||
config_path = local.config_mount_path | ||
secret_path = local.secrets_mount_path | ||
} | ||
locals { | ||
configuration = merge( | ||
local.configuration_defaults, # lowest precedence | ||
var.configuration_overrides, | ||
local.configuration_default_overrides # highest precedence | ||
) | ||
Comment on lines
+27
to
+32
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Interesting |
||
} | ||
|
||
|
||
resource "kubernetes_config_map" "oathkeeper-configs" { | ||
metadata { | ||
name = "oathkeeper-config" | ||
namespace = var.namespace | ||
} | ||
data = { | ||
"access-rule-oathkeeper.yaml" = data.template_file.oathkeeper-access-rules.rendered | ||
"config-oathkeeper.yaml" = data.template_file.oathkeeper-config.rendered | ||
"access-rule-oathkeeper.yaml" = yamlencode(var.access_rules) | ||
"config-oathkeeper.yaml" = yamlencode(local.configuration) | ||
} | ||
} | ||
|
||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
okay, I like this