Skip to content

Commit 281d0ab

Browse files
Bearer auth
1 parent e843a67 commit 281d0ab

File tree

1 file changed

+52
-10
lines changed

1 file changed

+52
-10
lines changed

modules/ROOT/pages/authentication-authorization.adoc

+52-10
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,25 @@
11
= Authorize requests
22

3-
Unless authentication is disabled on the server, all HTTP requests must be authorized using the login credentials of a valid user.
3+
Unless authentication is disabled on the server, all requests must be authorized using the login credentials of a valid user.
44

55
Request are authorized through an `Authorization` header.
6-
The header value encoding follows the standard format for `Basic` authentication (RFC 7617), which is as follows:
6+
Both _basic_ and _bearer_ authentication are supported.
7+
8+
[NOTE]
9+
If authentication is disabled on the server, requests can be sent without an `Authorization` header.
10+
11+
12+
== Basic authentication
13+
14+
The header format for basic authentication follows the standard format (RFC 7617):
715

816
----
917
Authorization: Basic <base64(username:password)>
1018
----
1119

12-
For example, to authenticate as user `neo4j` with password `verysecret`, first join them with a colon:
20+
.Basic authentication
21+
=====
22+
To authenticate as user `neo4j` with password `verysecret`, first join them with a colon:
1323
1424
----
1525
neo4j:verysecret
@@ -37,14 +47,46 @@ To obtain the final header, prepend `Basic` to the base64-encoding of the creden
3747
----
3848
Authorization: Basic bmVvNGo6dmVyeXNlY3JldA==
3949
----
50+
=====
4051

41-
[NOTE]
42-
--
43-
If authentication is disabled on the server, HTTP API requests can be sent without an `Authorization` header.
44-
--
4552

53+
== Bearer authentication
54+
55+
The header format to authenticate with a bearer token is:
56+
57+
----
58+
Authorization: Bearer <base64(token)>
59+
----
60+
61+
.Bearer authentication
62+
=====
63+
To authenticate with the token `xbhkjnlvianztghqwawxqfe`, first base64-encode it:
64+
65+
----
66+
eGJoa2pubHZpYW56dGdocXdhd3hxZmUK
67+
----
68+
69+
.How to base64-encode a string
70+
[%collapsible]
71+
====
72+
To base64-encode a string on a Linux or Mac machine, use the built-in `base64` command:
73+
74+
[source, bash]
75+
----
76+
echo -n "xbhkjnlvianztghqwawxqfe" | base64
77+
----
78+
====
79+
80+
To obtain the final header, prepend `Bearer` to the base64-encoding of the credential:
81+
82+
----
83+
Authorization: Bearer eGJoa2pubHZpYW56dGdocXdhd3hxZmUK
84+
----
85+
=====
86+
87+
== Errors
4688

47-
== Missing authorization
89+
=== Missing authorization
4890

4991
If an `Authorization` header is not supplied (and authentication is not disabled), the server replies with status `401 Forbidden` and an error.
5092

@@ -80,7 +122,7 @@ Content-Type: application/json;charset=utf-8
80122
====
81123

82124

83-
== Incorrect authentication
125+
=== Incorrect authentication
84126

85127
If an incorrect username or password is provided, or if they fail to be properly base64-encoded, the server replies with status `401 Forbidden` and an error.
86128

@@ -117,7 +159,7 @@ Content-Type: application/json;charset=utf-8
117159
====
118160

119161

120-
== Invalid authentication
162+
=== Invalid authentication
121163

122164
If the content of the `Authorization` header fails to be properly base64-encoded, the server replies with status `401 Forbidden` and an error.
123165

0 commit comments

Comments
 (0)