Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Auth Snaplet users.json format change #214

Open
imalsogreg opened this issue Jan 11, 2020 · 1 comment
Open

Auth Snaplet users.json format change #214

imalsogreg opened this issue Jan 11, 2020 · 1 comment

Comments

@imalsogreg
Copy link
Contributor

imalsogreg commented Jan 11, 2020

At some point in the last several years, the format for users.json changed, specifically the uidCache field. The one in use by a deployment of https://github.com/imalsogreg/reffit several years old was encoded as:

{ uidCache:
  [
    [ 999,
      {
        "last_ip": null,
        "roles": [],
        "current_ip": "127.0.0.1",
        "activated_at": null,
        "reset_requested_at": null,
        "uid": "999",
         ...
        "login": "Interfacelea",
        "reset_token": null
      }
    ],
    ...
  ],
  ...
}

(id and info tuples were in a list of length-2 lists, not key-value entries in a map)

When I bumped snap to the most recent version, parsing failed because the new format is expected to be key-value pairs in a map:

{ uidCache:
  { "999":
    {
      "last_ip": null,
      "roles": [],
      "current_ip": "127.0.0.1",
      "activated_at": null,
      "reset_requested_at": null,
      "uid": "999",
       ...
      "login": "Interfacelea",
      "reset_token": null
    }
    ...
  },
  ...
}

Apologies for vagueness about the dates - I'd need to do some research to get more details.

If anyone else runs into this, the following jq call can do the migration:

jq '.uidCache = ([.uidCache[] | { "key": .[0], "value": .[1] }] | from_entries)' users.json
@imalsogreg
Copy link
Contributor Author

We can fix this simply by adding another parser in the json-file auth backend.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant