RFC 4282:The Network Access Identifier
RFC-Ref

2. NAI Definition

2.1. Formal Syntax


   The grammar for the NAI is given below, described in Augmented
   Backus-Naur Form (ABNF) as documented in [RFC4234].  The grammar for
   the username is based on [RFC0821], and the grammar for the realm is
   an updated version of [RFC1035].

   nai         =  username
   nai         =/ "@" realm
   nai         =/ username "@" realm

   username    =  dot-string
   dot-string  =  string
   dot-string  =/ dot-string "." string
   string      =  char
   string      =/ string char
   char        =  c
   char        =/ "\" x

   c           =  %x21    ; '!'              allowed
                          ; '"'              not allowed
   c           =/ %x23    ; '#'              allowed
   c           =/ %x24    ; '$'              allowed
   c           =/ %x25    ; '%'              allowed
   c           =/ %x26    ; '&'              allowed
   c           =/ %x27    ; '''              allowed
                          ; '(', ')'         not allowed
   c           =/ %x2A    ; '*'              allowed
   c           =/ %x2B    ; '+'              allowed
                          ; ','              not allowed
   c           =/ %x2D    ; '-'              allowed
                          ; '.'              not allowed
   c           =/ %x2F    ; '/'              allowed
   c           =/ %x30-39 ; '0'-'9'          allowed
                          ; ';', ':', '<'    not allowed
   c           =/ %x3D    ; '='              allowed
                          ; '>'              not allowed
   c           =/ %x3F    ; '?'              allowed
                          ; '@'              not allowed
   c           =/ %x41-5a ; 'A'-'Z'          allowed
                          ; '[','\',']'    not allowed
   c           =/ %x5E    ; '^'              allowed
   c           =/ %x5F    ; '_'              allowed
   c           =/ %x60    ; '`'              allowed
   c           =/ %x61-7A ; 'a'-'z'          allowed
   c           =/ %x7B    ; '{'              allowed
   c           =/ %x7C    ; '|'              allowed
   c           =/ %x7D    ; '}'              allowed
   c           =/ %x7E    ; '~'              allowed
                          ; DEL              not allowed
   c           =/ %x80-FF ; UTF-8-Octet      allowed (not in RFC 2486(-> 4282prop))
                          ; Where UTF-8-octet is any octet in the
                          ; multi-octet UTF-8 representation of a
                          ; unicode codepoint above %x7F.
                          ; Note that c must also satisfy rules in
                          ; Section 2.4, including, for instance,
                          ; checking that no prohibited output is
                          ; used (see also Section 2.3 of
                          ; [RFC4013]).
   x           =  %x00-FF ; all 128 ASCII characters, no exception;
                          ; as well as all UTF-8-octets as defined
                          ; above (this was not allowed in
                          ; RFC 2486(-> 4282prop)).  Note that x must nevertheless
                          ; again satisfy the Section 2.4 rules.

   realm       =  1*( label "." ) label
   label       =  let-dig *(ldh-str)

   ldh-str     =  *( alpha / digit / "-" ) let-dig
   let-dig     =  alpha / digit
   alpha       =  %x41-5A  ; 'A'-'Z'
   alpha       =/ %x61-7A  ; 'a'-'z'
   digit       =  %x30-39  ; '0'-'9'


2.2. NAI Length Considerations


   Devices handling NAIs MUST support an NAI length of at least 72
   octets.  Support for an NAI length of 253 octets is RECOMMENDED.
   However, the following implementation issues should be considered:

   o  NAIs are often transported in the User-Name attribute of the
      Remote Authentication Dial-In User Service (RADIUS) protocol.
      Unfortunately, RFC 2865draft [RFC2865], Section 5.1, states that "the
      ability to handle at least 63 octets is recommended."  As a
      result, it may not be possible to transfer NAIs beyond 63 octets
      through all devices.  In addition, since only a single User-Name
      attribute may be included in a RADIUS message and the maximum
      attribute length is 253 octets; RADIUS is unable to support NAI
      lengths beyond 253 octets.

   o  NAIs can also be transported in the User-Name attribute of
      Diameter [RFC3588], which supports content lengths up to 2^24 - 9
      octets.  As a result, NAIs processed only by Diameter nodes can be
      very long.  Unfortunately, an NAI transported over Diameter may
      eventually be translated to RADIUS, in which case the above
      limitations apply.


2.3. Support for Username Privacy


   Interpretation of the username part of the NAI depends on the realm
   in question.  Therefore, the "username" part SHOULD be treated as
   opaque data when processed by nodes that are not a part of the
   authoritative domain (in the sense of Section 4) for that realm.

   In some situations, NAIs are used together with a separate
   authentication method that can transfer the username part in a more
   secure manner to increase privacy.  In this case, NAIs MAY be
   provided in an abbreviated form by omitting the username part.
   Omitting the username part is RECOMMENDED over using a fixed username
   part, such as "anonymous", since it provides an unambiguous way to
   determine whether the username is intended to uniquely identify a
   single user.

   For roaming purposes, it is typically necessary to locate the
   appropriate backend authentication server for the given NAI before
   the authentication conversation can proceed.  As a result, the realm

   portion is typically required in order for the authentication
   exchange to be routed to the appropriate server.


2.4. International Character Sets


   This specification allows both international usernames and realms.
   International usernames are based on the use of Unicode characters,
   encoded as UTF-8 and processed with a certain algorithm to ensure a
   canonical representation.  Internationalization of the realm portion
   of the NAI is based on "Internationalizing Domain Names in
   Applications (IDNA)" [RFC3490].

   In order to ensure a canonical representation, characters of the
   username portion in an NAI MUST fulfill the ABNF in this
   specification as well as the requirements specified in [RFC4013].
   These requirements consist of the following:

   o  Mapping requirements, as specified in Section 2.1 of [RFC4013].
      Mapping consists of mapping certain characters to others (such as
      SPACE) in order to increase the likelihood of correctly performed
      comparisons.

   o  Normalization requirements, as specified in Section 2.2 of
      [RFC4013], are also designed to assist in comparisons.

   o  Prohibited output.  Certain characters are not permitted in
      correctly formed strings that follow Section 2.3 of [RFC4013].
      Ensuring that NAIs conform to their ABNF is not sufficient; it is
      also necessary to ensure that they do not contain prohibited
      output.

   o  Bidirectional characters are handled as specified in Section 2.4
      of [RFC4013].

   o  Unassigned code points are specified in Section 2.5 of [RFC4013].
      The use of unassigned code points is prohibited.

   The mapping, normalization, and bidirectional character processing
   MUST be performed by end systems that take international text as
   input.  In a network access setting, such systems are typically the
   client and the Authentication, Authorization, and Accounting (AAA)
   server.  NAIs are sent over the wire in their canonical form, and
   tasks such as normalization do not typically need to be performed by
   nodes that just pass NAIs around or receive them from the network.
   End systems MUST also perform checking for prohibited output and
   unassigned code points.  Other systems MAY perform such checks, when
   they know that a particular data item is an NAI.

   The realm name is an "IDN-unaware domain name slot" as defined in
   [RFC3490].  That is, it can contain only ASCII characters.  An
   implementation MAY support Internationalized Domain Names (IDNs)
   using the ToASCII operation; see [RFC3490] for more information.

   The responsibility for the conversion of internationalized domain
   names to ASCII is left for the end systems, such as network access
   clients and AAA servers.  Similarly, we expect domain name
   comparisons, matching, resolution, and AAA routing to be performed on
   the ASCII versions of the internationalized domain names.  This
   provides a canonical representation, ensures that intermediate
   systems such as AAA proxies do not need to perform translations, and
   can be expected to work through systems that are unaware of
   international character sets.


2.5. Compatibility with E-Mail Usernames


   As proposed in this document, the Network Access Identifier is of the
   form user@realm.  Please note that while the user portion of the NAI
   is based on the BNF described in [RFC0821], it has been extended for
   internationalization support as well as for purposes of Section 2.7,
   and is not necessarily compatible with the usernames used in e-mail.
   Note also that the internationalization requirements for NAIs and
   e-mail addresses are different, since the former need to be typed in
   only by the user himself and his own operator, not by others.


2.6. Compatibility with DNS


   The BNF of the realm portion allows the realm to begin with a digit,
   which is not permitted by the BNF described in [RFC1035].  This
   change was made to reflect current practice; although not permitted
   by the BNF described in [RFC1035], Fully Qualified Domain Names
   (FQDNs) such as 3com.com are commonly used and accepted by current
   software.


2.7. Realm Construction


   NAIs are used, among other purposes, for routing AAA transactions to
   the user's home realm.  Usually, the home realm appears in the realm
   portion of the NAI, but in some cases a different realm can be used.
   This may be useful, for instance, when the home realm is reachable
   only via another mediating realm.

   Such usage may prevent interoperability unless the parties involved
   have a mutual agreement that the usage is allowed.  In particular,
   NAIs MUST NOT use a different realm than the home realm unless the
   sender has explicit knowledge that (a) the specified other realm is
   available and (b) the other realm supports such usage.  The sender

   may determine the fulfillment of these conditions through a database,
   dynamic discovery, or other means not specified here.  Note that the
   first condition is affected by roaming, as the availability of the
   other realm may depend on the user's location or the desired
   application.

   The use of the home realm MUST be the default unless otherwise
   configured.

   Where these conditions are fulfilled, an NAI such as

       user@homerealm.example.net

   MAY be represented as in

       homerealm.example.net!user@otherrealm.example.net

   In this case, the part before the (non-escaped) '!'  MUST be a realm
   name as defined in the ABNF in Section 2.1.  This realm name is an
   "IDN-unaware domain name slot", just like the realm name after the
   "@" character; see Section 2.4 for details.  When receiving such an
   NAI, the other realm MUST convert the format back to
   "user@homerealm.example.net" when passing the NAI forward, as well as
   applying appropriate AAA routing for the transaction.

   The conversion process may apply also recursively.  That is, after
   the conversion, the result may still have one or more '!' characters
   in the username.  For instance, the NAI

       other2.example.net!home.example.net!user@other1.example.net

   would first be converted in other1.example.net to

       home.example.net!user@other2.example.net

   and then at other2.example.net finally to

       user@homerealm.example.net

   Note that the syntax described in this section is optional and is not
   a part of the ABNF.  The '!' character may appear in the username
   portion of an NAI for other purposes as well, and in those cases, the
   rules outlined here do not apply; the interpretation of the username
   is up to an agreement between the identified user and the realm given
   after the '@' character.


2.8. Examples


   Examples of valid Network Access Identifiers include the following:

           bob
           joe@example.com
           fred@foo-9.example.com
           jack@3rd.depts.example.com
           fred.smith@example.com
           fred_smith@example.com
           fred$@example.com
           fred=?#$&*+-/^smith@example.com
           nancy@eng.example.net
           eng.example.net!nancy@example.net
           eng%nancy@example.net
           @privatecorp.example.net
           \(user\)@example.net
           alice@xn--tmonesimerkki-bfbb.example.net

   The last example uses an IDN converted into an ASCII representation.

   Examples of invalid Network Access Identifiers include the following:

           fred@example
           fred@example_9.com
           fred@example.net@example.net
           fred.@example.net
           eng:nancy@example.net
           eng;nancy@example.net
           (user)@example.net
           <nancy>@example.net



Google
Web
RFC-Ref