I'm trying to build an HTTP API (using R/plumber). One feature I'd like is for the user to make a GET request and then return some data depending on the factors they'd like data for. However, querying the data requires me to build an odbc database connection and then submit the query, and return the results as a JSON object.
At the moment I have a function like:
#* @param username
#* @param password
#* @param factors
#* @get /data
function(username, password, factors){
# build database connection
# query data
# return results
}
This would be using HTTPS, but I'm still worried this is unsafe (although the API would only be hosted on internal servers, so I think in general security is less of an issue). Is there a better way to do this? I don't have a better way to authenticate users at the moment - I need to pass in the user/password combination to build a database connection using a different R function and then I can access data from our database. I might be able to get a system database account and just store the username/password from a config file and then get the user's ID from a system environment variable, but this would require navigating my companies bureaucracy :(
Is what I'm doing OK or would you recommend going a different route?