Commit Graph

29855 Commits

Author SHA1 Message Date
Luke Howard
0492729ba7 kdc: remove unused v4 hprop code 2021-12-30 20:42:18 +11:00
Nicolas Williams
09f3f96467 gsskrb5: Use optimistic anon PKINIT armored FAST 2021-12-30 18:54:54 +11:00
Nicolas Williams
554f375626 kinit: Use optimistic anon PKINIT armored FAST
Now that we can optimistically try FAST w/ anon PINIT armor, we should
do so in kinit whenever it makes sense.
2021-12-30 18:54:54 +11:00
Nicolas Williams
944e12e103 krb5: Add GIC optimistic FAST w/ anon 2021-12-30 18:54:54 +11:00
Nicolas Williams
ca71e365ec asn1: Move decoration to krb5.opt file 2021-12-30 18:54:54 +11:00
Luke Howard
486a1ea773 kdc: remove unnecessary cast in finalize() (windc.c) 2021-12-29 21:15:08 +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
5e3c0a7ce0 base: 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.

To fix this we'll add a `ret` field to the common service request state
structure, HEIM_SVC_REQUEST_DESC_COMMON_ELEMENTS /
heim_svc_req_desc_common_s.
2021-12-27 10:16:58 +11:00
Luke Howard
81077eea7b tests: use cname/sname string name instead of unparsing 2021-12-26 18:40:19 +11:00
Nicolas Williams
833483137b kdc: Log more about KRB-ERROR failures 2021-12-23 21:06:38 -06:00
Nicolas Williams
eeba89a1af kdc: Stop confusing the compiler 2021-12-23 21:06:38 -06:00
Nicolas Williams
6baac3126f asn1: Fix template decoration copy 2021-12-23 19:11:49 -06:00
Luke Howard
f74e9223b6 tests: add some logging to windc test plugin
Log some parameters from the astgs_request_t.
2021-12-23 17:49:36 -06:00
Luke Howard
f49e99e15f kdc: remove e_text argument to _kdc_encode_reply()
e_text is part of astgs_request_t, so it doesn't need to be an explicit
argument to _kdc_encode_reply()
2021-12-23 17:49:36 -06:00
Luke Howard
b6be850e0d kdc: remove outpadata from astgs_request_t
Remove the outpadata field from astgs_request_t, because it's not something we
wish to expose publically (yet it is something that Samba needs in the
client_access plugin API, to add Windows error information).

Instead, allocate rep->padata at the start of AS/TGS request handling, and
ensure it is valid for the lifetime of the request until it is encoded (at
which point it will be freed and set to NULL if zero length, to avoid sending a
zero length METHOD-DATA to the client).

(The previous approach of setting rep->padata to point to &r->outpadata was
fragile, because it required clearing the pointer before freeing the KDC-REP.)
2021-12-23 17:49:36 -06:00
Luke Howard
64dad876a4 kdc: simplify client_access windc plugin API
Make client_access plugin API take a single argument, astgs_request_t. Note: in
order to avoid making r->outpadata public (it's an internal buffer), but allow
Samba to modify the reply pa data, some pointer magic is required.
2021-12-23 17:49:36 -06:00
Luke Howard
36fe09f433 kdc: remove unused padata field from astgs_request_t 2021-12-23 17:49:36 -06:00
Luke Howard
e81bcb71f3 kdc: add finalize_reply API to windc plugin
Allow a windc plugin to finalize the KDC reply (including the encrypted ticket
and reply parts) before encoding for transmission.
2021-12-23 17:49:36 -06:00
Luke Howard
6b312659cb kdc: use PAC from request in _kdc_gss_finalize_pac()
Pass astgs_request_t to _kdc_gss_finalize_pac() in order to harmonize with
other functions.
2021-12-23 17:49:36 -06:00
Luke Howard
d3549c4ab7 kdc: remove superflous request arg to _kdc_check_access()
KDC_REQ is accessible as r->req
2021-12-23 17:49:36 -06:00
Luke Howard
805ea5e0a0 kdc: use rep/et/ek fields in astgs_request_t
Use rep/et/ek fields in astgs_request_t that were previously present but not
globally used.
2021-12-23 17:49:36 -06:00
Luke Howard
e3a5169862 kdc: make common astgs_request_t elements public API 2021-12-23 17:49:36 -06:00
Luke Howard
2e8b172f38 kdc: move PAC into astgs_request_t structure 2021-12-23 17:49:36 -06:00
Luke Howard
d95be72681 kdc: separate astgs_request_t common elements
Separate out some astgs_request_t common elements with the intention of making
them public API.
2021-12-23 17:49:36 -06:00
Luke Howard
5b7cf5d56f kdc: centralize include PAC logic
Add a helper function that returns TRUE if a PAC should be included in ticket
authorization data, that can be called from both AS and TGS paths.

Per [MS-KILE] 3.3.5.3, PACs are always included for TGTs; for service
tickets, policy is governed by whether the client explicitly requested
a PAC be omitted when requesting a TGT, or if the no-auth-data-reqd
flag is set on the service principal entry.
2021-12-23 13:52:15 +11:00
Luke Howard
0165633964 hdb: add no-auth-data-reqd flag to HDB entry
Add a new flag, no-auth-data-reqd, to the HDB entry which indicates that a PAC
should not be included on issued service tickets.
2021-12-23 13:52:12 +11:00
Luke Howard
317df4dbd4 kdc: remove pac_attributes_present field
Remove the unwieldy pac_attributes_present field from the request structure.

Instead, if PAC attributes are not present in the TGT, the default is to assume
they were set to KRB5_PAC_WAS_GIVEN_IMPLICITLY.
2021-12-23 13:26:40 +11:00
Luke Howard
ebd7092dff kdc: distinguish long-term key from replacing reply key
Distinguish pre-authentication mechanisms that replace the reply key from those
that use the client's long-term key. In the general case, one is the inverse of
the other, however KRB5_PADATA_ENCRYPTED_CHALLENGE replaces the reply-key with
one derived from the long-term key.

PA_REPLACE_REPLY_KEY indicates that the kvno should be set to zero in the
reply; the absence of PA_USES_LONG_TERM_KEY indicates that the client's
long-term key may be included in the PAC (PAC_CREDENTIAL_INFO with Samba only).

Corrects e8984871.
2021-12-23 11:24:35 +11:00
Luke Howard
bdb3e1020c Revert "kdc: distinguish long-term key from replacing reply key"
This reverts commit e89848719a.

(Reverting: typo.)
2021-12-23 11:24:00 +11:00
Luke Howard
e89848719a kdc: distinguish long-term key from replacing reply key
Distinguish pre-authentication mechanisms that replace the reply key from those
that use the client's long-term key. In the general case, one is the inverse of
the other, however KRB5_PADATA_ENCRYPTED_CHALLENGE replaces the reply-key with
one derived from the long-term key.

PA_REPLACE_REPLY_KEY indicates that the kvno should be set to zero in the
reply; the absence of PA_USES_LONG_TERM_KEY indicates that the client's
long-term key may be included in the PAC (PAC_CREDENTIAL_INFO with Samba only).
2021-12-23 11:21:30 +11:00
Luke Howard
357c73e013 kdc: avoid linear search of PA types
Store a dispatch table pointer for the used pre-authentication type to avoid
needing to traverse the table.
2021-12-23 11:04:38 +11:00
Luke Howard
f18c9e06a8 kdc: honor PAC_ATTRIBUTES in presented TGT
PACs are included when issuing TGTs, if there is no PAC_ATTRIBUTES buffer
(legacy behavior) or if the attributes buffer indicates the AS client requested
one.
2021-12-22 17:13:13 +11:00
Luke Howard
b4f3617964 kdc: don't add PAC_ATTRIBUTES PAC buffer for service tickets
Only include the PAC_ATTRIBUTES PAC info buffer if we are issuing a TGT, as its
contents are not relevant to application services. (The buffer contains a bit
indicating whether the client explicitly or implicitly requested a PAC.)
2021-12-22 16:38:52 +11:00
Luke Howard
b36ac3c15e kdc: don't add REQUESTOR_SID PAC buffer for service tickets
In the altsecid GSS pre-authentication authorizer plugin, don't add the
REQUESTOR_SID PAC info buffer unless the client requested a TGT. It is not
relevant to application services.
2021-12-22 16:37:32 +11:00
Luke Howard
c974f8625c krb5: PAC_EXTRA_LOGON_INFO_FLAGS_UPN_DEFAULTED fix
Only set the PAC_EXTRA_LOGON_INFO_FLAGS_UPN_DEFAULTED flag in the
UPN_DNS_INFO_EX PAC buffer, if the provided UPN matches the cname.

This is a NOOP at present, as no UPN is provided by the Heimdal KDC.
2021-12-22 16:37:24 +11:00
Luke Howard
692ed5e841 krb5: fix build regression in report_canonical_client_name
Fix build regression introduced in 5ba46072.
2021-12-22 15:01:54 +11:00
Luke Howard
7990dc287d asn1: use " instead of ' when quoting on Windows
NMAKE on Windows requires " instead of ' be used when quoting arguments. Fixes
regression introduced in fe095aa1c0.
2021-12-22 14:52:04 +11:00
Luke Howard
7cd99b86d3 roken: include MIT license text 2021-12-22 14:45:35 +11:00
Luke Howard
5ba4607277 krb5: report_canonical_client_name implies check_pac 2021-12-22 14:33:01 +11:00
Luke Howard
9aa67e58ba roken: don't call assert() before variable decl 2021-12-22 13:43:17 +11:00
Luke Howard
8590499b53 kdc: include SID in PAC with GSS authorizer
Update the sample GSS pre-authentication authorizer plugin to allow the PAC to
be pinned to the authenticating user's SID.

There is still a race condition between the time the user authenticates and the
time the SID is looked up via LDAP, but it should be sufficient as an example;
if more security is required, then users should be enrolled with their SIDs.
2021-12-22 10:36:26 +11:00
Luke Howard
a2c225fe0a kdc: add PA PAC finalize callback
Note the selected pre-authentication mechanism, and add a callback to allow the
pre-authentication mechanism to update the PAC immediately prior to signing.
2021-12-22 10:36:26 +11:00
Luke Howard
f7964251ff kdc: support for PAC_ATTRIBUTES_INFO
Add PAC_ATTRIBUTES_INFO to the PAC. This info buffer indicates whether the user
explicitly requested a PAC be present or absent.

Note: this changes the windc plugin ABI.
2021-12-22 10:36:26 +11:00
Luke Howard
e50033aec2 kdc: add canonical principal name to authz data
Use the UPN_DNS_INFO buffer of the PAC to include the canonical principal name.

Arguably we should use AD-LOGIN-ALIAS as defined in RFC6806, but we may not
always know all the principal's aliases, and this approach allows us to share
application service logic with Windows.
2021-12-22 10:36:26 +11:00
Luke Howard
0ab3b7b2dd krb5: support for canonical name in PAC
If the UPN_DNS_INFO buffer in the Windows PAC contains a canonical principal
name, use it in lieu of the ticket client name to determine the GSS-API
initiator name.
2021-12-22 10:36:26 +11:00
Luke Howard
b3bb3ac49d roken: add rk_clzll() helper function 2021-12-22 10:36:26 +11:00
Luke Howard
29cd8a46d8 krb5: zero memory in krb5_storage_emem() 2021-12-22 10:36:26 +11:00
Nicolas Williams
5528039a07 bx509d: Fix tests/kdc/check-bx509
Grep pattern needed updating.
2021-12-20 16:35:16 -06:00
Luke Howard
2bb85f61e9 roken: unbreak Windows build 2021-12-21 08:19:31 +11:00
Nicolas Williams
fe095aa1c0 krb5: Decorate Principal type with name attributes
See `asn1: Add --decorate=... for internal bookkeeping`, which adds an
option to `asn1_compile` for decorating SET/SEQUENCE types with fields
that are neither encoded nor decoded, but which _are_ copied and freed.

We'll use this to add name attributes to the `Principal` type (which is
used to represent Kerberos principal names in the krb5 GSS mechanism)
without having to rototill the GSS krb5 mechanism nor the krb5 library,
and without affecting the encodings of HDB entries (which happen to use
the `Principal` type).
2021-12-20 11:51:53 -06:00