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

CSAPI Service should include more flexible config for its write database #273

Open
earocorn opened this issue Oct 8, 2024 · 0 comments
Open

Comments

@earocorn
Copy link

earocorn commented Oct 8, 2024

Current State

Currently, the CSAPI Service allows you to specify a filtered view of the federated database to read from and a single database module to write to. If no filtered view is specified, the entire federated database is exposed. If no database module is specified to write to, the entire system state database is exposed for writing.

Issues

  • If you want to send POST requests to a system that is not part of the system state database/specified database, but is exposed in the database view, the data will not update, but still send a HTTP 200 response code. In theory, this could be fine as you may only want to write data to one database, but allow reads for other systems. However, if multiple systems are spread across multiple databases, this could cause issues.
  • If database module id OR filtered view are unspecified, the entire system is exposed. This should show some warning in the admin UI to be cautious of unsafe rules.

doStart() of ConSysApiService

// get handle to obs system database
        if (!Strings.isNullOrEmpty(config.databaseID))
        {
            writeDb = (IObsSystemDatabase)getParentHub().getModuleRegistry()
                .getModuleById(config.databaseID);
            if (writeDb != null && !writeDb.isOpen())
                writeDb = null;
        }
        else
            writeDb = getParentHub().getSystemDriverRegistry().getSystemStateDatabase();
        
        // get existing or create new FilteredView from config
        if (config.exposedResources != null)
        {
            if (writeDb != null)
            {
                var obsFilter = config.exposedResources.getObsFilter();
                var cmdFilter = config.exposedResources.getCommandFilter();
                readDb = new FilteredFederatedDatabase(
                    getParentHub().getDatabaseRegistry(),
                    obsFilter, cmdFilter, new ProcedureFilter.Builder().build(), writeDb.getDatabaseNum());
            }
            else
                readDb = config.exposedResources.getFilteredView(getParentHub());
        }
        else
            readDb = getParentHub().getDatabaseRegistry().getFederatedDatabase();

Solution

  • ConSysApiService should allow a more flexible configuration for the databases it's allowed to write to.
  • The filtered view could also have a more flexible configuration to allow filtered views for multiple databases.
  • Warning messages in Admin UI when no read or write databases are specified.
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