ovirt: Use sso-token when set in .vv file
Starting with oVirt 4.0, this replaces the jsessionid field for
automatic authentication with oVirt instances for REST communication.
Christophe Fergeau
7 years ago
308 | 308 |
|
309 | 309 |
=item C<jsessionid> (string)
|
310 | 310 |
|
311 | |
Value to set the 'jsessionid' cookie to. Setting this authentication cookie to a valid value
|
312 | |
will allow to interact with the oVirt REST API without being asked for credentials.
|
|
311 |
Value to set the 'jsessionid' cookie to. With oVirt 3.6, setting this
|
|
312 |
authentication cookie to a valid value will allow to interact with the oVirt
|
|
313 |
REST API without being asked for credentials.
|
|
314 |
|
|
315 |
=item C<sso-token> (string)
|
|
316 |
|
|
317 |
Value to set the 'Authorization' header to. With oVirt 4.0 or newer, setting
|
|
318 |
this authentication header to a valid value will allow to interact with the
|
|
319 |
oVirt REST API without being asked for credentials.
|
313 | 320 |
|
314 | 321 |
=item C<ca> (string)
|
315 | 322 |
|
833 | 833 |
gboolean admin;
|
834 | 834 |
char *ca_str = NULL;
|
835 | 835 |
char *jsessionid = NULL;
|
|
836 |
char *sso_token = NULL;
|
836 | 837 |
char *url = NULL;
|
837 | 838 |
char *vm_guid = NULL;
|
838 | 839 |
GByteArray *ca = NULL;
|
|
840 | 841 |
url = virt_viewer_file_get_ovirt_host(file);
|
841 | 842 |
vm_guid = virt_viewer_file_get_ovirt_vm_guid(file);
|
842 | 843 |
jsessionid = virt_viewer_file_get_ovirt_jsessionid(file);
|
|
844 |
sso_token = virt_viewer_file_get_ovirt_sso_token(file);
|
843 | 845 |
ca_str = virt_viewer_file_get_ovirt_ca(file);
|
844 | 846 |
admin = virt_viewer_file_get_ovirt_admin(file);
|
845 | 847 |
|
846 | |
if ((url == NULL) || (vm_guid == NULL) || (jsessionid == NULL)) {
|
847 | |
g_debug("ignoring [ovirt] section content as URL, VM GUID or jsessionid"
|
|
848 |
if ((url == NULL) || (vm_guid == NULL)) {
|
|
849 |
g_debug("ignoring [ovirt] section content as URL, VM GUID"
|
848 | 850 |
" are missing from the .vv file");
|
|
851 |
goto end;
|
|
852 |
}
|
|
853 |
|
|
854 |
if ((jsessionid == NULL) && (sso_token == NULL)) {
|
|
855 |
g_debug("ignoring [ovirt] section content as jsessionid and sso-token"
|
|
856 |
" are both missing from the .vv file");
|
849 | 857 |
goto end;
|
850 | 858 |
}
|
851 | 859 |
|
|
860 | 868 |
|
861 | 869 |
g_object_set(G_OBJECT(proxy),
|
862 | 870 |
"admin", admin,
|
863 | |
"session-id", jsessionid,
|
864 | 871 |
"ca-cert", ca,
|
865 | 872 |
NULL);
|
|
873 |
if (jsessionid != NULL) {
|
|
874 |
g_object_set(G_OBJECT(proxy),
|
|
875 |
"session-id", jsessionid,
|
|
876 |
NULL);
|
|
877 |
}
|
|
878 |
if (sso_token != NULL) {
|
|
879 |
g_object_set(G_OBJECT(proxy),
|
|
880 |
"sso-token", sso_token,
|
|
881 |
NULL);
|
|
882 |
}
|
|
883 |
|
866 | 884 |
menu = g_object_new(OVIRT_TYPE_FOREIGN_MENU,
|
867 | 885 |
"proxy", proxy,
|
868 | 886 |
"vm-guid", vm_guid,
|
|
872 | 890 |
g_free(url);
|
873 | 891 |
g_free(vm_guid);
|
874 | 892 |
g_free(jsessionid);
|
|
893 |
g_free(sso_token);
|
875 | 894 |
g_free(ca_str);
|
876 | 895 |
if (ca != NULL) {
|
877 | 896 |
g_byte_array_unref(ca);
|