Skip to content

fix(soap/auth): preserve instance component of host/service principals - #105

Merged
cryptomilk merged 2 commits into
openSUSE:masterfrom
cryptomilk:asn-fix
Jun 29, 2026
Merged

cryptomilk merged 2 commits into
openSUSE:masterfrom
cryptomilk:asn-fix

Conversation

@cryptomilk

@cryptomilk cryptomilk commented Jun 26, 2026

Copy link
Copy Markdown
Collaborator

Replace the manual if/else reconstruction and the hardcoded KRB5_NT_ENTERPRISE_PRINCIPAL service_type with a simple str(principal) call. The Principal class now infers the correct type from its parsed components and knows how to render itself as a string.

The old "%s@%s" % (primary, realm) reconstruction was also lossy for service principals (e.g. host/node@REALM would have been stored as node@REALM); str(principal) preserves all components correctly.

Fixes: #103

@cryptomilk
cryptomilk force-pushed the asn-fix branch 6 times, most recently from fa4d750 to dbbdfd8 Compare June 26, 2026 15:26
cryptomilk and others added 2 commits June 29, 2026 10:02
Add a __str__ method to Principal that produces the canonical string
representation (primary/instance@realm, primary/instance/domain@realm,
or primary@realm), so callers no longer need to reconstruct the string
manually.

Infer service_type from the parsed principal components : 2-component
service principals (service/host@REALM) are typed as KRB5_NT_SRV_HST,
3-component domain-based principals (service/host/domain@REALM) as
KRB5_NT_SRV_HST_DOMAIN (RFC 5179), and bare principals as
KRB5_NT_ENTERPRISE_PRINCIPAL. An explicit service_type argument always
takes precedence. The sname_to_principal path falls back to
KRB5_NT_SRV_HST when no type is given.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Replace the manual if/else reconstruction and the hardcoded
KRB5_NT_ENTERPRISE_PRINCIPAL service_type with a simple str(principal)
call. The Principal class now infers the correct type from its parsed
components and knows how to render itself as a string.

Fixes: openSUSE#103

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
@abbra

abbra commented Jun 29, 2026

Copy link
Copy Markdown

LGTM

@cryptomilk
cryptomilk merged commit 0a3e430 into openSUSE:master Jun 29, 2026
9 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

KRB5_NT_ENTERPRISE_PRINCIPAL drops instance component from host principals

2 participants