youauth.texi (54325B)
1 @title YouAuth: A Decentralized P2P Authentication and Authorization Protocol 2 @node Current Outline 3 @chapter Current Outline for the YouAuth LSD Proposal 4 5 In the GNU tradition of crafting documentation that liberates protocols through clear, extensible specifications---much as LSD0001 (The GNU Name System) provides a blueprint for decentralized naming---we refine our outline to prioritize YouAuth's practical, DNS-based P2P authentication while noting optional enhancements like GNS for advanced scenarios. This balances ubiquity with future-proofing, ensuring the protocol empowers users without imposing niche dependencies. The structure follows LSD templates, with normative sections for core flows and informative appendices for extensions. 6 7 @menu 8 * Abstract:: 9 * Status of This Memo:: 10 * Introduction:: 11 * Terminology:: 12 * Overview:: 13 * Identities and Authentication:: 14 * Authorization and Data Sharing:: 15 * Cryptography:: 16 * Resolution Mechanisms:: 17 * Security Considerations:: 18 * GANA Considerations:: 19 * Implementation Status:: 20 * References:: 21 * Appendices:: 22 @end menu 23 @node Abstract 24 @section Abstract 25 26 YouAuth is a lightweight decentralized, peer-to-peer authentication and authorization protocol that empowers users with self-sovereign domain-based identities. By leveraging standard DNS/HTTPS for resolution and optionally the GNU Name System (GNS) for enhanced privacy, YouAuth establishes a secure foundation for subsequent data sharing by enabling peers to mutually generate a token pair and a shared secret for end-to-end encryption (layered over HTTPS), using cryptographic primitives such as Elliptic Curve Diffie-Hellman (ECDH) over P-384 for key exchange, HKDF-SHA256 for key derivation, and AES-CBC/GCM for encryption - ensuring P2P E2E security without intermediaries. 27 28 While similar decentralization could be achieved by operating their own OpenID Connect (OIDC) servers, often referred to as Bring Your Own OIDC (BYO-OIDC), YouAuth offers a more streamlined, purpose-built protocol that natively incorporates end-to-end peer-to-peer encryption, avoiding OIDC's extensive specification ecosystem and the need for custom extensions to achieve comparable security and privacy. In terms of security, YouAuth's use of HKDF(ECDH(priv_self, pub_other), salt) provides equivalence to OIDC's PKCE (Proof Key for Code Exchange) in mitigating interception and replay attacks through short-lived values and secure transport, but delivers higher security for the final secret (e.g., the Client Access Token and shared secret) by layering application-level encryption on top of HTTPS, protecting against potential decryption at intermediaries like corporate firewalls or browser extensions where TLS alone might be vulnerable. 29 30 This specification outlines normative flows, extensions, and considerations for interoperable implementations. 31 32 33 34 @node Status of This Memo 35 @section Status of This Memo 36 37 This document is a draft specification for the YouAuth protocol, submitted as an independent proposal to the GNUnet community for consideration as a Layered System Design (LSD) document. It does not represent consensus within the GNUnet project or any standards body such as the IETF. This draft is intended to solicit feedback and foster discussion on decentralized authentication mechanisms. 38 39 The information in this document is provided "as is" without warranty of any kind. Implementers are encouraged to review and test the specification but should not deploy it in production without further validation. 40 41 This draft expires on April 29, 2026. After this date, it should be considered obsolete unless updated or adopted. 42 43 Distribution of this document is unlimited. 44 @node Introduction 45 @section Introduction 46 Centralized authentication services, such as those provided by major platforms like Google, Twitter, or Facebook, offer convenience for logging into third-party sites, via OAUTH, without requiring separate credentials for each service. However, these systems introduce significant drawbacks that undermine user privacy, autonomy, and security. 47 The primary issues with centralized authentication include: 48 @itemize @bullet 49 @item 50 @strong{Privacy Concerns}: Centralized platforms track users' login activities across sites, collecting data on what services are accessed and when. This pervasive surveillance compromises personal privacy and enables detailed profiling. 51 @item 52 @strong{Web Tracking}: Users are further exposed through cross-site tracking mechanisms embedded by these services, allowing the aggregation of behavioral data for advertising or other purposes. 53 @item 54 @strong{Loss of Control}: Access to third-party sites is ultimately governed by the centralized provider. If a user is deplatformed or their account is suspended, they lose access to all integrated services without recourse. 55 @item 56 @strong{Service Dependency}: Similarly, if the centralized platform revokes access for a third-party service, users are cut off from that service, regardless of their own preferences. 57 @item 58 @strong{Data Sharing Limitations}: Users have minimal control over what personal information is shared with third-party sites or how it is used, often leading to over-sharing and potential misuse. 59 @end itemize 60 61 YouAuth addresses these challenges by providing a decentralized, peer-to-peer (P2P) authentication protocol that empowers users with self-sovereign identities based on domain names. By leveraging existing web technologies like DNS and HTTPS for resolution and communication, YouAuth enables direct, secure exchanges between peers without relying on intermediary authorities. This approach restores user control, enhances privacy through end-to-end encryption and data minimization, and ensures compatibility with standard web infrastructure, including seamless integration with web browsers for client-side authentication flows. 62 63 In YouAuth, users authenticate themselves to third-party sites using their own domain-based identities (e.g., samwisegamgee.me). The protocol supports granular authorization, allowing users to specify exactly what information is shared and under what conditions. Through YouAuth, peers can exchange cryptographic information that is encrypted in such a way that it can only be decrypted within the intended application or site, rendering man-in-the-middle (MITM) attacks ineffective for accessing sensitive data—a level of protection not fully achieved in traditional OAuth implementations, where transport-layer security (TLS) protects transmission but does not inherently ensure application-specific decryption. Third parties are not required to store sensitive user data, reducing risks for both users and services. Critically, YouAuth eliminates centralized tracking, as all interactions occur directly between the user's identity host and the requesting peer. 64 65 YouAuth builds on proven standards, including HTTPS for secure transport, SSL certificates for verification, Elliptic Curve Cryptography (ECC) for key exchanges, AES for encryption, DNS and DNSSEC for resolution, and optional Client Certificate Authentication for enhanced security in identity-to-identity flows. While DNS serves as the primary, normative resolution mechanism for broad accessibility, the protocol includes informative support for advanced alternatives like the GNU Name System (GNS) to provide censorship resistance and privacy in specialized scenarios. 66 This document specifies the YouAuth protocol in a manner that promotes interoperability, extensibility, and user freedom, in the spirit of GNU documentation. Implementations can enable a truly decentralized web where authentication is liberated from corporate silos. 67 68 Systems like re:claimID (LSD0002) provide decentralized identity management with verifiable credentials; YouAuth complements this by offering P2P authentication compatible with web technologies, enabling access to such credentials via granular permissions in the Client Access Token (CAT). 69 70 The key words "MUST", "MUST NOT", "REQUIRED", "SHALL", "SHALL NOT", "SHOULD", "SHOULD NOT", "RECOMMENDED", "NOT RECOMMENDED", "MAY", and "OPTIONAL" in this document are to be interpreted as described in BCP 14 [@cite{RFC2119}] [@cite{RFC8174}] when, and only when, they appear in all capitals, as shown here. 71 @node Terminology 72 @section Terminology 73 74 This section defines key terms used throughout this document to ensure clarity and consistency. Terms are presented in alphabetical order for reference. 75 76 @table @dfn 77 @item Authentication Code 78 A short-lived, single-use code generated by the identity host during the authorization flow. It is transmitted unencrypted to the requesting peer but expires quickly (e.g., within seconds) to mitigate replay attacks. 79 80 @item Client Access Token (CAT) 81 A cryptographic token issued by the identity host to the requesting peer upon successful authentication and authorization. The CAT serves as proof of the user's identity and includes any granted permissions. It is encrypted using a shared secret and can be used for subsequent secure interactions. 82 83 @item Client Type 84 The category of the requesting peer, which influences consent requirements and permission handling. Valid types are: 85 @itemize @bullet 86 @item @code{app}: A single-page or native application (e.g., a mobile app accessing user data). 87 @item @code{domain}: A domain-based peer (e.g., a website like @code{frodo.me} or @code{shop.amazon.com}). 88 @end itemize 89 90 @item Consent Requirement 91 A policy specifying when user consent is needed for authentication or authorization. Types include: 92 @itemize @bullet 93 @item @code{Always}: Consent is required for every request. 94 @item @code{Expiring}: Consent is required after a specified expiration time. 95 @item @code{Never}: No consent is required (use with caution). 96 @end itemize 97 98 @item Identity 99 A domain-based identifier representing a user or entity in the YouAuth protocol (e.g., @code{samwisegamgee.me}). The identity host manages authentication and authorization for this identifier. 100 101 @item Peer 102 In the context of YouAuth's P2P model, a peer refers to a domain or application participating in direct exchanges. Peers include the user's identity host and the requesting client (either an @code{app} or @code{domain}). 103 104 @item Permission Request 105 A list of specific permissions requested by the client, such as access to certain data drives or operations (e.g., @code{drive:xyz:read}). These are evaluated during consent and included in the CAT if approved. 106 107 @item Shared Secret 108 A cryptographically derived value computed independently by both peers using Elliptic Curve Diffie-Hellman (ECDH) key exchange, combined with a Key Derivation Function (KDF) like HKDF and a random salt. It is used for encrypting sensitive data, such as the CAT, ensuring only the intended parties can decrypt it. 109 @end table 110 111 Additional terms from referenced standards (e.g., ECDH, HKDF) are used as defined in their respective specifications. 112 @node Overview 113 @section Overview 114 115 YouAuth operates as a decentralized peer-to-peer (P2P) authentication and authorization protocol, where identities are represented by domain names and interactions occur directly between the user's identity host and the requesting peer (client). The protocol follows a flow inspired by OAuth 2.0's authorization code grant but adapted for P2P environments: the client redirects the user's browser to the identity host, obtains user consent if required, and exchanges cryptographic material for a Client Access Token (CAT) that serves as proof of the user's identity and provides access to granted permissions for subsequent interactions. All sensitive exchanges are secured using Elliptic Curve Diffie-Hellman (ECDH) for shared secret derivation, HKDF for key strengthening, and AES-CBC for encryption, ensuring end-to-end protection against interception. 116 117 The high-level flow is as follows: 118 119 @enumerate 120 @item 121 The client (e.g., a website or app) redirects the user's browser to the identity host's @code{/authorize} endpoint, providing parameters such as the client type (@code{app} or @code{domain}), client ID, public key, permission requests, and a redirect URI. 122 123 @item 124 The identity host checks if the user is authenticated; if not, it prompts for login. It then verifies if consent is needed based on the consent requirements (e.g., always, expiring, or never). If consent is required, the user is prompted via a frontend interface. 125 126 @item 127 Upon approval, the identity host generates a temporary ECC key pair, computes an exchange shared secret using ECDH (its temporary private key and the client's public key) combined with HKDF and a random salt, encrypts the CAT and a new random shared secret (for future communications) using this exchange shared secret, stores the encrypted data in a cache keyed by the SHA-256 digest of the exchange shared secret, and redirects back to the client with its temporary public key and salt. 128 129 @item 130 The client computes the exchange shared secret using its private key, the identity host's temporary public key, and the salt (via ECDH and HKDF), computes the digest, and requests the encrypted data from the @code{/token} endpoint using the digest. 131 132 @item 133 The identity host validates the digest, retrieves the encrypted data from the cache, and returns it (the encrypted CAT and new shared secret, along with their respective IVs). 134 @end enumerate 135 136 This flow ensures that authentication only proceeds with explicit user control, minimizes data exposure, and resists man-in-the-middle attacks through application-level encryption. Note that the CAT itself is a token providing proof of identity and permissions; it does not contain additional user data. The successful decryption of the response from the @code{/token} endpoint (using the exchange shared secret) confirms the user's identity, as only the legitimate identity host could have encrypted it with the matching shared secret (because the validation https request is to the user's domain and X509 certificate). While the client could theoretically verify identity solely through successful decryption without fully utilizing the CAT (if no further access is needed), in practice, decryption yields the CAT and new shared secret, which are typically required for any authorized data requests. For further interactions, the client uses the CAT and new shared secret to authenticate API calls to the identity host and retrieve any authorized information (e.g., profile details or payment info). 137 138 To illustrate, consider a shopping example where Sam Gamgee (identity: @code{samwisegamgee.me}) wants to authenticate to an online shop at @code{www.southfarthing.com} to purchase tobacco. 139 140 @itemize @bullet 141 @item 142 Sam enters his identity @code{samwisegamgee.me} on the shop's login page and submits. 143 144 @item 145 The shop generates an ECC key pair and redirects Sam's browser to @code{https://samwisegamgee.me/authorize} with parameters including its public key, client type (@code{domain}), client ID (@code{southfarthing.com}), and redirect URI. 146 147 @item 148 Sam's identity host checks for login and consent. Assuming Sam is logged in but hasn't approved @code{southfarthing.com}, he is prompted to consent (e.g., "www.southfarthing.com wants to confirm your identity. Auto-login in the future?"). 149 150 @item 151 Upon approval, the identity host generates a temporary ECC key pair, computes the exchange shared secret (ECDH + HKDF with salt), encrypts the CAT and new random shared secret, caches it under the digest, and redirects back with its temporary public key and salt. 152 153 @item 154 The shop computes the exchange shared secret and digest, sends the digest to @code{https://samwisegamgee.me/token}, receives the encrypted response, and decrypts it to obtain the CAT and new shared secret, verifying Sam's identity. 155 156 @item 157 For additional authorization (e.g., accessing address or payment info), the shop includes permission requests in the initial redirect, and Sam consents to specific terms. The CAT allows subsequent access to granted permissions, enabling the shop to make authenticated calls (using the CAT and new shared secret) to Sam's identity host to retrieve the authorized data securely. 158 @end itemize 159 160 The following ASCII diagram depicts the core flow: 161 162 @example 163 @verbatim 164 +-------------+ +----------------+ +-------------------+ 165 | Sam's | | Southfarthing | | Sam's Identity | 166 | Browser | | (Shop) | | Host | 167 +-------------+ +----------------+ +-------------------+ 168 | | | 169 | [User enters ID and clicks login] | 170 | | | 171 |<------------------------------| | 172 | | | 173 |------------------------------>| [010] Generate ECC keys | 174 | | | 175 |------------------------------>| | 176 | | [030] Redirect to /authorize | 177 | | with params (public_key, etc.) | 178 | |<--------------------------------| 179 | | | 180 |------------------------------>| [040-050] Check login/consent | 181 | | | 182 | | [070] Gen temp ECC pair, | 183 | | compute exchange SS (ECDH+HKDF)| 184 | | encrypt CAT & new SS, cache | 185 | | | 186 | | [080] Redirect back with | 187 | | temp public_key, salt | 188 | |-------------------------------->| 189 | | | 190 |<------------------------------| [090] Compute exchange SS | 191 | | | 192 | | [100] POST to /token with | 193 | | secret_digest | 194 | |-------------------------------->| 195 | | | 196 | | [110-140] Validate digest, | 197 | | return encrypted CAT & new SS | 198 | |<--------------------------------| 199 | | | 200 | | [150] Decrypt; auth complete | 201 | | | 202 | | [Post-flow] Use CAT & new SS | 203 | | to request authorized data | 204 | |-------------------------------->| 205 @end verbatim 206 @end example 207 208 Note that resolution of identities primarily uses DNS over HTTPS for compatibility with existing web infrastructure and browser-native operations. The HTTPS validation of the X.509 certificate is a crucial aspect of the flow, providing irrefutable proof of the domain (and thus the username) from the identity host. As an optional enhancement, integration with the GNU Name System (GNS) is supported for scenarios requiring greater privacy or censorship resistance, such as via proxies or distributed hash tables (DHTs). Details on GNS integration are provided informatively in appendices. 209 @node Identities and Authentication 210 @section Identities and Authentication 211 212 YouAuth identities are domain-based, leveraging DNS names (e.g., @code{samwisegamgee.me}) to establish self-sovereign control. This ensures users own their identifiers through standard domain registration, avoiding centralized silos. Identities resolve via HTTPS endpoints on the domain, enabling P2P exchanges without intermediaries. The protocol mandates X.509 certificate validation during resolution to confirm domain ownership, providing cryptographic proof of identity. 213 214 The core authentication flows occur via two endpoints: @code{/authorize} (GET/POST) for initiation and consent, and @code{/token} (POST) for token exchange. These mimic OAuth 2.0's authorization code flow but in a decentralized manner, with direct peer communication. 215 216 @subsection Authorize Endpoint (@code{/authorize}) 217 This endpoint handles the initial request and user consent. 218 219 @itemize @bullet 220 @item @strong{GET Request Parameters}: 221 @table @code 222 @item redirect_uri 223 Required: Callback URI for redirect after authorization (HTTPS only). 224 @item client_type 225 Required: @code{app} or @code{domain}, determining consent and permission handling. 226 @item client_id 227 Required: UUID for apps or domain name for domains (must match @code{redirect_uri} host for domains). 228 @item public_key 229 Required: Base64-encoded ECC public key (P-384) from the client. 230 @item state 231 Optional: Client-defined value echoed in response for CSRF protection. 232 @item permission_request 233 Optional: JSON-encoded list of permissions (e.g., @code{["drive:xyz:read", "profile:email"]}). 234 @item client_info 235 Optional: JSON or URL with client details (name, description) for consent display. 236 @end table 237 238 @item @strong{Processing}: 239 - Validate parameters and client_type-specific rules. 240 - Check if user is authenticated (via session cookie); redirect to login if not. 241 - For @code{client_type=app}, ensure app registration; prompt if unregistered. 242 - Determine consent need based on prior approvals and permission_request. 243 - If consent required, redirect to frontend consent page (e.g., @code{/owner/youauth/authorize}). 244 - Upon consent, generate temporary ECC key pair, compute exchange shared secret (ECDH + HKDF), encrypt CAT and new shared secret, cache under digest. 245 - Redirect to @code{redirect_uri} with: 246 @table @code 247 @item identity 248 Authorizing domain. 249 @item public_key 250 Temporary public key. 251 @item salt 252 Base64-encoded salt. 253 @item state 254 Echoed value. 255 @end table 256 257 @item @strong{POST for Consent (Internal)}: 258 Used by frontend to store consent after user approval. 259 Parameters: @code{return_url}, @code{consent_req} (JSON for ConsentRequirements: @code{always}, @code{expiring}, @code{never}). 260 @end itemize 261 262 @subsection Token Endpoint (@code{/token}) 263 Exchanges digest for encrypted tokens. 264 265 @itemize @bullet 266 @item @strong{POST Request Parameters}: 267 @table @code 268 @item secret_digest 269 Required: Base64-encoded SHA-256 digest of exchange shared secret. 270 @end table 271 272 @item @strong{Processing}: 273 - Lookup cached encrypted data by digest. 274 - If found, return JSON response and MUST delete the cache entry to enforce one-time use and prevent replays; else, 404. 275 - Response: 276 @table @code 277 @item base64SharedSecretCipher 278 AES-CBC encrypted new shared secret. 279 @item base64SharedSecretIv 280 Initialization vector. 281 @item base64ClientAuthTokenCipher 282 AES-CBC encrypted CAT. 283 @item base64ClientAuthTokenIv 284 Initialization vector. 285 @end table 286 - Client decrypts using exchange shared secret to obtain CAT and new shared secret for further interactions. 287 @end itemize 288 289 @subsection Consent Handling 290 Consent is user-centric and granular. For domains, prior consents can auto-approve unless new permissions are requested. Apps always require initial consent. ConsentRequirements allow configuration: always prompt, expire after time, or never prompt. Stored consents minimize friction while preserving control. 291 292 @subsection Wire Formats 293 All endpoints use HTTPS. Parameters are URL-encoded in GET/redirects; JSON in POST bodies/responses. Errors follow HTTP status codes (e.g., 400 for invalid params, 401 for unauthorized). 294 295 This section defines the normative P2P authentication mechanics, ensuring secure, consensual identity verification without central authorities. 296 @node Authorization and Data Sharing 297 @section Authorization and Data Sharing 298 299 YouAuth extends beyond mere authentication to enable fine-grained authorization and secure data sharing. Authorization is integrated into the authentication flow, allowing clients to request specific permissions during the @code{/authorize} step. The resulting Client Access Token (CAT) encapsulates these granted permissions, serving as a proof of consent for subsequent data access. This design emphasizes data minimization, user control, and privacy, ensuring that only necessary information is shared under explicit conditions. 300 301 @subsection Permission Requests and the CAT 302 Permissions are requested via the @code{permission_request} parameter in the @code{/authorize} GET request. This is a JSON-encoded array of permission strings, following a scoped format such as @code{"drive:profile:read"}, @code{"profile:email"}, or @code{"payment:info:write"}. These scopes define the actions (e.g., read, write) on specific resources (e.g., profile, payment info). 303 304 During processing: 305 @itemize @bullet 306 @item The identity host parses the @code{permission_request} and presents it to the user during consent (if required). 307 @item Users can approve, deny, or modify permissions (e.g., grant read-only instead of read-write). 308 @item Upon approval, the identity host embeds the granted permissions into the CAT. 309 @item The CAT is a structured token (e.g., JWT-like, signed with EdDSA) containing: 310 @itemize @bullet 311 @item Issuer: The identity domain. 312 @item Subject: The client's @code{client_id}. 313 @item Granted permissions: Array of approved scopes. 314 @item Expiry: Short-lived by default (e.g., 1 hour), configurable. 315 @item Audience: Restricted to the client's domain or app ID. 316 @end itemize 317 @end itemize 318 319 The CAT does not contain user data itself but acts as an access credential. Clients must present the CAT (and use the new shared secret from the token exchange, for AES encryption/decryption of data) in subsequent API requests to the identity host to retrieve authorized data. 320 321 @subsection Data Sharing Mechanics 322 Data sharing occurs post-authentication via authenticated API calls to the identity host's endpoints (e.g., @code{/api/data/profile}). These endpoints are not normatively defined in this specification but follow these principles: 323 324 @itemize @bullet 325 @item @strong{Authentication}: Requests must include the CAT in headers (e.g., @code{Authorization: Bearer <CAT>}) and prove knowledge of the shared secret (e.g., via HMAC signature). 326 @item @strong{Encryption}: Responses are encrypted end-to-end using the shared secret (AES-CBC), ensuring only the authorized client can decrypt. 327 @item @strong{Data Minimization}: Only requested and consented data is returned. For example, if @code{"profile:email"} is granted, only the email is shared, not the full profile. 328 @item @strong{User Controls}: During consent, users can impose restrictions, such as: 329 - No storage: The client must not persist the data (enforced via token claims or agreements; auditable but not technically prevented). 330 - Time-bound access: Permissions expire automatically. 331 - Revocation: Users can revoke consents via their identity host's interface, invalidating CATs. 332 @end itemize 333 334 For advanced verifiable credential sharing, implementations MAY integrate with re:claimID (LSD0002), where YouAuth's CAT can authorize access to stored attributes. 335 336 Informative: For browser-based clients, implementations MAY split the CAT into components (e.g., a visible ID cookie and an HTTP-only secure secret) to mitigate XSS and JS access risks, with server-side key derivation (e.g., via XOR) for session security. In mobile/apps, the full CAT can be used in headers. The reference Odin C# implementation employs this split for enhanced web security. 337 338 Example: In the shopping scenario, the shop requests @code{["profile:address", "payment:info"]}. After consent, the CAT grants these. The shop then queries the identity host for the address and payment details, receiving encrypted responses. 339 340 @subsection Identity-to-Identity Interactions 341 For peer-to-peer interactions between YouAuth identities (e.g., one domain authenticating to another), mutual authentication is strengthened: 342 343 @itemize @bullet 344 @item @strong{Client Certificates}: The requesting peer must present a valid X.509 client certificate during TLS handshake, proving domain ownership. 345 @item @strong{Mutual TLS (mTLS)}: Both peers validate certificates, ensuring bidirectional trust. 346 @item @strong{Ease for Third-Parties}: Non-identity clients (e.g., e-commerce sites) are not required to present client certificates, lowering integration barriers while maintaining server-side validation via HTTPS. 347 @end itemize 348 349 This enables secure, direct data sharing between users' domains, such as syncing profiles or payments in a decentralized network. 350 351 @subsection Privacy and Control Considerations 352 YouAuth prioritizes user sovereignty: 353 - No unnecessary data is shared without consent. 354 - Permissions are granular and revocable. 355 - Data flows directly P2P, avoiding centralized tracking. 356 - Clients are encouraged to implement just-in-time data fetching, reducing storage needs. 357 358 Implementations MUST log consent events for user review and SHOULD provide interfaces for permission management. For full security analysis, see @ref{Security Considerations}. 359 @node Cryptography 360 @section Cryptography 361 YouAuth relies on established cryptographic primitives to ensure confidentiality, integrity, and authenticity in its P2P exchanges. All operations MUST use secure randomness from cryptographically secure sources (e.g., @code{/dev/urandom} on Unix-like systems or equivalent). Implementations MUST validate all inputs, such as public keys and digests, to prevent attacks like invalid curve points or weak keys. 362 @subsection Key Exchange and Shared Secret Derivation 363 Elliptic Curve Diffie-Hellman (ECDH) over the NIST P-384 curve (secp384r1) is used for ephemeral key exchanges during authentication. 364 @itemize @bullet 365 @item @strong{Key Generation}: Generate ECC key pairs using P-384 parameters as defined in RFC 5480. Public keys are encoded in JSON Web Key (JWK) format, base64url-encoded for transmission. 366 @item @strong{ECDH Computation}: Compute the raw shared secret using the client's private key and the peer's public key (or vice versa). 367 @item @strong{Key Derivation}: Derive the final shared secret using HKDF (RFC 5869) with SHA-256 as the hash function: 368 369 Input Keying Material (IKM): Raw ECDH output. 370 Salt: Random 16-byte salt generated by the identity host, base64-encoded in responses. 371 Info: Empty or protocol-specific label (e.g., @code{"YouAuth-Exchange"}). 372 Output Length: 16 bytes for AES-128 (normative minimum); implementations SHOULD derive 32 bytes for AES-256 to provide higher security margins, especially against potential quantum threats. 373 @item @strong{Digest for Lookup}: Compute a SHA-256 digest of the derived shared secret for secure, indirect cache lookups in the @code{/token} endpoint. 374 @end itemize 375 376 @subsection Encryption and Decryption 377 Symmetric encryption protects tokens and data during exchanges. 378 @itemize @bullet 379 @item @strong{Algorithm}: AES-128 in CBC mode (AES-CBC) with PKCS#7 padding (normative minimum); implementations SHOULD use AES-256 for enhanced security. For new implementations, consider AEAD modes like AES-GCM (NIST SP 800-38D) for built-in authentication, better performance, and resistance to certain attacks, though CBC remains secure when paired with separate integrity mechanisms. 380 @item @strong{Key}: The 16-byte (AES-128) or 32-byte (AES-256) derived shared secret from HKDF. 381 @item @strong{Initialization Vector (IV)}: Random 16-byte IV per encryption, base64-encoded in responses. IVs MUST be unique and unpredictable to prevent attacks. 382 @item @strong{Usage}: Encrypt the Client Access Token (CAT) and new persistent shared secret during @code{/authorize} processing. Clients decrypt using the exchange shared secret; the new shared secret secures future data APIs. When using CBC, ALWAYS pair with integrity checks (e.g., HMAC-SHA-256 or the signed CAT) to mitigate padding oracle and other attacks. 383 @end itemize 384 @subsection Signing and Verification 385 The CAT is signed to ensure integrity and authenticity. 386 @itemize @bullet 387 @item @strong{Algorithm}: EdDSA (Edwards-curve Digital Signature Algorithm) over Ed25519 as per RFC 8032. 388 @item @strong{Structure}: The CAT is a compact, serialized structure (e.g., JWT-like: header.payload.signature), with the header specifying @code{alg=EdDSA} and @code{typ=CAT}. 389 @item @strong{Verification}: Clients MUST verify the signature using the identity host's public key (obtainable via well-known endpoints or included in responses) and check claims like issuer, expiry, and audience. 390 @end itemize 391 @subsection Additional Requirements 392 393 @strong{Randomness}: All random values (keys, salts, IVs) MUST be generated with at least 128 bits of entropy. 394 @strong{Validation}: Implementations MUST perform point validation on received ECC public keys to mitigate invalid curve attacks. 395 @strong{Key Rotation}: Ephemeral keys for each exchange; persistent shared secrets SHOULD rotate periodically. 396 @strong{Forward Secrecy}: Achieved via ephemeral ECDH for each authentication flow. 397 @strong{Quantum Considerations}: While AES-128 provides strong classical security, AES-256 offers better resistance to quantum attacks (e.g., Grover's algorithm). Future versions SHOULD explore post-quantum key exchange alternatives. 398 399 For security analysis, including resistance to quantum threats (consider post-quantum alternatives in future versions), see @ref{Security Considerations}. Normative references: RFC 5869 (HKDF), RFC 8032 (EdDSA), NIST SP 800-38A (AES-CBC), NIST SP 800-38D (AES-GCM). 400 @node Resolution Mechanisms 401 @section Resolution Mechanisms 402 403 YouAuth prioritizes ubiquitous, browser-native resolution mechanisms to facilitate broad adoption while allowing for advanced privacy enhancements. The normative resolution uses DNS and HTTPS, leveraging existing web infrastructure for peer discovery and communication. This ensures compatibility with standard browsers and servers without requiring additional software. Informatively, integration with the GNU Name System (GNS) is described for scenarios demanding higher privacy or resistance to censorship, though it is optional and may require proxies or DHT-based resolution. 404 405 @subsection Normative: DNS and HTTPS Resolution 406 Identities are resolved via standard DNS lookups on the domain name (e.g., @code{samwisegamgee.me}). Implementations MUST support this method as the primary mechanism. 407 408 @itemize @bullet 409 @item @strong{Domain Resolution}: Use DNS to resolve the identity domain to an IP address. DNSSEC SHOULD be enabled for added integrity against cache poisoning. 410 @item @strong{Endpoint Discovery}: Authentication endpoints (@code{/authorize}, @code{/token}) are accessed via HTTPS on the resolved domain. Well-known URIs (per RFC 8615) MAY be used for additional metadata, such as public keys or supported features (e.g., @code{/.well-known/youauth}). 411 @item @strong{TLS Validation}: All connections MUST use HTTPS with valid X.509 certificates matching the domain, ensuring server authentication and encryption in transit. 412 @item @strong{Browser Compatibility}: This method enables direct P2P flows in web browsers without extensions, as redirects and requests are handled natively. 413 @end itemize 414 415 This approach balances simplicity and security, allowing any domain owner to host a YouAuth identity without specialized infrastructure. 416 417 @subsection Informative: Optional GNS Integration 418 For enhanced privacy and decentralization, YouAuth MAY integrate with the GNU Name System (GNS, as defined in LSD0001). GNS provides a censorship-resistant, privacy-preserving alternative to DNS via a distributed hash table (DHT) and user-controlled namespaces. 419 420 @itemize @bullet 421 @item @strong{GNS Resolution}: Identities can be registered as GNS records (e.g., under @code{.gnu} TLD). Resolution occurs via GNS clients or proxies, mapping to IP addresses or other locators. 422 @item @strong{Hybrid Flows}: Clients MAY attempt GNS resolution first, falling back to DNS if unavailable. This is useful in censored environments. 423 @item @strong{Privacy Benefits}: GNS avoids central registries, reducing tracking risks. However, it requires GNS-aware software or gateways, limiting ubiquity. 424 @item @strong{Implementation Notes}: Use GNS record types for YouAuth-specific data (e.g., public keys). See @ref{GANA Considerations} for registry requests. 425 @end itemize 426 427 While GNS offers future-proofing, it is not required; DNS/HTTPS suffices for most deployments. Hybrid implementations SHOULD prioritize DNS for compatibility. 428 @node Security Considerations 429 @section Security Considerations 430 431 This section addresses key security aspects of YouAuth, focusing on threats inherent to decentralized P2P authentication and mitigation strategies. Implementations MUST adhere to these considerations to maintain the protocol's integrity, confidentiality, and user sovereignty. Analysis draws from standard threat models (e.g., Dolev-Yao) adapted for P2P environments, emphasizing active adversaries, network attacks, and user errors. 432 433 @subsection Consent and User Control 434 User consent is mandatory for all authentications and authorizations to prevent unauthorized access. 435 @itemize @bullet 436 @item Implementations MUST prompt for explicit consent unless pre-approved (e.g., via ConsentRequirements), and MUST log all consents for auditability. 437 @item All user interfaces MUST display all remote domains clearly with non-ASCII letters clearly visually marked, such that Ámazon.com isn't mistaken for Amazon.com. 438 @item Risks: Social engineering or UI spoofing could trick users into granting permissions. Mitigations: Use clear, non-deceptive consent interfaces; validate @code{client_info} to display accurate client details. 439 @item Revocation: Users MUST be able to revoke consents and CATs at any time via the identity host. Revoked tokens SHOULD be invalidated immediately (e.g., via blocklists or short expiries). 440 @end itemize 441 442 @subsection Token Lifetimes and Replay Attacks 443 Tokens (e.g., CATs, exchange digests) are short-lived to limit exposure. 444 @itemize @bullet 445 @item CAT expiry MUST be enforced (default: 1 hour; configurable by the user). Exchange caches MUST expire quickly (e.g., 5 minutes) and be deleted post-use (as normatively required in @ref{Identities and Authentication}). 446 @item Risks: Replay of intercepted tokens or digests. Mitigations: One-time use enforced by cache deletion; unique salts/IVs per exchange; timestamp/nonce claims in CATs verified on use. 447 @end itemize 448 449 @subsection Man-in-the-Middle (MITM) Resistance 450 YouAuth resists MITM through cryptographic design. 451 @itemize @bullet 452 @item All communications use HTTPS with TLS 1.3+; domain-validated certificates confirm peer identity. 453 @item ECDH + HKDF derives secrets without transmission; end-to-end encryption (AES-CBC/GCM) protects data beyond TLS. 454 @item Risks: Certificate misissuance or DNS hijacking. Mitigations: DNSSEC for resolution; HPKP/Expect-CT for pinning (informative); mTLS for identity-to-identity flows. 455 @end itemize 456 457 @subsection P2P-Specific Threats 458 Decentralization introduces unique risks compared to centralized systems. 459 @itemize @bullet 460 @item @strong{Peer Validation}: Clients MUST verify identity hosts via TLS and SHOULD make signatures for the CAT. Risks: Impersonation. Mitigations: Public key pinning; cross-check with DNS/GNS records. 461 @item @strong{Denial of Service (DoS)}: Flooding @code{/authorize} or @code{/token}. Mitigations: Rate limiting by client_id/IP; ephemeral keys to avoid state exhaustion. 462 @item @strong{Side-Channel Attacks}: Timing or cache probes. Mitigations: Constant-time crypto operations; randomized delays. 463 @end itemize 464 465 @subsection Privacy Considerations 466 YouAuth minimizes tracking and data exposure. 467 @itemize @bullet 468 @item End-to-end encryption ensures only consented peers access data; no intermediaries (unlike centralized OAuth). 469 @item Risks: Metadata leakage (e.g., login times via DNS queries). Mitigations: Optional GNS for private resolution; anonymizing proxies; data minimization in requests. 470 @item No centralized logging: All flows are direct P2P, reducing surveillance risks. 471 @end itemize 472 473 @subsection Cryptographic Risks and Future-Proofing 474 @itemize @bullet 475 @item Weak keys or randomness: Mitigated by requiring CSPRNGs and input validation. 476 @item Quantum threats: ECDH/P-384 vulnerable to Shor's algorithm; AES-128 to Grover's. Mitigations: Recommend AES-256; plan for post-quantum KEMs (e.g., Kyber) in future versions. 477 @item Downgrade attacks: Enforce minimum versions (e.g., TLS 1.3, AES-128). 478 @end itemize 479 480 Implementers SHOULD conduct threat modeling and audits. Report vulnerabilities to the community for collaborative fixes. Normative references: RFC 3552 (Security Considerations Guidelines), OWASP for web threats. 481 @node GANA Considerations 482 @section GANA Considerations 483 484 YouAuth requires assignments from the GNUnet Assigned Numbers Authority (GANA) to ensure interoperability and avoid collisions in record types, enumerations, and other protocol elements. This section requests the creation or extension of registries, following GANA policies as defined in the GNUnet project. All requests are for first-come-first-served allocation unless specified otherwise, with expert review recommended for additions that impact core security or compatibility. 485 486 @subsection Record Types Registry 487 YouAuth defines new record types for use in resolution mechanisms, particularly for optional GNS integration (see @ref{Resolution Mechanisms}). Request to extend the "GNS Record Types" registry (or create a sub-registry if appropriate): 488 489 @itemize @bullet 490 @item @strong{YOUAUTH_PUBLIC_KEY}: Value 65560. Stores the identity host's EdDSA public key (Ed25519) in JWK format (RFC 7517), serialized to UTF-8 binary for compactness in GNS records. This enables metadata like "alg" and "kid" for verification and rotation. 491 @item @strong{YOUAUTH_ENDPOINT}: Value 65561. Stores well-known endpoint URIs (e.g., @code{/authorize}) as UTF-8 strings. 492 @item @strong{YOUAUTH_FEATURES}: Value 65562. Bitfield for supported features (e.g., bit 0: AES-256 support; bit 1: GNS hybrid). 493 @item Policy: First-come-first-served for values 65563-69999; expert review for lower values to prevent conflicts with core YouAuth extensions. 494 @end itemize 495 496 @subsection Client Types Registry 497 A new registry for ClientType enumeration values used in @code{/authorize} requests. 498 499 @itemize @bullet 500 @item @strong{unknown}: Value 0 (reserved). 501 @item @strong{app}: Value 1. For single-page or native applications. 502 @item @strong{domain}: Value 2. For domain-based peers. 503 @item Policy: Expert review for additions, ensuring new types align with P2P principles and do not introduce security risks. 504 @end itemize 505 506 @subsection Error Codes Registry 507 A new registry for error codes in responses (e.g., JSON fields in @code{/token} 4xx responses or informative logs). 508 509 @itemize @bullet 510 @item @strong{INVALID_PARAMETER}: Value 100. For missing or malformed request params. 511 @item @strong{CONSENT_REQUIRED}: Value 101. When consent is needed but not provided. 512 @item @strong{TOKEN_EXPIRED}: Value 102. For expired or replayed digests/tokens. 513 @item @strong{ACCESS_DENIED}: Value 103. Revoked or invalid permissions. 514 @item Policy: First-come-first-served for values 104-199; expert review for security-critical codes (0-99 reserved for core). 515 @end itemize 516 517 @subsection Signature Purposes Registry 518 Extension to the existing "GNUnet Signature Purposes" registry for EdDSA signatures in CATs. 519 520 @itemize @bullet 521 @item @strong{YOUAUTH_CAT}: Value 42 (example; assign next available). Purpose for signing Client Access Tokens. 522 @item Policy: Expert review, as signatures impact cryptographic trust. 523 @end itemize 524 525 Implementations MUST use these assigned values for interoperability. Future YouAuth versions or extensions MAY request additional entries via GANA updates. Contact the GANA maintainers for assignments. 526 @node Implementation Status 527 @section Implementation Status 528 529 This section provides an overview of known implementations of YouAuth, focusing on reference code, deployment status, and extensions. As an evolving protocol, implementations are in early stages, with emphasis on open-source contributions to foster community development. 530 531 The primary reference implementation is the Odin project from Homebase-ID (https://github.com/homebase-id/), written in C# (.NET). It serves as a back-end web server implementing core YouAuth flows, including domain-based identities, P2P authentication endpoints (@code{/authorize} and @code{/token}), consent handling, and integration with decentralized storage and communications. Key features include Federated Identity Authentication aligned with YouAuth's self-sovereign principles, emphasizing security over traditional OAuth. 532 533 - **Status**: Alpha release; subject to breaking changes and upgrades. Suitable for development and testing, with pre-built identities (e.g., frodo.dotyou.cloud) for local setups. Continuous Integration (CI) workflows support SQLite and PostgreSQL backends. 534 - **Licensing**: Open-source under the Affero General Public License (AGPL-3.0), ensuring freedoms for modification and distribution while requiring source disclosure for networked services. 535 - **Test Deployments**: Local development environments are provided, with optional at-home hosting for fully distributed testing. No production-scale deployments are documented yet, but the implementation supports experimental P2P networks. 536 - **Hybrid Extensions**: The Odin ecosystem includes hybrid support via web technologies (e.g., the odin-js TypeScript monorepo at https://github.com/homebase-id/odin-js), enabling browser-native flows and optional GNS integration through proxies or DHTs for enhanced privacy. This aligns with the protocol's normative DNS/HTTPS and informative GNS resolution. 537 538 Contributions are welcomed via pull requests or community channels (e.g., Discord). Future work may include mobile app integrations and post-quantum cryptography upgrades. Implementers are encouraged to report issues and share extensions to refine the protocol. 539 @node References 540 @section References 541 542 This section lists normative and informative references cited in this document. Normative references provide requirements essential for implementing YouAuth, while informative references offer additional context or background. 543 544 @subsection Normative References 545 @itemize @bullet 546 @item RFC 2119: Key words for use in RFCs to Indicate Requirement Levels. S. Bradner. March 1997. 547 @item RFC 8174: Ambiguity of Uppercase vs Lowercase in RFC 2119 Key Words. B. Leiba. May 2017. 548 @item RFC 5480: Elliptic Curve Cryptography Subject Public Key Information. S. Turner, D. Brown, K. Yiu, R. Housley, T. Polk. March 2009. 549 @item RFC 5869: HMAC-based Extract-and-Expand Key Derivation Function (HKDF). H. Krawczyk, P. Eronen. May 2010. 550 @item RFC 7517: JSON Web Key (JWK). M. Jones. May 2015. 551 @item RFC 8032: Edwards-Curve Digital Signature Algorithm (EdDSA). S. Josefsson, I. Liusvaara. January 2017. 552 @item NIST SP 800-38A: Recommendation for Block Cipher Modes of Operation: Methods and Techniques. M. Dworkin. December 2001 (AES-CBC). 553 @item NIST SP 800-38D: Recommendation for Block Cipher Modes of Operation: Galois/Counter Mode (GCM) and GMAC. M. Dworkin. November 2007 (AES-GCM, informative but referenced for alternatives). 554 @item RFC 3552: Guidelines for Writing RFC Text on Security Considerations. E. Rescorla, B. Korver. July 2003. 555 @end itemize 556 557 @subsection Informative References 558 @itemize @bullet 559 @item LSD0001: The GNU Name System. M. Schanzenbach, C. Grothoff, B. Fix. November 2021. 560 @item LSD0002 @anchor{lsd0002} re:claimID Specification. @url{https://lsd.gnunet.org/lsd0002/}. 561 @item RFC 9498: The GNU Name System. M. Schanzenbach, C. Grothoff, B. Fix. November 2023. 562 @item RFC 8615: Well-Known Uniform Resource Identifiers (URIs). M. Nottingham. May 2019. 563 @item OWASP: Open Worldwide Application Security Project resources for web threats and best practices. 564 @item RFC 7519: JSON Web Token (JWT). M. Jones, J. Bradley, N. Sakimura. May 2015 (for CAT structure inspiration). 565 @end itemize 566 567 Additional resources, such as the Odin implementation (see @ref{Implementation Status}), may provide practical examples and code references. 568 @node Appendices 569 @section Appendices 570 @table @asis 571 @item A 572 Example Flows (ASCII diagrams, DNS and GNS variants). 573 574 @item B 575 Test Vectors (keys, secrets, tokens). 576 @end table 577 578 @subsection Appendix A: Example Flows 579 580 This appendix provides ASCII diagrams illustrating key YouAuth flows, based on the shopping example where Sam (samwisegamgee.me) authenticates to southfarthing.com. Diagrams cover the normative DNS variant and an informative GNS hybrid. 581 582 @subsubsection DNS-Based Flow 583 584 @verbatim 585 +---------------+ +----------------+ +-------------------+ 586 | Sam's Browser | | southfarthing | | samwisegamgee.me | 587 +---------------+ +----------------+ +-------------------+ 588 | | | 589 | --- Login Request ----> | | 590 | | --- DNS Resolve --------> | 591 | | <--- IP/HTTPS ----------- | 592 | | | 593 | <--- Redirect (302) --- | | 594 | --- GET /authorize ---> | | 595 | | --- Internal Consent ---> | 596 | | <--- Consent Granted ---- | 597 | | | 598 | <--- Redirect (302) --- | | 599 | w/ pub_key, salt | | 600 | --- POST /token ------> | | 601 | | --- Cache Lookup/Delete -> | 602 | <--- Encrypted CAT ---- | | 603 | | | 604 v v v 605 @end verbatim 606 607 Description: Browser redirects to identity host via DNS-resolved HTTPS. Consent handled internally; token exchanged with cache deletion for one-time use. 608 609 @subsubsection GNS Hybrid Flow (Informative) 610 611 @verbatim 612 +---------------+ +----------------+ +-------------------+ 613 | Sam's Browser | | southfarthing | | samwisegamgee.me | 614 +---------------+ +----------------+ +-------------------+ 615 | | | 616 | --- Login Request ----> | | 617 | | --- GNS Resolve (DHT) --> | 618 | | <--- Locator/Records ---- | 619 | | --- Fallback DNS? ------> | 620 | | <--- IP/HTTPS ----------- | 621 | | | 622 | <--- Redirect (302) --- | | 623 | --- GET /authorize ---> | | 624 | | --- Fetch YOUAUTH_PUBLIC_KEY from GNS --> | 625 | | <--- JWK Pub Key -------- | 626 | | --- Consent (Proxy?) ---> | 627 | | <--- Granted ------------ | 628 | | | 629 | <--- Redirect (302) --- | | 630 | w/ pub_key, salt | | 631 | --- POST /token ------> | | 632 | | --- Cache Lookup/Delete -> | 633 | <--- Encrypted CAT ---- | | 634 | | | 635 v v v 636 @end verbatim 637 638 Description: Attempts GNS first for privacy; falls back to DNS. Retrieves public key from GNS records for verification. 639 640 @subsection Appendix B: Test Vectors 641 642 This appendix provides sample test vectors for cryptographic operations. These are generated for illustration; implementations MUST NOT hardcode them but use secure randomness. Values are in hexadecimal. 643 644 @subsubsection Key Exchange and Derivation 645 646 TODO: This has not yet been verified. 647 648 @itemize @bullet 649 @item Host Private Key (d): c3d058229170f520ed2b8ac0f1ad7b3e4f7d59119a5b66a5953042653d7c5f5d0028e27dc8ea7a90de0642435f8fd41e 650 @item Host Public Key (x,y): 499e6b2db750bd8fe25e08722a8dc30467fb4f0aa9a20afd1373c18e575298968219bf5af1dc0925655658ac0a5344ce20a8e13fc99726f8e67fba2a4989ee07cf983831e9e0369db811864e8ea4b35d6dde10f46a31affd790dde7c54e079db04d 651 @item Client Private Key (d): bb0280bbdc4da8dee2dccc70545c752efa6d1caec995c615e7cc947051cf9bae3ff8cf38ff5916bc21f265d306f62de7 652 @item Client Public Key (x,y): e1743ebd476292f6c774036cc8cfa3248aefac8bef7d0d631a0a1b830f34e24a1f89b9da2acb6017622522fa9a71aa4d959800c643f0d88451ba9d2a53ee759f71f7f3d0b6a8bd298107f1b58acacb1c0467d609d15865c3c6bc06885c01bc0d 653 @item Raw Shared Secret (x): ff7ab0a74c61d1a132a6700a2578f74e612f90fa0c1eab7b5bc2fad9fcd8828efd457b92d1d3cbe9b20cfcd3fa559517 654 @item Salt: 5c6de4afc6e9371feab049e12ffa40e7 655 @item Derived Shared Secret (16 bytes): 5e481af2aca2706b213e1754d72aba57 656 @item Secret Digest (SHA256): 4600f0aa2be3b347e7e02db62526fc9b4bd93744840d5603614a42ff7302dcef 657 @end itemize 658 659 @subsubsection Encryption (Placeholder) 660 661 TODO: This has not yet been verified. 662 663 @itemize @bullet 664 @item Sample CAT Plaintext: 6f1614813f86bdfaca28dfd88a9bde41ef3c6fddce7df5b1d9fc0c8cc4d1bdb4 665 @item IV: c289331e898a15c5be600cf42f71d7d0 666 @item Placeholder Encrypted CAT (demo hash): 393a22541b98ed91202b6a2450393de2574c89078257737f47d0528b3b3df99 667 @end itemize 668 669 Note: Actual AES-128-CBC encryption would use the derived key; this placeholder uses a hash for illustration. Implementations should verify with real crypto libraries.