Coder Social home page Coder Social logo

on-prem / jidoteki-admin-api Goto Github PK

View Code? Open in Web Editor NEW
4.0 4.0 8.0 1.26 MB

On-Prem Admin Dashboard and REST API

Home Page: https://on-premises.com

License: Other

Makefile 0.35% Shell 0.61% HTML 49.14% PicoLisp 22.33% Common Lisp 3.24% CoffeeScript 24.11% Roff 0.21%
api cloud-native jidoteki on-prem picolisp

jidoteki-admin-api's People

Contributors

aw avatar

Stargazers

 avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar

jidoteki-admin-api's Issues

Missing certs status

The certificate upload occurs as a background task. It should be possible to retrieve the status as well as the log. The API call to api/v1/admin/certs only returns the log at the moment.

API crashes when no log file exists

When making a call to /api/v1/admin/update/log , the API crashes because the file doesn't exist.

A check should ensure the file exists before trying to parse/display it.

Server cannot start when JIDO_API_PORT env var is set

When JIDO_API_PORT environment variable is set, the http server cannot start:

$ JIDO_API_PORT=8888 ./run.l
HTTP listening on port: 8888
[app.l:26] !? (port *Port)
"8888" -- Bad argument

This happens because *JIDO_API_PORT is a string rather than a number, when the environment variable is loaded.

Add endpoint to upload TLS certs

The API should allow an authenticated user to upload their own TLS certs:

  • public certificate
  • private certificate
  • CA root certificate

This can then be merged into a single enterprise.pem file.

Storage options should be optional

If an appliance is built without NFS support, then it shouldn't be available as an option in the API/UI.

There should be a configuration file which defines which storage options are available, so the API/UI can present only those options.

Send HMAC instead of token

To avoid sending the authentication token across the wire, we want to implement a hmac based verification. The token will be a shared secret between the client and API:

  • Choose a suitable HMAC hashing algorithm (sha1, sha256..)
  • Concatenate the HTTP Method, URL, and token to generate the hash
  • Validate the hash based on the request method, URL and token
  • Remove simple token-based authentication
  • Ensure old authentication scheme still works, to allow backwards compatibility with older clients

Admin UI authentication prevents short tokens

Upon login, the Admin UI requires the auth token to be between 8 and 64 characters, but the Admin API doesn't have this restriction when setting/changing the token.

The best fix is to modify the API to only allow tokens between 8 and 64, but this breaks backwards compatibility. It would also lock-out anyone who's already using a shorter token with the API.

The proper fix is to not perform validation of the auth token's length (in the UI)... or to allow any non-zero absolute value.

Certificate validation is bypassed on missing key

Certificate validation will return an error message (http-msg 400) if no public/private key is sent, but will continue processing and still end up calling (certs-update), because (http-msg 400) isn't final.

Luckily the backend scripts in Jidoteki Admin have safeguards and will return 1 (and fail) if there's no public/private key file, but this should still be corrected.

The bug can be found in the code here. It's a bit subtle, but essentially on L50 after calling (http-msg 400), the next condition (if Private.. will be called. Doh. Not what we expected.. ๐Ÿค• ๐ŸŒด

API calls dont return a body

The following API calls should return a body:

  • POST /api/v1/admin/update
  • POST /api/v1/admin/settings

.. at least to know the request is being processed.

Add services toggle endpoint

The ability to toggle a service on/off via the API would be beneficial in many situations.

An endpoint POST /services for updating the toggle status of designated system services.

This feature should provide the option to enable/disable designated system services, which are specific to the appliance (generic in the API). The settings should be stored in services.json as well as flag files on the system.

Update API documentation

The API documentation should provide more detailed information on usage, parameters and responses.

Implement TLS client certificates

To ensure only specific clients can use the API, we want to implement client/server certificates. This should be the default, but will be optional in the event the clients are always trusted (ex: private LAN).

These changes are specific to stunnel and its default config (verify = 3 ?):

  • Optionally load stunnel-strict.conf
  • Add self-signed server root CA certificate
  • Validate the client certificate using the root CA certificate
  • Reject requests from invalid clients

Better progress when an update runs

Currently the GET /api/v1/admin/update endpoint responds with a qualitative status, success, failed, running. Is it possible to get a percentage progress based on the packages or steps that are contained in the update package?

Port for 32-bit OS

The current version of the API will only run on a 64-bit OS because it requires PicoLisp 64-bit and performs a few (native) calls.

Some changes are necessary to let it run on a 32-bit OS which doesn't support (native):

  • Replace all (json~) calls with a conditional (symbols 'json)
  • Use external json executable or internal @lib/json.l to parse/create a JSON string
  • Adjust tests

HMAC auth bypassed when no token is set

When no API token is set (missing api.token), the HMAC authentication can be bypassed by generating an SHA256 HMAC with an empty string.

The API should always validate whether the api.token exists, and return NIL if it doesn't.

User friendly message for status in GET /update endpoint

The GET /update status endpoint returns a JSON response containing status and log. Parsing the log for a human friendly message is not ideal and error prone.

I propose adding a message property in the JSON response that contains a descriptive message. This is important when a failed status is received. There are several cases where an update would fail such as already up to date, failed to decrypt update package, incorrect checksum of update package, etc. Each case should produce a unique error message to indicate the cause of failure.

Alternatively a code, statusCode or errorCode property could be added which would indicate a failure reason. The consumer of the API can write their own messages from the status code.

In either case, responding to an upgrade failure will become easier.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.