Skip to content

Commit

Permalink
Added helm configuration settings
Browse files Browse the repository at this point in the history
Signed-off-by: Gavin Jaeger-Freeborn <[email protected]>
  • Loading branch information
Gavinok committed Oct 31, 2024
1 parent f2e6f29 commit 7790306
Show file tree
Hide file tree
Showing 6 changed files with 42 additions and 26 deletions.
11 changes: 11 additions & 0 deletions charts/vc-authn-oidc/templates/deployment.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,12 @@ spec:
- name: auth-session-ttl
configMap:
name: {{ include "global.fullname" . }}-session-timeout
- name: custom-variable-substitution
configMap:
name: {{ include "global.fullname" . }}-variable-substitution-config
items:
- key: user_variable_substitution.py
path: user_variable_substitution.py
containers:
- name: {{ .Chart.Name }}
securityContext:
Expand Down Expand Up @@ -72,6 +78,8 @@ spec:
value: {{ .Values.controller.presentationExpireTime | quote }}
# - name: CONTROLLER_SESSION_TIMEOUT_CONFIG_FILE
# value: /home/aries/sessiontimeout.json
- name: CONTROLLER_VARIABLE_SUBSTITUTION_OVERRIDE
value: /home/aries/user_variable_substitution.py
- name: CONTROLLER_PRESENTATION_CLEANUP_TIME
value: {{ .Values.controller.sessionTimeout.duration | quote }}
- name: ACAPY_AGENT_URL
Expand Down Expand Up @@ -133,6 +141,9 @@ spec:
- name: auth-session-ttl
mountPath: /home/aries/sessiontimeout.json
subPath: sessiontimeout.json
- name: custom-variable-substitution
mountPath: /home/aries/user_variable_substitution.py
subPath: sessiontimeout.json
{{- with .Values.nodeSelector }}
nodeSelector:
{{- toYaml . | nindent 8 }}
Expand Down
2 changes: 1 addition & 1 deletion docker/manage
Original file line number Diff line number Diff line change
Expand Up @@ -180,7 +180,7 @@ configureEnvironment() {
export CONTROLLER_SESSION_TIMEOUT_CONFIG_FILE="/home/aries/sessiontimeout.json"

# Extend Variable Substitutions
# export CONTROLLER_VARIABLE_SUBSTITUTION_OVERRIDE="/home/aries/user_variable_substitution.py"
export CONTROLLER_VARIABLE_SUBSTITUTION_OVERRIDE="/home/aries/user_variable_substitution.py"

#controller app settings
export INVITATION_LABEL=${INVITATION_LABEL:-"VC-AuthN"}
Expand Down
24 changes: 0 additions & 24 deletions docker/oidc-controller/config/user_variable_substitution.py
Original file line number Diff line number Diff line change
@@ -1,24 +0,0 @@
def sub_days_plus_one(days: str) -> int:
"""Strings like '$sub_days_plus_one_4' will be replaced with the
final number incremented by one. In this case 5.
$sub_days_plus_one_4 -> 5
$sub_days_plus_one_10 -> 11"""
return int(days) + 1


variable_substitution_map.add_variable_substitution(
r"\$sub_days_plus_one_(\d+)", sub_days_plus_one
)


def sub_string_for_sure(_: str) -> str:
"""Turns strings like $sub_string_for_sure_something into the string 'sure'
$sub_string_for_sure_something -> sure
$sub_string_for_sure_i -> sure
"""
return "sure"


variable_substitution_map.add_variable_substitution(
r"\$sub_string_for_sure_(.+)", sub_string_for_sure
)
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
def sub_days_plus_one(days: str) -> int:
"""Strings like '$sub_days_plus_one_4' will be replaced with the
final number incremented by one. In this case 5.
$sub_days_plus_one_4 -> 5
$sub_days_plus_one_10 -> 11"""
return int(days) + 1


variable_substitution_map.add_variable_substitution(
r"\$sub_days_plus_one_(\d+)", sub_days_plus_one
)


def sub_string_for_sure(_: str) -> str:
"""Turns strings like $sub_string_for_sure_something into the string 'sure'
$sub_string_for_sure_something -> sure
$sub_string_for_sure_i -> sure
"""
return "sure"


variable_substitution_map.add_variable_substitution(
r"\$sub_string_for_sure_(.+)", sub_string_for_sure
)
2 changes: 1 addition & 1 deletion docs/ConfigurationGuide.md
Original file line number Diff line number Diff line change
Expand Up @@ -154,4 +154,4 @@ def today_plus_times(added_days: str, multiplied_days: str) -> int:
variable_substitution_map.add_variable_substitution(r"\$today_plus_(\d+)_times_(\d+)", today_plus_times)
```

For an example of this python file see `docker/oidc-controller/config/user_variable_substitution.py`
For an example of this python file see `docker/oidc-controller/config/user_variable_substitution_example.py`
Original file line number Diff line number Diff line change
Expand Up @@ -127,11 +127,16 @@ def apply_user_variables():
exec(code)
if len(variable_substitution_map.user_static_map) <= 1:
logger.info("No new user created variable substitution where found")

changes = 0
for pattern, func in variable_substitution_map.user_static_map.items():
if pattern not in og_substitution_map:
logger.info(
f'New user created variable substitution: The pattern "{pattern.pattern}" is now mapped to the function {func.__name__}'
)
changes += 1
if changes == 0:
logger.info("No user created variable applied")


apply_user_variables()

0 comments on commit 7790306

Please sign in to comment.