files/en-us/web/uri/reference/authority/index.md
The authority of a URI is the section that comes after the scheme and before the path. It may have up to three parts: user information, host, and port.
host
host:port
user@host
user@host:port
host
port {{optional_inline}}
user {{optional_inline}}
: The user is optional and is used for authentication purposes. It is not commonly used in web URIs.
[!WARNING] Providing user information directly in HTTP URLs is not recommended, as it can expose sensitive information. Use other methods like HTTP authentication or session cookies instead. Sometimes, phishing sites trick users by displaying misleading URLs whose "user" part appears as if it's a domain name, known as semantic URL attack.
Consider the following URL:
http://www.example.com:80/path/to/myfile.html?key1=value1&key2=value2#SomewhereInTheDocument
The authority in this case is www.example.com:80, comprised of the host name (specifically a domain name) and a port.
www.example.com is the host name of the URI, indicating which Web server is being requested. Here, we use a domain name, but it's also possible to use an {{Glossary("IP address")}} of the host.
Because IP addresses are less convenient and harder to remember, it's more common to use a domain name unless the server doesn't have one registered.
:80 is the port of the URL, indicating the technical "gate" used to access the resources on the web server. It is usually omitted if the web server uses the standard ports of the HTTP protocol (80 for HTTP and 443 for HTTPS) to grant access to its resources. Otherwise, it is mandatory.
https://developer.mozilla.org
developer.mozilla.org. The port is not specified but will default to 443 if accessed via https:.http://localhost:8080
localhost and the port is 8080. localhost is a special host name that the browser resolves to the local address 127.0.0.1.postgresql://postgres:admin123@db:5432
db, and the port is 5432. It also specifies a user postgres and its password admin123. This can be used to connect to a PostgreSQL database.https://cnn.example.com&[email protected]
10.0.0.1, and the cnn.example.com&story=breaking_news part is the "user".{{Specifications}}