diff options
| author | kkadosh | 2018-05-29 19:34:16 +0000 |
|---|---|---|
| committer | jvoisin | 2018-05-29 19:34:16 +0000 |
| commit | 7832438b7abedf567ce6376f99949f419abcdff1 (patch) | |
| tree | 560e43918d1dc36ce4cf760a5b27aed0c563bc1c /src/sp_config_keywords.c | |
| parent | 9eebe8c67e03e3041d454ea28e93996f7a67740b (diff) | |
Support session encryption
Implement session encryption.
Diffstat (limited to 'src/sp_config_keywords.c')
| -rw-r--r-- | src/sp_config_keywords.c | 43 |
1 files changed, 43 insertions, 0 deletions
diff --git a/src/sp_config_keywords.c b/src/sp_config_keywords.c index 9faaafb..f702f4d 100644 --- a/src/sp_config_keywords.c +++ b/src/sp_config_keywords.c | |||
| @@ -60,6 +60,49 @@ static int parse_enable(char *line, bool *restrict retval, | |||
| 60 | return ret; | 60 | return ret; |
| 61 | } | 61 | } |
| 62 | 62 | ||
| 63 | int parse_session(char *line) { | ||
| 64 | sp_config_session *session = | ||
| 65 | pecalloc(sizeof(sp_config_session), 1, 0); | ||
| 66 | |||
| 67 | sp_config_functions sp_config_funcs_session_encryption[] = { | ||
| 68 | {parse_empty, SP_TOKEN_ENCRYPT, &(session->encrypt)}, | ||
| 69 | {parse_empty, SP_TOKEN_SIMULATION, &(session->simulation)}, | ||
| 70 | {0}}; | ||
| 71 | int ret = parse_keywords(sp_config_funcs_session_encryption, line); | ||
| 72 | if (0 != ret) { | ||
| 73 | return ret; | ||
| 74 | } | ||
| 75 | if (session->encrypt) { | ||
| 76 | if (0 == (SNUFFLEUPAGUS_G(config).config_snuffleupagus->cookies_env_var)) { | ||
| 77 | sp_log_err( | ||
| 78 | "config", | ||
| 79 | "You're trying to use the session cookie encryption feature" | ||
| 80 | "on line %zu without having set the `.cookie_env_var` option in" | ||
| 81 | "`sp.global`: please set it first.", | ||
| 82 | sp_line_no); | ||
| 83 | pefree(session, 0); | ||
| 84 | return -1; | ||
| 85 | } else if (0 == | ||
| 86 | (SNUFFLEUPAGUS_G(config).config_snuffleupagus->encryption_key)) { | ||
| 87 | sp_log_err( | ||
| 88 | "config", | ||
| 89 | "You're trying to use the session cookie encryption feature" | ||
| 90 | "on line %zu without having set the `.encryption_key` option in" | ||
| 91 | "`sp.global`: please set it first.", | ||
| 92 | sp_line_no); | ||
| 93 | pefree(session, 0); | ||
| 94 | return -1; | ||
| 95 | } | ||
| 96 | } | ||
| 97 | |||
| 98 | SNUFFLEUPAGUS_G(config).config_session->encrypt = | ||
| 99 | session->encrypt; | ||
| 100 | SNUFFLEUPAGUS_G(config).config_session->simulation = | ||
| 101 | session->simulation; | ||
| 102 | pefree(session, 0); | ||
| 103 | return ret; | ||
| 104 | } | ||
| 105 | |||
| 63 | int parse_random(char *line) { | 106 | int parse_random(char *line) { |
| 64 | return parse_enable(line, &(SNUFFLEUPAGUS_G(config).config_random->enable), | 107 | return parse_enable(line, &(SNUFFLEUPAGUS_G(config).config_random->enable), |
| 65 | NULL); | 108 | NULL); |
