On 3/20/23 10:19, Paul Ryder wrote:
I've manage to configure my security.json so that a read only user can access 
the admin panel but not update any docs or create/edit collections... 
security.json is as below

<snip>

       {
         "name":"all",
         "role":[
           "admin",
           "readonly"],
         "index":12}

That section is most likely the problem. You gave the readonly role the "all" permission. Which means if the permission is not explicitly listed in the prior rules, the readonly role will be allowed to do it. Remove readonly from the all permission. That might fix it. I don't think there is an explicit permission that covers enabling or disabling replication, so it would fall under "all".

Because you have the "all" permission at the end, you do not need any of the other permissions that have been assigned only to admin, but those permissions are not hurting anything with the rest of the config the way it is. The "read" permission DOES need both roles. If you remove admin from that permission, then the admin user would not be able to do queries.

If you are running in Cloud mode or have a distributed index in standalone mode, disabling forwardCredentials as you have will most likely break queries. Someone with more authentication expertise will need to confirm or refute that statement.

It took me a few hours to fully grasp how the rule-based authorization in Solr works. Once it clicked, I could see why it was designed to work that way, which I admit is very non-intuitive. It's enormously flexible.

------------------

Below is a security.json that I constructed entirely in the webui after uploading the sample authentication and authorization security.json found in the reference guide to zookeeper. It features three users - read, update, and admin.

The read role has most of the read permissions found in Solr 9.3.0-SNAPSHOT, plus health. I excluded filestore-read and security-read.

The update role only has the "update" permission. Which means that it can send update requests.

The admin role has the "all" permission.

The admin user has all three roles. The update user has read and update. The read user only gets the read role. Due to the way the config is parsed, if you remove the read and update roles from the admin user, it won't work the way I envisioned it.

The read user can obtain a large subset of information from Solr but cannot make changes. The update user can do everything read can do, plus make changes to the index. The admin user has all permissions.

For better security the read role probably needs a few more permissions removed, particularly zk-read so only the admin can look directly into the ZK database. Some experimentation is required.

I have set the coreadmin-edit permission to not allow ANYONE to do it, as my setup is in cloud mode. Using CoreAdmin to make changes in cloud mode is a recipe for disaster. It's probably not a good idea in standalone mode either, but it's FAR less likely to cause BIG problems in standalone mode.

-----------------

{
  "authentication":{
    "class":"solr.BasicAuthPlugin",
    "credentials":{
      "admin":"REDACTED REDACTED",
      "read":"REDACTED REDACTED",
      "update":"REDACTED REDACTED"},
    "":{"v":153}},
  "authorization":{
    "class":"solr.RuleBasedAuthorizationPlugin",
    "permissions":[
      {
        "name":"read",
        "role":["read"],
        "index":1},
      {
        "name":"collection-admin-read",
        "role":["read"],
        "index":2},
      {
        "name":"config-read",
        "role":["read"],
        "index":3},
      {
        "name":"core-admin-read",
        "role":["read"],
        "index":4},
      {
        "name":"package-read",
        "role":["read"],
        "index":5},
      {
        "name":"health",
        "role":["read"],
        "index":6},
      {
        "name":"zk-read",
        "role":["read"],
        "index":7},
      {
        "name":"schema-read",
        "role":["read"],
        "index":8},
      {
        "name":"metrics-read",
        "role":["read"],
        "index":9},
      {
        "name":"core-admin-edit",
        "role":null,
        "index":10},
      {
        "name":"update",
        "role":["update"],
        "index":11},
      {
        "name":"all",
        "role":["admin"],
        "index":12}],
    "user-role":{
      "admin":[
        "admin",
        "read",
        "update"],
      "read":["read"],
      "update":[
        "read",
        "update"]},
    "":{"v":37}}}

Thanks,
Shawn

Reply via email to