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

Policies not found #24

Closed
sergioinf opened this issue Jan 7, 2025 · 7 comments
Closed

Policies not found #24

sergioinf opened this issue Jan 7, 2025 · 7 comments

Comments

@sergioinf
Copy link
Member

          Hello, as I commented on another issue, I have added the policy manually through the API. Still the error persist and the console shows bad request "400" when loading policies. 

My clarification in the other issue:
"Hello. I have same problem but creating a type page has the button but not in the policies' page where nothing is showing. The error in the console is :
url: 'http://IP_Extended_API/api/policies', bad request 400

accessing that url on browser gives a void message :
{
"message": {}
}

I'm deploying using Minikube. Grafana, the extended API, the Ditto NGINX and Mosquitto are accessible from Internet as I'm deploying on cloud with openstack instance with a floating IP. Grafana OpenTwin plugin is well connected to the Ip addresses of both Ditto NGINX and Extended API. Running API queries such as IP_Ditto_NGINX/api/2/whoami works, inserting and finding a new policy through curl to IP_Ditto_NGINX/api/2/policies/id_policy works. However, in the installation files, it is expected that I find default:basic_policy if I query Ditto NGINX, but it seems it is not their ""error": "policies:policy.notfound",".

I was thinking it could be a problem with mongodb not connected, but as long as I insert and I can find a test policy then it is connected. What could make policies not loading ?

Thank you."

Originally posted by @xxabdelxx in #6 (comment)

@sergioinf
Copy link
Member Author

Hello @xxabdelxx, did you installed opentwins following the helm tutorial?
This problem is usually caused because extended api and mongodb are not connected. Is your Mongodb installation older than OpenTwins installation?. Helm installation should install everything and configure this connection. If you installed OpenTwins with helm and you have this problem let us know.

@gogardas
Copy link

gogardas commented Jan 21, 2025

I have the same problem with Grafana (ver. 9.5.2) and policies. Although I am logged in as admin in Grafana, I am not able to manually add the policy, nor can I see any policy in the OpenTwins App. On the other side, I can see connections and everything else. I have installed everything through Helm.

@sergioinf
Copy link
Member Author

Hi @gogardas, as I commented in this issue #6 (comment), in the actual version of OpenTwins you can not create a policy through Grafana. Policies are an Eclipse Ditto component to give different users access to certain features. Currently, OpenTwins does not have user control far from admin and viewer so having different policies does not help.

The way of creating a new policy is through Eclipse Ditto Nginx (e.g. CURL, Postman, etc) to your Eclipse Ditto Nginx (PUT http://yourDittoNginxurl/api/2/policies/{policyId}).

Our basic policy is:

{
    "policyId": "default:basic_policy",
    "imports": {},
    "entries": {
        "DEFAULT": {
            "subjects": {
                "pre-authenticated:kafkaml-connection": {
                    "type": "Connection to KafkaML"
                },
                "pre-authenticated:hono-connection": {
                    "type": "Connection to Eclipse Hono"
                },
                "nginx:ditto": {
                    "type": "Ditto user authenticated via nginx"
                }
            },
            "resources": {
                "policy:/": {
                    "grant": [
                        "READ",
                        "WRITE"
                    ],
                    "revoke": []
                },
                "thing:/": {
                    "grant": [
                        "READ",
                        "WRITE"
                    ],
                    "revoke": []
                },
                "message:/": {
                    "grant": [
                        "READ",
                        "WRITE"
                    ],
                    "revoke": []
                }
            },
            "importable": "implicit"
        }
    }
}

The other problem is that you can not see the basic policy. Maybe it has not been created properly or maybe something in the get request is failing. Could you provide some screenshots or information about console requests of youyr web browser?
You should have something like this:

Image

@gogardas
Copy link

gogardas commented Jan 22, 2025

Hi @gogardas, as I commented in this issue #6 (comment), in the actual version of OpenTwins you can not create a policy through Grafana. Policies are an Eclipse Ditto component to give different users access to certain features. Currently, OpenTwins does not have user control far from admin and viewer so having different policies does not help.

Hi @sergioinf , thank you for your reply! Yes, I am aware of all the facts that you mentioned. One problem is related to the fact that in Grafana, for some reason, I do not have enough permission to see all Apps content (as, by default, it is created by OpenTwins), nor can I create new twins (because I have no policy to associate to it).

I have no problem creating a policy in the way you described it. But the response containes no message.

@sergioinf
Copy link
Member Author

When installing with helm, did you changed some values or did you installed everything by default?

Maybe MongoDB is not connected properly to Ditto Extended API.
Try making a get request to extended API directly.
GET yourextendedapiurl/api/policies

If the connection is correct, you should get a list with all policies.

@gogardas
Copy link

gogardas commented Jan 22, 2025

It works now! I have reinstalled everything; it was probably some update-related issue!
Thanks!

@sergioinf
Copy link
Member Author

Perfect! So as the problem is already solved I will close the issue.

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

2 participants