Discussion:
Plugin Question
Paul Cuzner
2018-09-29 01:05:11 UTC
Permalink
Hi,

I have a REST API that's running on localhost (flask app) that I'd like to
access with a cockpit plugin. I've done a few initial tests but I'm finding
it difficult to navigate the CORS and Content-Security-Policy - so before I
invest any more time in this, I thought I'd ask the dumb question first.

Is this goal achievable? Can a cockpit plugin access a REST API running on
the same host - if so, could someone provide some guidance, or point me at
some docs?

I'm testing on Fedora, but the longer term goal is to use RHEL.

Any help appreciated!

Paul C
Stef Walter
2018-09-29 09:40:37 UTC
Permalink
Post by Paul Cuzner
Hi,
I have a REST API that's running on localhost (flask app) that I'd like
to access with a cockpit plugin. I've done a few initial tests but I'm
finding it difficult to navigate the CORS and Content-Security-Policy -
so before I invest any more time in this, I thought I'd ask the dumb
question first.>
Is this goal achievable? Can a cockpit plugin access a REST API running
on the same host - if so, could someone provide some guidance, or point
me at some docs?
Yes, but access it with cockpit.http() to access HTTP/REST services on
the local machine via cockpit-bridge ... rather than directly accessing
them from the browser. Does that work? Do you control the javascript
code that makes the request?

https://cockpit-project.org/guide/latest/cockpit-http.html

If not, we may need to help make a shim around XMLHttpRequest (to wrap
cockpit.http() ... similar to how we've made a shim around WebSocket (to
wrap cockpit.channel() [1]).

Stef

[1]
https://github.com/cockpit-project/cockpit/blob/master/examples/gtk-broadway/gtk.html#L14
Post by Paul Cuzner
I'm testing on Fedora, but the longer term goal is to use RHEL.
Any help appreciated!
Paul C
_______________________________________________
Fedora Code of Conduct: https://getfedora.org/code-of-conduct.html
List Guidelines: https://fedoraproject.org/wiki/Mailing_list_guidelines
--
Stef Walter
Platform Engineering
Red Hat
_______________________________________________
cockpit-devel mailing list -- cockpit-***@lists.fedorahosted.org
To unsubscribe send an email to cockpit-devel-***@lists.fedorahosted.org
Fedora Code of Conduct: https://getfedora.org/code-of-conduct.html
List Guidelines: https://fedoraproject.org/wiki/Mailing_list_guidelines
List Archives: https://lists.fedorahosted.org/archives/list/cockpit-***@li
Rohan Joseph
2018-09-30 14:33:23 UTC
Permalink
Post by Stef Walter
Yes, but access it with cockpit.http() to access HTTP/REST services on
the local machine via cockpit-bridge
+1

We've done this with our new gluster plugin:
https://github.com/gluster/cockpit-gluster

You can see the usage in this file:
https://github.com/gluster/cockpit-gluster/blob/master/src/components/GlusterManagement.js
Post by Stef Walter
Post by Paul Cuzner
Hi,
I have a REST API that's running on localhost (flask app) that I'd like
to access with a cockpit plugin. I've done a few initial tests but I'm
finding it difficult to navigate the CORS and Content-Security-Policy -
so before I invest any more time in this, I thought I'd ask the dumb
question first.>
Is this goal achievable? Can a cockpit plugin access a REST API running
on the same host - if so, could someone provide some guidance, or point
me at some docs?
Yes, but access it with cockpit.http() to access HTTP/REST services on
the local machine via cockpit-bridge ... rather than directly accessing
them from the browser. Does that work? Do you control the javascript
code that makes the request?
https://cockpit-project.org/guide/latest/cockpit-http.html
If not, we may need to help make a shim around XMLHttpRequest (to wrap
cockpit.http() ... similar to how we've made a shim around WebSocket (to
wrap cockpit.channel() [1]).
Stef
[1]
https://github.com/cockpit-project/cockpit/blob/master/
examples/gtk-broadway/gtk.html#L14
Post by Paul Cuzner
I'm testing on Fedora, but the longer term goal is to use RHEL.
Any help appreciated!
Paul C
_______________________________________________
fedorahosted.org
Post by Paul Cuzner
Fedora Code of Conduct: https://getfedora.org/code-of-conduct.html
List Guidelines: https://fedoraproject.org/wiki/Mailing_list_guidelines
List Archives: https://lists.fedorahosted.org/archives/list/cockpit-
--
Stef Walter
Platform Engineering
Red Hat
_______________________________________________
Fedora Code of Conduct: https://getfedora.org/code-of-conduct.html
List Guidelines: https://fedoraproject.org/wiki/Mailing_list_guidelines
List Archives: https://lists.fedorahosted.org/archives/list/cockpit-
Paul Cuzner
2018-10-01 02:48:26 UTC
Permalink
Thanks guys!
Post by Rohan Joseph
Post by Stef Walter
Yes, but access it with cockpit.http() to access HTTP/REST services on
the local machine via cockpit-bridge
+1
https://github.com/gluster/cockpit-gluster
https://github.com/gluster/cockpit-gluster/blob/master/src/components/GlusterManagement.js
Post by Stef Walter
Post by Paul Cuzner
Hi,
I have a REST API that's running on localhost (flask app) that I'd like
to access with a cockpit plugin. I've done a few initial tests but I'm
finding it difficult to navigate the CORS and Content-Security-Policy -
so before I invest any more time in this, I thought I'd ask the dumb
question first.>
Is this goal achievable? Can a cockpit plugin access a REST API running
on the same host - if so, could someone provide some guidance, or point
me at some docs?
Yes, but access it with cockpit.http() to access HTTP/REST services on
the local machine via cockpit-bridge ... rather than directly accessing
them from the browser. Does that work? Do you control the javascript
code that makes the request?
https://cockpit-project.org/guide/latest/cockpit-http.html
If not, we may need to help make a shim around XMLHttpRequest (to wrap
cockpit.http() ... similar to how we've made a shim around WebSocket (to
wrap cockpit.channel() [1]).
Stef
[1]
https://github.com/cockpit-project/cockpit/blob/master/examples/gtk-broadway/gtk.html#L14
Post by Paul Cuzner
I'm testing on Fedora, but the longer term goal is to use RHEL.
Any help appreciated!
Paul C
_______________________________________________
To unsubscribe send an email to
Fedora Code of Conduct: https://getfedora.org/code-of-conduct.html
List Guidelines: https://fedoraproject.org/wiki/Mailing_list_guidelines
--
Stef Walter
Platform Engineering
Red Hat
_______________________________________________
To unsubscribe send an email to
Fedora Code of Conduct: https://getfedora.org/code-of-conduct.html
List Guidelines: https://fedoraproject.org/wiki/Mailing_list_guidelines
Loading...