Skip to content

Commit ccbb09a

Browse files
IDP: avoid logging value of 'idp_client_secret'
Note that 'ldap_default_authtok' doesn't require special handling because it is of DP_OPT_BLOB type and isn't logged.
1 parent 128cde9 commit ccbb09a

File tree

5 files changed

+26
-12
lines changed

5 files changed

+26
-12
lines changed

src/confdb/confdb.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -264,6 +264,9 @@
264264
#define CONFDB_PROXY_FAST_ALIAS "proxy_fast_alias"
265265
#define CONFDB_PROXY_MAX_CHILDREN "proxy_max_children"
266266

267+
/* IdP Provider */
268+
#define CONFDB_IDP_CLIENT_SECRET "idp_client_secret"
269+
267270
/* KCM Service */
268271
#define CONFDB_KCM_CONF_ENTRY "config/kcm"
269272
#define CONFDB_KCM_SOCKET "socket_path"

src/oidc_child/oidc_child.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -155,13 +155,13 @@ static errno_t read_client_secret_from_stdin(TALLOC_CTX *mem_ctx,
155155

156156
ret = read_from_stdin(mem_ctx, &str);
157157
if (ret != EOK) {
158-
DEBUG(SSSDBG_OP_FAILURE, "read_from_stdin failed.\n");
158+
DEBUG(SSSDBG_OP_FAILURE, "read_from_stdin() failed.\n");
159159
return ret;
160160
}
161161

162162
*out = str;
163163

164-
DEBUG(SSSDBG_TRACE_ALL, "Client secret: [%s].\n", *out);
164+
DEBUG(SSSDBG_TRACE_ALL, "Client secret was read.\n");
165165

166166
return EOK;
167167
}

src/providers/data_provider_opts.c

Lines changed: 19 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -88,6 +88,22 @@ void dp_option_inherit(int option,
8888

8989
/* =Retrieve-Options====================================================== */
9090

91+
static inline void log_string_option(const struct dp_option *opt)
92+
{
93+
if (strcmp(opt->opt_name, CONFDB_IDP_CLIENT_SECRET) == 0) {
94+
/* avoid logging value of sensitive option */
95+
DEBUG(SSSDBG_CONF_SETTINGS,
96+
"Option "CONFDB_IDP_CLIENT_SECRET" is%s set\n",
97+
opt->val.cstring ? "" : " not");
98+
return;
99+
}
100+
101+
DEBUG(SSSDBG_CONF_SETTINGS, "Option %s has%s value %s\n",
102+
opt->opt_name,
103+
opt->val.cstring ? "" : " no",
104+
opt->val.cstring ? opt->val.cstring : "");
105+
}
106+
91107
int dp_get_options(TALLOC_CTX *memctx,
92108
struct confdb_ctx *cdb,
93109
const char *conf_path,
@@ -123,10 +139,8 @@ int dp_get_options(TALLOC_CTX *memctx,
123139
if (ret == EOK) ret = EINVAL;
124140
goto done;
125141
}
126-
DEBUG(SSSDBG_CONF_SETTINGS, "Option %s has%s value %s\n",
127-
opts[i].opt_name,
128-
opts[i].val.cstring ? "" : " no",
129-
opts[i].val.cstring ? opts[i].val.cstring : "");
142+
143+
log_string_option(&opts[i]);
130144
break;
131145

132146
case DP_OPT_BLOB:
@@ -227,10 +241,7 @@ static int dp_copy_options_ex(TALLOC_CTX *memctx,
227241
opts[i].opt_name);
228242
goto done;
229243
}
230-
DEBUG(SSSDBG_CONF_SETTINGS, "Option %s has%s value %s\n",
231-
opts[i].opt_name,
232-
opts[i].val.cstring ? "" : " no",
233-
opts[i].val.cstring ? opts[i].val.cstring : "");
244+
log_string_option(&opts[i]);
234245
break;
235246

236247
case DP_OPT_BLOB:

src/providers/idp/idp_init.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -111,7 +111,7 @@ errno_t sssm_idp_init(TALLOC_CTX *mem_ctx,
111111
IDP_CLIENT_SECRET);
112112
if (init_ctx->client_secret == NULL) {
113113
DEBUG(SSSDBG_CRIT_FAILURE,
114-
"Missing required option 'idp_client_secret'.\n");
114+
"Missing required option '"CONFDB_IDP_CLIENT_SECRET"'.\n");
115115
ret = EINVAL;
116116
goto done;
117117
}

src/providers/idp/idp_opts.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ struct dp_option default_idp_opts[] = {
2828
{ "idp_request_timeout", DP_OPT_NUMBER, { .number = 10 }, NULL_NUMBER },
2929
{ "idp_type", DP_OPT_STRING, NULL_STRING, NULL_STRING },
3030
{ "idp_client_id", DP_OPT_STRING, NULL_STRING, NULL_STRING },
31-
{ "idp_client_secret", DP_OPT_STRING, NULL_STRING, NULL_STRING },
31+
{ CONFDB_IDP_CLIENT_SECRET, DP_OPT_STRING, NULL_STRING, NULL_STRING },
3232
{ "idp_token_endpoint", DP_OPT_STRING, NULL_STRING, NULL_STRING },
3333
{ "idp_device_auth_endpoint", DP_OPT_STRING, NULL_STRING, NULL_STRING },
3434
{ "idp_userinfo_endpoint", DP_OPT_STRING, NULL_STRING, NULL_STRING },

0 commit comments

Comments
 (0)