Skip to content

Commit bf468b9

Browse files
committed
return status code from STS call
- if > 500 (504 = gateway timeout) - bump liboauth2 dependency to 1.1.1 - version 3.0.1 Signed-off-by: Hans Zandbelt <[email protected]>
1 parent 10cd7fb commit bf468b9

File tree

6 files changed

+314
-158
lines changed

6 files changed

+314
-158
lines changed

.cproject

Lines changed: 287 additions & 143 deletions
Large diffs are not rendered by default.

.project

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -5,11 +5,6 @@
55
<projects>
66
</projects>
77
<buildSpec>
8-
<buildCommand>
9-
<name>org.eclipse.cdt.autotools.core.genmakebuilderV2</name>
10-
<arguments>
11-
</arguments>
12-
</buildCommand>
138
<buildCommand>
149
<name>org.eclipse.cdt.managedbuilder.core.genmakebuilder</name>
1510
<triggers>clean,full,incremental,</triggers>
@@ -28,6 +23,5 @@
2823
<nature>org.eclipse.cdt.core.ccnature</nature>
2924
<nature>org.eclipse.cdt.managedbuilder.core.managedBuildNature</nature>
3025
<nature>org.eclipse.cdt.managedbuilder.core.ScannerConfigNature</nature>
31-
<nature>org.eclipse.cdt.autotools.core.autotoolsNatureV2</nature>
3226
</natures>
3327
</projectDescription>

ChangeLog

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
07/03/2019
2+
- return status code from STS call: if > 500 (504 = gateway timeout)
3+
- bump liboauth2 dependency to 1.1.1
4+
- version 3.0.1

configure.ac

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
AC_INIT([ngx_sts_module],[3.0.0],[[email protected]])
1+
AC_INIT([ngx_sts_module],[3.0.1],[[email protected]])
22

33
AM_INIT_AUTOMAKE([foreign no-define subdir-objects])
44
AC_CONFIG_MACRO_DIRS([m4])
@@ -25,11 +25,11 @@ AM_CONDITIONAL(HAVE_NGINX, [test x"$have_nginx" = "xyes"])
2525
AC_SUBST(NGINX_CFLAGS)
2626
AC_SUBST(NGINX_LIBS)
2727

28-
PKG_CHECK_MODULES(OAUTH2, [liboauth2 >= 1.0.0])
28+
PKG_CHECK_MODULES(OAUTH2, [liboauth2 >= 1.1.1])
2929
AC_SUBST(OAUTH2_CFLAGS)
3030
AC_SUBST(OAUTH2_LIBS)
3131

32-
PKG_CHECK_MODULES(OAUTH2_NGINX, [liboauth2_nginx >= 1.0.0])
32+
PKG_CHECK_MODULES(OAUTH2_NGINX, [liboauth2_nginx >= 1.1.1])
3333
AC_SUBST(OAUTH2_NGINX_CFLAGS)
3434
AC_SUBST(OAUTH2_NGINX_LIBS)
3535

src/liboauth2-sts

src/ngx_sts_module.c

Lines changed: 19 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -303,12 +303,13 @@ static ngx_int_t ngx_sts_post_config(ngx_conf_t *cf)
303303

304304
static ngx_int_t ngx_sts_handler(ngx_http_request_t *r)
305305
{
306-
ngx_int_t rv = NGX_DECLINED;
306+
ngx_int_t rv = NGX_ERROR;
307307
bool rc = false;
308308
oauth2_nginx_request_context_t *ctx = NULL;
309309
ngx_sts_config *cfg = NULL;
310310
ngx_str_t ngx_source_token;
311311
char *source_token = NULL, *target_token = NULL;
312+
oauth2_http_status_code_t status_code = 0;
312313

313314
if (r != r->main)
314315
goto end;
@@ -352,19 +353,32 @@ static ngx_int_t ngx_sts_handler(ngx_http_request_t *r)
352353
oauth2_debug(ctx->log, "enter: source_token=%s, initial_request=%d",
353354
source_token, (r != r->main));
354355

355-
rc = sts_handler(ctx->log, cfg->cfg, source_token, &target_token);
356+
rc = sts_handler(ctx->log, cfg->cfg, source_token, &target_token,
357+
&status_code);
358+
359+
oauth2_debug(ctx->log, "target_token=%s (rc=%d)",
360+
target_token ? target_token : "(null)", rc);
356361

357-
oauth2_debug(ctx->log, "target_token=%s (rc=%d)", target_token, rc);
362+
if (rc == false) {
363+
if (status_code < 500) {
364+
r->headers_out.status = NGX_HTTP_UNAUTHORIZED;
365+
} else {
366+
r->headers_out.status = (ngx_uint_t)status_code;
367+
}
368+
goto end;
369+
}
358370

359-
if (target_token == NULL)
371+
if (target_token == NULL) {
372+
rv = NGX_DONE;
360373
goto end;
374+
}
361375

362376
cfg->target_token.len = strlen(target_token);
363377
cfg->target_token.data = ngx_palloc(r->pool, cfg->target_token.len);
364378
ngx_memcpy(cfg->target_token.data, (unsigned char *)target_token,
365379
cfg->target_token.len);
366380

367-
rv = rc ? NGX_OK : NGX_ERROR;
381+
rv = NGX_OK;
368382

369383
end:
370384

0 commit comments

Comments
 (0)