summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorChristophe Fergeau <cfergeau@redhat.com>2016-01-15 15:35:52 (GMT)
committerChristophe Fergeau <cfergeau@redhat.com>2016-05-10 07:51:14 (GMT)
commit4f3733294028d9b1f7c7135eb299436509845bb4 (patch)
tree0d0f5f583bf523d7cfab9ff7ed4a0ef2f9df3652
parentc904b1c63a2bf23ec06c6b9719b2d0ec43f19cb1 (diff)
downloadvirt-viewer-master.zip
virt-viewer-master.tar.gz
virt-viewer-master.tar.xz
ovirt: Use sso-token when set in .vv fileHEADmaster
Starting with oVirt 4.0, this replaces the jsessionid field for automatic authentication with oVirt instances for REST communication.
-rw-r--r--man/remote-viewer.pod11
-rw-r--r--src/ovirt-foreign-menu.c25
2 files changed, 31 insertions, 5 deletions
diff --git a/man/remote-viewer.pod b/man/remote-viewer.pod
index 119dd2a..60ea3a6 100644
--- a/man/remote-viewer.pod
+++ b/man/remote-viewer.pod
@@ -309,8 +309,15 @@ GUID of the oVirt virtual machine to connect to.
=item C<jsessionid> (string)
-Value to set the 'jsessionid' cookie to. Setting this authentication cookie to a valid value
-will allow to interact with the oVirt REST API without being asked for credentials.
+Value to set the 'jsessionid' cookie to. With oVirt 3.6, setting this
+authentication cookie to a valid value will allow to interact with the oVirt
+REST API without being asked for credentials.
+
+=item C<sso-token> (string)
+
+Value to set the 'Authorization' header to. With oVirt 4.0 or newer, setting
+this authentication header to a valid value will allow to interact with the
+oVirt REST API without being asked for credentials.
=item C<ca> (string)
diff --git a/src/ovirt-foreign-menu.c b/src/ovirt-foreign-menu.c
index 88c6be5..9b552eb 100644
--- a/src/ovirt-foreign-menu.c
+++ b/src/ovirt-foreign-menu.c
@@ -834,6 +834,7 @@ OvirtForeignMenu *ovirt_foreign_menu_new_from_file(VirtViewerFile *file)
gboolean admin;
char *ca_str = NULL;
char *jsessionid = NULL;
+ char *sso_token = NULL;
char *url = NULL;
char *vm_guid = NULL;
GByteArray *ca = NULL;
@@ -841,15 +842,22 @@ OvirtForeignMenu *ovirt_foreign_menu_new_from_file(VirtViewerFile *file)
url = virt_viewer_file_get_ovirt_host(file);
vm_guid = virt_viewer_file_get_ovirt_vm_guid(file);
jsessionid = virt_viewer_file_get_ovirt_jsessionid(file);
+ sso_token = virt_viewer_file_get_ovirt_sso_token(file);
ca_str = virt_viewer_file_get_ovirt_ca(file);
admin = virt_viewer_file_get_ovirt_admin(file);
- if ((url == NULL) || (vm_guid == NULL) || (jsessionid == NULL)) {
- g_debug("ignoring [ovirt] section content as URL, VM GUID or jsessionid"
+ if ((url == NULL) || (vm_guid == NULL)) {
+ g_debug("ignoring [ovirt] section content as URL, VM GUID"
" are missing from the .vv file");
goto end;
}
+ if ((jsessionid == NULL) && (sso_token == NULL)) {
+ g_debug("ignoring [ovirt] section content as jsessionid and sso-token"
+ " are both missing from the .vv file");
+ goto end;
+ }
+
proxy = ovirt_proxy_new(url);
if (proxy == NULL)
goto end;
@@ -861,9 +869,19 @@ OvirtForeignMenu *ovirt_foreign_menu_new_from_file(VirtViewerFile *file)
g_object_set(G_OBJECT(proxy),
"admin", admin,
- "session-id", jsessionid,
"ca-cert", ca,
NULL);
+ if (jsessionid != NULL) {
+ g_object_set(G_OBJECT(proxy),
+ "session-id", jsessionid,
+ NULL);
+ }
+ if (sso_token != NULL) {
+ g_object_set(G_OBJECT(proxy),
+ "sso-token", sso_token,
+ NULL);
+ }
+
menu = g_object_new(OVIRT_TYPE_FOREIGN_MENU,
"proxy", proxy,
"vm-guid", vm_guid,
@@ -873,6 +891,7 @@ end:
g_free(url);
g_free(vm_guid);
g_free(jsessionid);
+ g_free(sso_token);
g_free(ca_str);
if (ca != NULL) {
g_byte_array_unref(ca);