keeps / dbptk-enterprise

DBPTK Enterprise deployment using docker
https://database-preservation.com
GNU Lesser General Public License v3.0
4 stars 2 forks source link

With cas enabled, how can I POST siard files from command line #21

Closed raulk89 closed 2 years ago

raulk89 commented 2 years ago
# curl -X POST "http://localhost:8080/api/v1/database" -H "accept: text/plain" -H "Content-Type: application/json" -d "database.siard"
{"type":"error","message":"AuthorizationException: Remote exception caused by AuthorizationDeniedException: The user 'guest' does not have all needed permissions"}

I have tried the following, but no luck. curl -u admin:admin ..

Regards Raul

luis100 commented 2 years ago

When CAS is enabled, to use the REST-API for systems integration you need to whitelist the IP where the request comes from.

https://github.com/keeps/dbptk-ui/blob/4d8fea46f90ce274df326cb0dd4111e40ac98acf/src/main/resources/config/dbvtk-viewer.properties#L78

raulk89 commented 2 years ago

Hmm, I am having the following error, this says something that guest user does not have permissions to do so: AuthorizationDeniedException: The user 'guest' does not have all needed permissions

This really is due to this parameter in file "dbptk-enterprise-master/deploys/development/dbptke/config/dbvtk-viewer.properties"..?

#ui.filter.onOff.protectedResourcesWhitelistedIP = 127.0.0.1
#ui.filter.onOff.protectedResourcesWhitelistedIP = 192.168.1.2

And when I execute this REST API request from localhost, then I should uncomment this row: ui.filter.onOff.protectedResourcesWhitelistedIP = 127.0.0.1

Raul

luis100 commented 2 years ago

You need to both enable the whilelisting and add the required IP address to the list. Please note that the name of the list key.

https://github.com/keeps/dbptk-ui/blob/4d8fea46f90ce274df326cb0dd4111e40ac98acf/src/main/resources/config/dbvtk-viewer.properties#L77-L78

So, for localhost you could set:

ui.filter.onOff.protectedResourcesAllowAllIPs=true
ui.filter.onOff.protectedResourcesWhitelistedIP[].ip=127.0.0.1

You can repeat the last property to add multiple IP addresses. You can also add a FQDN/DNS to the list instead of the IP adress, but please note that some cache may be done by Java's DNS resolving and you may have issues if your DNS name changes IP address (you may need to restart the service to force a update).

raulk89 commented 2 years ago

I am using dbptk-enterprise-master (not dbptk-ui), there I do not have those "[]" at the moment. So do I need to add those or not..?

Raul

luis100 commented 2 years ago

dbptk-ui is the underlying base for both dbptk-enterprise and dbptk-desktop, so the code is the same.

To check your version, see: http://localhost:8080/version.json

You should use a configuration compatible with the version you have, which should be 2.5.10.

The version used in dbptk-enteprise demo seems to be outdated. You should check the one at: https://github.com/keeps/dbptk-ui/blob/v2.5.10/src/main/resources/config/dbvtk-viewer.properties

raulk89 commented 2 years ago

I downloaded this from here "https://github.com/keeps/dbptk-enterprise" Version is the same.

{
    "git.build.user.email": "",
    "git.build.host": "fv-az200-3",
    "git.dirty": "true",
    "git.remote.origin.url": "https://github.com/keeps/dbptk-ui",
    "git.closest.tag.name": "v2.5.10",
    "git.commit.id.describe-short": "v2.5.10-3-dirty",
    "git.commit.user.email": "lfaria@keep.pt",
    "git.commit.time": "2021-11-08T13:52:13+0000",
    "git.commit.message.full": "Update issue_template.md",
    "git.build.version": "latest",
    "git.commit.message.short": "Update issue_template.md",
    "git.commit.id.abbrev": "4d8fea4",
    "git.branch": "master",
    "git.build.user.name": "",
    "git.closest.tag.commit.count": "3",
    "git.commit.id.describe": "v2.5.10-3-g4d8fea4-dirty",
    "git.commit.id": "4d8fea46f90ce274df326cb0dd4111e40ac98acf",
    "git.tags": "",
    "git.build.time": "2021-11-08T14:00:37+0000",
    "git.commit.user.name": "Luis Faria"
}

Then my question is what else is outdated there "dbptk-enterprise"..? I actually wasted a lot of time getting this to work in server environment, since instructions are only specified for client computer.

Regards Raul