Skip to content

Commit 438ccb1

Browse files
Neo4j 3.5 security
1 parent b0835c3 commit 438ccb1

File tree

7 files changed

+155
-93
lines changed

7 files changed

+155
-93
lines changed

modules/ROOT/pages/security/index.adoc

Lines changed: 155 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -3,32 +3,64 @@
33
[[http-api-security]]
44
= Authentication and authorization
55

6-
Authentication and authorization are enabled by default in Neo4j (refer to xref:4.4-preview@operations-manual:ROOT:authentication-authorization/index.adoc#auth[Operations Manual -> Authentication and authorization]).
7-
With authentication and authorization enabled, requests to the HTTP API must be authorized using the username and password of a valid user.
6+
[WARNING]
7+
====
8+
The functionality described in this section has been deprecated and will be removed in Neo4j 4.0.
9+
====
810

911

10-
[[http-api-missing-authorization]]
11-
== Missing authorization
12+
[[http-api-security-introduction]]
13+
[role=deprecated]
14+
== Introduction
1215

13-
If an `Authorization` header is not supplied, the server will reply with an error.
16+
Authentication and authorization are enabled by default in Neo4j (refer to xref:3.5@operations-manual:ROOT:authentication-authorization/enable/index.adoc[Operations Manual -> Enabling authentication and authorization]).
17+
This means that requests to the HTTP API must be authorized using the username and password of a valid user.
18+
19+
When Neo4j is newly installed, the default user `neo4j` has the default password `neo4j`.
20+
The default password must be changed before access to resources will be permitted.
21+
See xref::security/index.adoc#http-api-changing-the-user-password[Changing the user password] for how to set a new password.
22+
23+
24+
[[http-api-authenticate-to-access-the-server]]
25+
[role=deprecated]
26+
== Authenticate to access the server
27+
28+
Authenticate by sending a username and a password to Neo4j using HTTP Basic Auth.
29+
Requests should include an `Authorization` header with a value of `Basic <payload>`, where `payload` is a base64-encoded string of `username:password`.
1430

1531
_Example request_
1632

17-
* *+POST+* +http://localhost:7474/db/neo4j/tx/commit+
33+
* *+GET+* +http://localhost:7474/user/neo4j+
1834
* *+Accept:+* +application/json;charset=UTF-8+
19-
* *+Content-Type:+* +application/json+
35+
* *+Authorization:+* +Basic bmVvNGo6c2VjcmV0+
36+
37+
_Example response_
38+
39+
* *+200:+* +OK+
40+
* *+Content-Type:+* +application/json;charset=utf-8+
2041

2142
[source, JSON, role="nocopy"]
2243
----
2344
{
24-
"statements": [
25-
{
26-
"statement": "CREATE (n:MyLabel) RETURN n"
27-
}
28-
]
45+
"password_change_required" : false,
46+
"password_change" : "http://localhost:7474/user/neo4j/password",
47+
"username" : "neo4j"
2948
}
3049
----
3150

51+
52+
53+
[[http-api-missing-authorization]]
54+
[role=deprecated]
55+
== Missing authorization
56+
57+
If an `Authorization` header is not supplied, the server will reply with an error.
58+
59+
_Example request_
60+
61+
* *+GET+* +http://localhost:7474/db/data/+
62+
* *+Accept:+* +application/json;charset=UTF-8+
63+
3264
_Example response_
3365

3466
* *+401:+* +Unauthorized+
@@ -52,48 +84,144 @@ If authentication and authorization have been disabled, HTTP API requests can be
5284

5385

5486
[[http-api-incorrect-authentication]]
87+
[role=deprecated]
5588
== Incorrect authentication
5689

5790
If an incorrect username or password is provided, the server replies with an error.
5891

5992
_Example request_
6093

61-
* *+POST+* +http://localhost:7474/db/neo4j/tx/commit+
94+
* *+POST+* +http://localhost:7474/db/data/+
6295
* *+Accept:+* +application/json;charset=UTF-8+
6396
* *+Authorization:+* +Basic bmVvNGo6aW5jb3JyZWN0+
64-
* *+Content-Type:+* +application/json+
97+
98+
_Example response_
99+
100+
* *+401:+* +Unauthorized+
101+
* *+Content-Type:+* +application/json;charset=utf-8+
102+
* *+WWW-Authenticate:+* +Basic realm="Neo4j"+
65103

66104
[source, JSON, role="nocopy"]
67105
----
68106
{
69-
"statements": [
70-
{
71-
"statement": "CREATE (n:MyLabel) RETURN n"
72-
}
73-
]
107+
"errors" : [ {
108+
"code" : "Neo.ClientError.Security.Unauthorized",
109+
"message" : "Invalid username or password."
110+
} ]
74111
}
75112
----
76113

114+
115+
[[http-api-required-password-changes]]
116+
[role=deprecated]
117+
== Required password changes
118+
119+
120+
In some cases, for example the very first time Neo4j is accessed, the user will be required to choose a new password.
121+
The database will signal that a new password is required and deny access.
122+
123+
See xref::security/index.adoc#http-api-changing-the-user-password[Changing the user password] for how to set a new password.
124+
125+
126+
_Example request_
127+
128+
* *+GET+* +http://localhost:7474/db/data/+
129+
* *+Accept:+* +application/json;charset=UTF-8+
130+
* *+Authorization:+* +Basic bmVvNGo6bmVvNGo=+
131+
77132
_Example response_
78133

79-
* *+401:+* +Unauthorized+
134+
* *+403:+* +Forbidden+
80135
* *+Content-Type:+* +application/json;charset=utf-8+
81-
* *+WWW-Authenticate:+* +Basic realm="Neo4j"+
82136

83137
[source, JSON, role="nocopy"]
84138
----
85139
{
140+
"password_change" : "http://localhost:7474/user/neo4j/password",
86141
"errors" : [ {
87-
"code" : "Neo.ClientError.Security.Unauthorized",
88-
"message" : "Invalid username or password."
142+
"code" : "Neo.ClientError.Security.Forbidden",
143+
"message" : "User is required to change their password."
89144
} ]
90145
}
91146
----
92147

93148

94-
[[http-api-auth-failure-rollback]]
95-
== Authentication failure on open transactions
149+
[[http-api-user-status-on-first-access]]
150+
[role=deprecated]
151+
== User status on first access
152+
153+
On first access, and using the default password, the user status will indicate that the users password requires changing.
154+
155+
_Example request_
156+
157+
* *+GET+* +ttp://localhost:7474/user/neo4j+
158+
* *+Accept:+* +application/json;charset=UTF-8+
159+
* *+Authorization:+* +Basic bmVvNGo6bmVvNGo=+
160+
161+
_Example response_
162+
163+
* *+200:+* +OK+
164+
* *+Content-Type:+* +application/json;charset=utf-8+
165+
166+
[source, JSON, role="nocopy"]
167+
----
168+
{
169+
"password_change_required" : true,
170+
"password_change" : "http://localhost:7474/user/neo4j/password",
171+
"username" : "neo4j"
172+
}
173+
----
174+
175+
176+
[[http-api-user-status]]
177+
[role=deprecated]
178+
== User status
179+
180+
Given that you know the current password, you can ask the server for the user status.
181+
182+
_Example request_
183+
184+
* *+GET+* +http://localhost:7474/user/neo4j+
185+
* *+Accept:+* +application/json;charset=UTF-8+
186+
* *+Authorization:+* +Basic bmVvNGo6c2VjcmV0+
187+
188+
_Example response_
189+
190+
* *+200:+* +OK+
191+
* *+Content-Type:+* +application/json;charset=utf-8+
192+
193+
[source, JSON, role="nocopy"]
194+
----
195+
{
196+
"password_change_required" : false,
197+
"password_change" : "http://localhost:7474/user/neo4j/password",
198+
"username" : "neo4j"
199+
}
200+
----
201+
202+
203+
[[http-api-changing-the-user-password]]
204+
[role=deprecated]
205+
== Changing the user password
206+
207+
Given that you know the current password for a user, you can ask the server to change that user's password.
208+
You can choose any password as long as it is different from the current password.
209+
210+
_Example request_
211+
212+
* *+POST+* +http://localhost:7474/user/neo4j/password+
213+
* *+Accept:+* +application/json;charset=UTF-8+
214+
* *+Authorization:+* +Basic bmVvNGo6bmVvNGo=+
215+
* *+Content-Type:+* +application/json;charset=UTF-8+
216+
217+
[source, JSON, role="nocopy"]
218+
----
219+
{
220+
"password" : "secret"
221+
}
222+
----
223+
224+
_Example response_
96225

97-
A `Neo.ClientError.Security.Unauthorized` error will typically imply a transaction rollback.
98-
However, due to the way authentication is processed in the HTTP server, the transaction will remain open.
226+
* *+200:+* +OK+
99227

modules/ROOT/pages/security/tmp/README.adoc

Lines changed: 0 additions & 1 deletion
This file was deleted.

modules/ROOT/pages/security/tmp/authenticate-to-access-the-server.adoc

Lines changed: 0 additions & 13 deletions
This file was deleted.

modules/ROOT/pages/security/tmp/changing-the-user-password.adoc

Lines changed: 0 additions & 14 deletions
This file was deleted.

modules/ROOT/pages/security/tmp/required-password-changes.adoc

Lines changed: 0 additions & 14 deletions
This file was deleted.

modules/ROOT/pages/security/tmp/user-status-on-first-access.adoc

Lines changed: 0 additions & 12 deletions
This file was deleted.

modules/ROOT/pages/security/tmp/user-status.adoc

Lines changed: 0 additions & 12 deletions
This file was deleted.

0 commit comments

Comments
 (0)