Skip to content

Commit d4665b4

Browse files
committed
add docs and working examples
1 parent bb8833c commit d4665b4

File tree

2 files changed

+49
-26
lines changed

2 files changed

+49
-26
lines changed

README.md

Lines changed: 33 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -21,24 +21,19 @@ accordingly.
2121
> Before using the plugin, please be familiar with
2222
> [Solr authentication and authorization](https://solr.apache.org/guide/8_11/authentication-and-authorization-plugins.html).
2323
24-
### Install the plugin
25-
26-
Drop the
24+
To use the plugin, drop the
2725
[release jar](https://github.com/solr-cool/solr-forward-authentication-plugin/releases)
28-
into the library directory of your Solr installation.
26+
into the [library directory of your Solr installation](https://solr.apache.org/guide/8_11/libs.html).
2927

30-
### Configure authentication
28+
### Configure authentication & authorization
3129

32-
```json
33-
{
34-
"authentication": {
35-
"class": "cool.solr.security.ForwardAuthPlugin",
36-
"httpUserHeader": "X-Forwarded-User"
37-
}
38-
}
39-
```
30+
To activate authentication & authorization, place a `security.json`
31+
in your Zookeeper root.
4032

41-
### Configure authorization
33+
To activate forward __authentication__ in Solr, use the
34+
`ForwardAuthPlugin` class as authentication class.
35+
36+
> The `httpUserHeader` is an optional configuration.
4237
4338
```json
4439
{
@@ -59,6 +54,10 @@ into the library directory of your Solr installation.
5954
}
6055
```
6156

57+
For __authorization__, the `DefaultRuleBasedAuthorizationPlugin` extends
58+
the [`RuleBasedAuthorizationPlugin`](https://solr.apache.org/guide/8_11/rule-based-authorization-plugin.html#example-for-rulebasedauthorizationplugin-and-basicauth) by assigning
59+
users without an explicit `user-role` mapping a `defaultRole`.
60+
6261
### Example
6362

6463
The [`examples`](examples/) folder contains a simple Docker Compose ensemble.
@@ -68,10 +67,29 @@ From inside the directory, launch the Solr/Zookeeper ensemble:
6867
$ docker-compose up
6968

7069
# Test connectivity (should return 200 OK)
71-
$ curl -I http://localhost:8983/solr/ping
70+
$ curl -s "http://localhost:8983/api/node/system" | jq .security
71+
{
72+
"tls": false
73+
}
7274

7375
# Activate security
7476
$ docker exec -it solr solr zk cp file:/opt/solr/server/solr/security.json zk:/security.json -z zookeeper:2181
77+
78+
# Test security (should return no data as we are not authorized)
79+
$ curl "http://localhost:8983/api/node/system"
80+
81+
# Fake forward authentication (should return 200)
82+
$ curl -sH "X-Forwarded-User: alice" "http://localhost:8983/api/node/system" \
83+
| jq .security
84+
{
85+
"authenticationPlugin": "cool.solr.security.ForwardAuthPlugin",
86+
"authorizationPlugin": "cool.solr.security.DefaultRuleBasedAuthorizationPlugin",
87+
"username": "alice",
88+
"roles": [
89+
"admin"
90+
],
91+
"tls": false
92+
}
7593
```
7694

7795
## Building the project

examples/docker-compose.yaml

Lines changed: 16 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,19 @@
1-
version: "2.4"
1+
version: "2.4"
22

33
services:
4-
zookeeper:
5-
image: zookeeper:3.6
4+
zookeeper:
5+
image: zookeeper:3.6
6+
container_name: zookeeper
67

7-
solr:
8-
image: solr:8.11.0-slim
9-
depends_on:
10-
- zookeeper
11-
environment:
12-
- ZK_HOST=zookeeper:2181
13-
volumes:
14-
- ./security.json:/opt/solr/server/solr/security.json
8+
solr:
9+
image: solr:8.11.0-slim
10+
container_name: solr
11+
depends_on:
12+
- zookeeper
13+
environment:
14+
- ZK_HOST=zookeeper:2181
15+
ports:
16+
- 8983:8983
17+
volumes:
18+
- ./security.json:/opt/solr/server/solr/security.json
19+
- ../target/solr-forward-authentication-plugin-0-SNAPSHOT.jar:/opt/solr/server/solr-webapp/webapp/WEB-INF/lib/solr-forward-authentication-plugin.jar

0 commit comments

Comments
 (0)