Skip to content

Commit 5c6e7d2

Browse files
committed
depend on liboauth2 1.2.2 with new ROPC capability
bump copyright year to 2020 Signed-off-by: Hans Zandbelt <hans.zandbelt@zmartzone.eu>
1 parent 8385c48 commit 5c6e7d2

File tree

10 files changed

+45
-124
lines changed

10 files changed

+45
-124
lines changed

.settings/language.settings.xml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313

1414
<provider class="org.eclipse.cdt.managedbuilder.language.settings.providers.GCCBuildCommandParser" id="org.eclipse.cdt.autotools.core.LibtoolGCCBuildCommandParser" keep-relative-paths="false" name="CDT Libtool GCC Build Output Parser" parameter="(libtool:\s+compile:\s+)?((g?cc)|([gc]\+\+)|(clang))" prefer-non-shared="true"/>
1515

16-
<provider class="org.eclipse.cdt.managedbuilder.language.settings.providers.GCCBuiltinSpecsDetector" console="false" env-hash="452001252992828664" id="org.eclipse.cdt.managedbuilder.core.GCCBuiltinSpecsDetector" keep-relative-paths="false" name="CDT GCC Built-in Compiler Settings" parameter="${COMMAND} ${FLAGS} -E -P -v -dD &quot;${INPUTS}&quot;" prefer-non-shared="true">
16+
<provider class="org.eclipse.cdt.managedbuilder.language.settings.providers.GCCBuiltinSpecsDetector" console="false" env-hash="452331985365382664" id="org.eclipse.cdt.managedbuilder.core.GCCBuiltinSpecsDetector" keep-relative-paths="false" name="CDT GCC Built-in Compiler Settings" parameter="${COMMAND} ${FLAGS} -E -P -v -dD &quot;${INPUTS}&quot;" prefer-non-shared="true">
1717

1818
<language-scope id="org.eclipse.cdt.core.gcc"/>
1919

@@ -37,7 +37,7 @@
3737

3838
<provider copy-of="extension" id="org.eclipse.cdt.autotools.core.LibtoolGCCBuildCommandParser"/>
3939

40-
<provider class="org.eclipse.cdt.managedbuilder.language.settings.providers.GCCBuiltinSpecsDetector" console="false" env-hash="-1658009168086983606" id="org.eclipse.cdt.managedbuilder.core.GCCBuiltinSpecsDetector" keep-relative-paths="false" name="CDT GCC Built-in Compiler Settings" parameter="${COMMAND} ${FLAGS} -E -P -v -dD &quot;${INPUTS}&quot;" prefer-non-shared="true">
40+
<provider class="org.eclipse.cdt.managedbuilder.language.settings.providers.GCCBuiltinSpecsDetector" console="false" env-hash="-1657678435714429606" id="org.eclipse.cdt.managedbuilder.core.GCCBuiltinSpecsDetector" keep-relative-paths="false" name="CDT GCC Built-in Compiler Settings" parameter="${COMMAND} ${FLAGS} -E -P -v -dD &quot;${INPUTS}&quot;" prefer-non-shared="true">
4141

4242
<language-scope id="org.eclipse.cdt.core.gcc"/>
4343

ChangeLog

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,7 @@
1+
02/05/2020
2+
- depend on liboauth 1.2.2 with new ROPC capability
3+
- bump copyright year to 2020
4+
15
09/12/2019
26
- depend on liboauth2 1.2.0 with new request header API
37

configure.ac

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ PKG_CHECK_MODULES(XML, libxml-2.0 >= 2.4)
1313
AC_SUBST(XML_CFLAGS)
1414
AC_SUBST(XML_LIBS)
1515

16-
PKG_CHECK_MODULES(OAUTH2, liboauth2 >= 1.2.0)
16+
PKG_CHECK_MODULES(OAUTH2, liboauth2 >= 1.2.2)
1717
AC_SUBST(OAUTH2_CFLAGS)
1818
AC_SUBST(OAUTH2_LIBS)
1919

include/oauth2/sts.h

Lines changed: 3 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33

44
/***************************************************************************
55
*
6-
* Copyright (C) 2018-2019 - ZmartZone Holding BV - www.zmartzone.eu
6+
* Copyright (C) 2018-2020 - ZmartZone Holding BV - www.zmartzone.eu
77
*
88
* This program is free software: you can redistribute it and/or modify
99
* it under the terms of the GNU Affero General Public License as
@@ -45,10 +45,7 @@
4545
#define STSWSTrustAppliesTo "STSWSTrustAppliesTo"
4646
#define STSWSTrustTokenType "STSWSTrustTokenType"
4747
#define STSWSTrustValueType "STSWSTrustValueType"
48-
#define STSROPCEndpoint "STSROPCEndpoint"
49-
#define STSROPCEndpointAuth "STSROPCEndpointAuth"
50-
#define STSROPCClientID "STSROPCClientID"
51-
#define STSROPCUsername "STSROPCUsername"
48+
#define STSROPC "STSROPC"
5249
#define STSOTXEndpoint "STSOTXEndpoint"
5350
#define STSOTXEndpointAuth "STSOTXEndpointAuth"
5451
#define STSOTXClientID "STSOTXClientID"
@@ -82,10 +79,7 @@ STS_CFG_SET_TAKE1(wstrust_applies_to)
8279
STS_CFG_SET_TAKE1(wstrust_token_type)
8380
STS_CFG_SET_TAKE1(wstrust_value_type)
8481

85-
STS_CFG_SET_TAKE1(ropc_endpoint)
86-
STS_CFG_SET_TAKE2(ropc_endpoint_auth)
87-
STS_CFG_SET_TAKE1(ropc_client_id)
88-
STS_CFG_SET_TAKE1(ropc_username)
82+
STS_CFG_SET_TAKE1(ropc)
8983

9084
STS_CFG_SET_TAKE1(otx_endpoint)
9185
STS_CFG_SET_TAKE2(otx_endpoint_auth)

src/otx.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
/***************************************************************************
22
*
3-
* Copyright (C) 2018-2019 - ZmartZone Holding BV - www.zmartzone.eu
3+
* Copyright (C) 2018-2020 - ZmartZone Holding BV - www.zmartzone.eu
44
*
55
* This program is free software: you can redistribute it and/or modify
66
* it under the terms of the GNU Affero General Public License as

src/ropc.c

Lines changed: 17 additions & 72 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
/***************************************************************************
22
*
3-
* Copyright (C) 2018-2019 - ZmartZone Holding BV - www.zmartzone.eu
3+
* Copyright (C) 2018-2020 - ZmartZone Holding BV - www.zmartzone.eu
44
*
55
* This program is free software: you can redistribute it and/or modify
66
* it under the terms of the GNU Affero General Public License as
@@ -21,18 +21,11 @@
2121

2222
#include <oauth2/http.h>
2323
#include <oauth2/oauth2.h>
24+
#include <oauth2/proto.h>
2425
#include <oauth2/sts.h>
2526

2627
#include "sts_int.h"
2728

28-
#define STS_ROPC_ENDPOINT_DEFAULT NULL
29-
#define STS_ROPC_ENDPOINT_AUTH_DEFAULT STS_ENDPOINT_AUTH_NONE
30-
#define STS_ROPC_CLIENT_ID_DEFAULT NULL
31-
#define STS_ROPC_USERNAME_DEFAULT NULL
32-
33-
#define STS_ROPC_GRANT_TYPE_VALUE "password"
34-
#define STS_ROPC_USERNAME "username"
35-
#define STS_ROPC_PASSWORD "password"
3629
/*
3730
int sts_ropc_config_check_vhost(oauth2_log_t *log, apr_pool_t *pool, server_rec
3831
*s, sts_config *cfg)
@@ -48,79 +41,31 @@ int sts_ropc_config_check_vhost(oauth2_log_t *log, apr_pool_t *pool, server_rec
4841
return OK;
4942
}
5043
*/
51-
static const char *sts_ropc_get_endpoint(oauth2_cfg_sts_t *cfg)
52-
{
53-
if (cfg->ropc_endpoint == NULL)
54-
return STS_ROPC_ENDPOINT_DEFAULT;
55-
return cfg->ropc_endpoint;
56-
}
57-
58-
static const char *sts_ropc_get_client_id(oauth2_cfg_sts_t *cfg)
59-
{
60-
if (cfg->ropc_client_id == NULL)
61-
return STS_ROPC_CLIENT_ID_DEFAULT;
62-
return cfg->ropc_client_id;
63-
}
6444

6545
static const char *sts_ropc_get_username(oauth2_cfg_sts_t *cfg,
6646
const char *user)
6747
{
68-
if (cfg->ropc_username == NULL)
48+
const char *username = oauth2_cfg_ropc_get_username(cfg->ropc);
49+
if (username == NULL) {
6950
// return the client_id by default
70-
return sts_ropc_get_client_id(cfg);
71-
if (strcmp(cfg->ropc_username, "*") == 0)
51+
username = oauth2_cfg_ropc_get_client_id(cfg->ropc);
52+
goto end;
53+
}
54+
if (strcmp(username, "*") == 0)
7255
// special handling to pull the authenticated username from a
7356
// previously triggered module
74-
return user;
75-
return cfg->ropc_username;
57+
username = user;
58+
end:
59+
60+
return username;
7661
}
7762

7863
bool sts_ropc_exec(oauth2_log_t *log, oauth2_cfg_sts_t *cfg, const char *token,
7964
const char *user, char **rtoken, oauth2_uint_t *status_code)
8065
{
81-
82-
bool rc = false;
83-
oauth2_nv_list_t *params = NULL;
84-
oauth2_http_call_ctx_t *ctx = NULL;
85-
const char *client_id = sts_ropc_get_client_id(cfg);
86-
const char *username = sts_ropc_get_username(cfg, user);
87-
88-
oauth2_debug(log, "enter");
89-
90-
params = oauth2_nv_list_init(log);
91-
oauth2_nv_list_add(log, params, OAUTH2_GRANT_TYPE,
92-
STS_ROPC_GRANT_TYPE_VALUE);
93-
94-
if ((oauth2_cfg_endpoint_auth_type(cfg->ropc_endpoint_auth) ==
95-
OAUTH2_ENDPOINT_AUTH_NONE) &&
96-
(client_id != NULL))
97-
oauth2_nv_list_add(log, params, OAUTH2_CLIENT_ID, client_id);
98-
99-
if (username != NULL)
100-
oauth2_nv_list_add(log, params, STS_ROPC_USERNAME, username);
101-
oauth2_nv_list_add(log, params, STS_ROPC_PASSWORD, token);
102-
103-
sts_merge_request_parameters(log, cfg, params);
104-
105-
ctx = oauth2_http_call_ctx_init(log);
106-
if (ctx == NULL)
107-
goto end;
108-
109-
if (oauth2_http_ctx_auth_add(log, ctx, cfg->ropc_endpoint_auth,
110-
params) == false)
111-
goto end;
112-
113-
rc = sts_util_oauth_call(log, cfg, ctx, sts_ropc_get_endpoint(cfg),
114-
params, rtoken, status_code);
115-
116-
end:
117-
118-
if (params)
119-
oauth2_nv_list_free(log, params);
120-
if (ctx)
121-
oauth2_http_call_ctx_free(log, ctx);
122-
123-
oauth2_debug(log, "leave: %d", rc);
124-
125-
return rc;
66+
// TODO:
67+
// sts_merge_request_parameters(log, cfg, params);
68+
return oauth2_ropc_exec(log, cfg->ropc,
69+
sts_ropc_get_username(cfg, user), token, rtoken,
70+
status_code);
12671
}

src/sts.c

Lines changed: 13 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
/***************************************************************************
22
*
3-
* Copyright (C) 2018-2019 - ZmartZone Holding BV - www.zmartzone.eu
3+
* Copyright (C) 2018-2020 - ZmartZone Holding BV - www.zmartzone.eu
44
*
55
* This program is free software: you can redistribute it and/or modify
66
* it under the terms of the GNU Affero General Public License as
@@ -83,10 +83,7 @@ oauth2_sts_cfg_t *oauth2_sts_cfg_create(oauth2_log_t *log, const char *path)
8383
c->wstrust_token_type = NULL;
8484
c->wstrust_value_type = NULL;
8585

86-
c->ropc_endpoint = NULL;
87-
c->ropc_endpoint_auth = NULL;
88-
c->ropc_client_id = NULL;
89-
c->ropc_username = NULL;
86+
c->ropc = NULL;
9087

9188
c->otx_endpoint = NULL;
9289
c->otx_endpoint_auth = NULL;
@@ -137,17 +134,8 @@ void oauth2_sts_cfg_merge(oauth2_log_t *log, oauth2_sts_cfg_t *cfg,
137134
oauth2_strdup(add->wstrust_value_type ? add->wstrust_value_type
138135
: base->wstrust_value_type);
139136

140-
cfg->ropc_endpoint = oauth2_strdup(
141-
add->ropc_endpoint ? add->ropc_endpoint : base->ropc_endpoint);
142-
cfg->ropc_endpoint_auth =
143-
add->ropc_endpoint_auth
144-
? oauth2_cfg_endpoint_auth_clone(NULL, add->ropc_endpoint_auth)
145-
: oauth2_cfg_endpoint_auth_clone(NULL,
146-
base->ropc_endpoint_auth);
147-
cfg->ropc_client_id = oauth2_strdup(
148-
add->ropc_client_id ? add->ropc_client_id : base->ropc_client_id);
149-
cfg->ropc_username = oauth2_strdup(
150-
add->ropc_username ? add->ropc_username : base->ropc_username);
137+
cfg->ropc = add->ropc ? oauth2_cfg_ropc_clone(NULL, add->ropc)
138+
: oauth2_cfg_ropc_clone(NULL, base->ropc);
151139

152140
cfg->otx_endpoint = oauth2_strdup(
153141
add->otx_endpoint ? add->otx_endpoint : base->otx_endpoint);
@@ -229,15 +217,8 @@ void oauth2_sts_cfg_free(oauth2_log_t *log, oauth2_sts_cfg_t *cfg)
229217
if (cfg->wstrust_value_type)
230218
oauth2_mem_free(cfg->wstrust_value_type);
231219

232-
if (cfg->ropc_endpoint)
233-
oauth2_mem_free(cfg->ropc_endpoint);
234-
if (cfg->ropc_endpoint_auth)
235-
oauth2_cfg_endpoint_auth_free(cfg->log,
236-
cfg->ropc_endpoint_auth);
237-
if (cfg->ropc_client_id)
238-
oauth2_mem_free(cfg->ropc_client_id);
239-
if (cfg->ropc_username)
240-
oauth2_mem_free(cfg->ropc_username);
220+
if (cfg->ropc)
221+
oauth2_cfg_ropc_free(cfg->log, cfg->ropc);
241222

242223
if (cfg->otx_endpoint)
243224
oauth2_mem_free(cfg->otx_endpoint);
@@ -285,9 +266,9 @@ STS_CFG_SET_TAKE1_IMPL(wstrust_endpoint, str)
285266
STS_CFG_SET_TAKE1_IMPL(wstrust_applies_to, str)
286267
STS_CFG_SET_TAKE1_IMPL(wstrust_token_type, str)
287268
STS_CFG_SET_TAKE1_IMPL(wstrust_value_type, str)
288-
STS_CFG_SET_TAKE1_IMPL(ropc_endpoint, str)
289-
STS_CFG_SET_TAKE1_IMPL(ropc_client_id, str)
290-
STS_CFG_SET_TAKE1_IMPL(ropc_username, str)
269+
// STS_CFG_SET_TAKE1_IMPL(ropc_endpoint, str)
270+
// STS_CFG_SET_TAKE1_IMPL(ropc_client_id, str)
271+
// STS_CFG_SET_TAKE1_IMPL(ropc_username, str)
291272
STS_CFG_SET_TAKE1_IMPL(otx_endpoint, str)
292273
STS_CFG_SET_TAKE1_IMPL(otx_client_id, str)
293274
STS_CFG_SET_TAKE1_IMPL(cache_expiry_s, uint)
@@ -378,11 +359,11 @@ const char *sts_cfg_set_wstrust_endpoint_auth(oauth2_sts_cfg_t *cfg,
378359
return rv;
379360
}
380361

381-
const char *sts_cfg_set_ropc_endpoint_auth(oauth2_sts_cfg_t *cfg,
382-
const char *type, const char *value)
362+
const char *sts_cfg_set_ropc(oauth2_sts_cfg_t *cfg, const char *value)
383363
{
384-
return _sts_cfg_set_endpoint_auth(&cfg->ropc_endpoint_auth, type,
385-
value);
364+
if (cfg->ropc == NULL)
365+
cfg->ropc = oauth2_cfg_ropc_init(cfg->log);
366+
return oauth2_cfg_set_ropc_options(cfg->log, cfg->ropc, value);
386367
}
387368

388369
const char *sts_cfg_set_otx_endpoint_auth(oauth2_sts_cfg_t *cfg,

src/sts_int.h

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33

44
/***************************************************************************
55
*
6-
* Copyright (C) 2018-2019 - ZmartZone Holding BV - www.zmartzone.eu
6+
* Copyright (C) 2018-2020 - ZmartZone Holding BV - www.zmartzone.eu
77
*
88
* This program is free software: you can redistribute it and/or modify
99
* it under the terms of the GNU Affero General Public License as
@@ -40,10 +40,7 @@ typedef struct oauth2_sts_cfg_t {
4040
char *wstrust_token_type;
4141
char *wstrust_value_type;
4242

43-
char *ropc_endpoint;
44-
oauth2_cfg_endpoint_auth_t *ropc_endpoint_auth;
45-
char *ropc_client_id;
46-
char *ropc_username;
43+
oauth2_cfg_ropc_t *ropc;
4744

4845
char *otx_endpoint;
4946
oauth2_cfg_endpoint_auth_t *otx_endpoint_auth;

src/wstrust.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
/***************************************************************************
22
*
3-
* Copyright (C) 2018-2019 - ZmartZone Holding BV - www.zmartzone.eu
3+
* Copyright (C) 2018-2020 - ZmartZone Holding BV - www.zmartzone.eu
44
*
55
* This program is free software: you can redistribute it and/or modify
66
* it under the terms of the GNU Affero General Public License as

test/check_liboauth2_sts.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
/***************************************************************************
22
*
3-
* Copyright (C) 2018-2019 - ZmartZone Holding BV - www.zmartzone.eu
3+
* Copyright (C) 2018-2020 - ZmartZone Holding BV - www.zmartzone.eu
44
*
55
* This program is free software: you can redistribute it and/or modify
66
* it under the terms of the GNU Affero General Public License as

0 commit comments

Comments
 (0)