Commit Graph

46 Commits

Author SHA1 Message Date
Taylor R Campbell
a142767598 Fix ctype.h misuse.
Excluded: libtomath and libedit files, most of which appear to be
testing or example code not involved in production, and which are
derived from an upstream that should perhaps have patches submitted
upstream instead.

fix https://github.com/heimdal/heimdal/issues/1111
2023-05-26 14:10:11 -05:00
Nicolas Williams
e27ddc6596 bx509d: If early ENOMEM, close the connection 2023-01-04 16:24:32 -06:00
Nicolas Williams
23c13886c4 bx509: Fix error path NULL dereference 2023-01-04 16:23:56 -06:00
Nicolas Williams
12160382a0 bx509d: Fix leaks 2023-01-04 01:36:02 -06:00
Nicolas Williams
c6074377bc bx509d: Fix free() of text string
Also fix a leak, and quiet some warnings.
2023-01-04 01:36:02 -06:00
Nicolas Williams
f47f15d5b9 bx509d: /get-tgts: Allow piecemeal authorization
We use the CSR authorizer system for /get-tgt and /get-tgts because,
well, the CSR authorizer system knows how to deal with principal names
("PKINIT SANs").

The caller of the /get-tgts end-point is a batch API that is meant for
super-user clients that implement orchestration for automation.  For
this end-point it's important to be able to return TGTs for just the
requested principals that are authorized rather than fail the whole
request because one principal isn't.  A principal might be rejected by
the authorizer if, for example, it's not meant to exist, and that might
be desirable because "synthetic" HDB entries might be configured, and we
might not want principals that don't exist to appear to exist for such
an orchestration service.

The hx509 CSR related functions allow one to mark specific requested
EKUs and SANs as authorized or not.  Until now we have simply rejected
all requests that don't have all attributes approved, but for /get-tgts
we need partial request approval.  This commit implements partial
request approval for the /get-tgts end-point.
2022-12-15 17:44:41 -06:00
Nicolas Williams
ba93778682 bx509d: Set log destination 2022-12-15 17:44:41 -06:00
Nicolas Williams
cf020532c2 bx509d: Fix leak of error messages 2022-12-15 17:44:41 -06:00
Nicolas Williams
ae527bf97c bx509d: Add /get-tgts batch end-point
In order to support batch jobs systems that run many users' jobs and
which jobs need credentials, we add a /get-tgts end-point that is a
batched version of the /get-tgt end-point.  This end-point returns JSON.

Also, we make GETs optional, default to not-allowed in preference of
POSTs.

We also correct handling of POST (before POSTs with non-zero-length bodies
would cause the server to close the connection), and add additional CSRF
protection features, including the ability to disable all GET requests
for /get-keys and /get-config.
2022-10-02 22:46:37 -05:00
Nicolas Williams
2c8a078bcf bx509d: Do not leak temp ccaches 2022-02-14 21:07:47 -06:00
Luke Howard
ed4fe65794 base: change ret fieldname to error_code in request struct 2022-01-20 17:23:24 +11:00
Nicolas Williams
b889942340 bx509d: Add missing check of result of key2SPKI() 2022-01-16 13:12:22 -06:00
Nicolas Williams
5dcad4635b bx509d: Fix warnings 2022-01-14 17:59:49 -06:00
Nicolas Williams
aa8eb19b8e bx509d: Build with older libmicrohttpd (fix GH CI) 2022-01-13 15:33:04 -06:00
Luke Howard
a8ff420b16 kdc: add attribute dictionary to kdc_request_t
Add a heim_dict_t to the KDC request structure for use by pre-authentication
mechanisms and plugins.
2022-01-04 12:27:43 +11:00
Luke Howard
b27026996a base: s/addkv_{bool,number,object}/setkv
Now heim_audit_addkv() correctly supports multiple values, the other functions
that (by design) replace existing values with a single value should use the
heim_audit_setkv prefix.

A subsequent commit could add variants that support multiple values for
non-string types.
2022-01-04 09:07:10 +11:00
Nicolas Williams
e328c0e496 bx509d: Use enum MHD_Result return type 2022-01-02 21:11:40 -06:00
Nicolas Williams
53e63d9ec9 kdc: Fix bx509d/httpkadmind (b1dcc1a47) 2022-01-02 21:11:07 -06:00
Luke Howard
a9c6bc2bf2 kdc: audit "yes" boolean values as booleans
Audit boolean values that were logged as "yes" as boolean values; this will
change audit log values to "true" instead, so this patch may be omitted.
2022-01-02 15:25:52 +11:00
Luke Howard
cc0874d410 kdc: preserve value types in auditing
Preserve integer/boolean audit values as their native types; convert to strings
when logging only. This commit goes some way towards unifying the two auditing
APIs.
2022-01-02 15:25:52 +11:00
Luke Howard
d165e73fff bx509d: don't audit NULL message string
formatted can be NULL, it appeares the intention was to log msg instead
2022-01-02 15:25:52 +11:00
Nicolas Williams
fb3ea5b943 kdc: Add ret to common svc req elements
We're logging SUCCESS even when the KDC sends error replies.  That's
because we're returning success to process_request() even when we send
errors to clients.  The error we want to send to the client, and that we
succeed or fail to send it, are different statuses.

Also, further move things into `r` and out of function arguments.
2021-12-27 10:16:58 +11:00
Nicolas Williams
5f63215d0d Always perform == or != operation on cmp function result
Although not required to address bad code generation in
some versions of gcc 9 and 10, a coding style that requires
explicit comparison of the result to zero before use is
both clearer and would have avoided the generation of bad
code.

This change converts all use of cmp function usage from

```
    if (strcmp(a, b) || !strcmp(c, d)) ...
```

to

```
    if (strcmp(a, b) != 0 || strcmp(c, d)) == 0
```

for all C library cmp functions and related:

 - strcmp(), strncmp()
 - strcasecmp(), strncasecmp()
 - stricmp(), strnicmp()
 - memcmp()

Change-Id: Ic60c15e1e3a07e4faaf10648eefe3adae2543188
2021-11-24 22:30:44 -05:00
Nicolas Williams
8807a0aad9 bx509d: Use /get-tgt lifetime q-param 2021-05-06 23:13:31 -05:00
Nicolas Williams
e609e61f21 bx509d: Set Content-Type and Cache-Control 2021-04-30 16:02:18 -05:00
Nicolas Williams
a4adb8354f bx509: Complete /get-tgt?cname= support 2021-04-22 17:02:18 -05:00
Nicolas Williams
76d6ee4abc bx509: Don't clobber error in get_tgt() 2021-04-22 17:02:16 -05:00
Nicolas Williams
f60300984e bx509d: /get-tgt add EKU to authorization check 2021-04-16 14:13:05 -05:00
Nicolas Williams
6ff3dbf297 bx509: Add addresses q-param for /get-tgt 2021-04-14 19:28:08 -05:00
Nicolas Williams
6633f6e525 bx509d: Implement /get-tgt end-point 2021-04-06 17:19:48 -05:00
Nicolas Williams
d72c4af635 bx509: Rename end-points; doc Negotiate more
Leaving old end-point names around.
2021-04-06 17:19:48 -05:00
Nicolas Williams
fbb1a4e3ec bx509d: Allow requesting longer cert lifetimes
Add a `lifetime=NUMunit` query parameter.

Also add a krb5.conf parameter to indicate whether this is allowed.
We already have a max lifetime configuration parameter.
2021-03-07 22:20:06 -06:00
Nicolas Williams
cb6c57dc36 bx509: Let simple authorizer use the app name 2020-09-08 00:25:24 -05:00
Nicolas Williams
4f0249cd94 hx509/kdc: Move KDC CA utility function into hx509
This is part of the program to move REST services like bx509d out of
kdc/.
2020-09-08 00:25:24 -05:00
Nicolas Williams
e311d05fee bx509d: Further disentanglement from kdc 2020-09-08 00:25:24 -05:00
Nicolas Williams
73c424ea66 bx509d: Get KDC config out of bx509d 2020-09-08 00:25:24 -05:00
Nicolas Williams
01509f553d Move KDC audit functionality to lib/base/ 2020-04-24 16:02:35 -05:00
Nicolas Williams
1cbbca8dcf bx509: Add /, /health for load balancer checking
A HEAD or GET of / or /health will now produce a 200 instead of a 404.

Ideally we should add configuration arguments that would allow /health
to get a token, make a CSR, and test the /bx509 (and/or /bnegotiate)
functionality, that way we'd have a real health check.  For now we defer
that work, as external health monitoring can be done using a simple
script anyways.
2020-01-10 11:43:00 -06:00
Nicolas Williams
e7ad9da3cc bx509: Do not clobber library error info 2020-01-10 11:34:33 -06:00
Nicolas Williams
ee0a288f92 bx509: Work around microhttpd bug 2019-12-20 15:54:27 -06:00
Nicolas Williams
608c2876d4 kdc: Fix audit_addkv() typos and reason handling
Now we'll put the "reason=..." last in the log lines and we won't escape
spaces -- just newlines and other control characters.  This makes
reading log lines much easier without complicating parsing of log lines
because interior key=value pairs do get whitespace escaped or removed.
2019-12-10 22:14:38 -06:00
Nicolas Williams
18df68d6e9 bx509: Add proper logging 2019-12-10 21:26:47 -06:00
Nicolas Williams
733140553a kdc: Fix leaks 2019-12-09 21:39:30 -06:00
Nicolas Williams
d1a2652090 bx509: CSRF protection for /bnegotiate 2019-12-09 20:13:33 -06:00
Nicolas Williams
0a0a27ccec kdc: bx509: Do not vend issuer private keys 2019-12-09 18:10:10 -06:00
Nicolas Williams
575c67806b Add bx509d 2019-12-04 21:34:44 -06:00