From 95b85be502f639fb2080ae92d4d33c013b18aa94 Mon Sep 17 00:00:00 2001 From: Tomas Bzatek Date: Mon, 31 Dec 2012 20:08:30 +0100 Subject: Add support for password protected albums This adds support for simple password protected areas (albums and all subalbums) through webserver HTTP authentication. CGG simply generates .htaccess and password files and it's up to the user to set up the rest on server side. No UI changes at this point. Limited to one user per album for the moment. --- src/items.c | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) (limited to 'src/items.c') diff --git a/src/items.c b/src/items.c index 68ae66d..8692b65 100644 --- a/src/items.c +++ b/src/items.c @@ -140,6 +140,20 @@ parse_album_xml (const gchar *filename, TPathInfo *path_info) } } + /* Authentication */ + index->auth_type = AUTH_TYPE_NONE; + s = xml_file_get_node_value (xml, "/gallery/general/auth/type/text()"); + if (g_strcmp0 (s, "Basic") == 0) + index->auth_type = AUTH_TYPE_BASIC; + g_free (s); + index->auth_realm = xml_file_get_node_value (xml, "/gallery/general/auth/realm/text()"); + index->auth_username = xml_file_get_node_value (xml, "/gallery/general/auth/username/text()"); + index->auth_passwd = xml_file_get_node_value (xml, "/gallery/general/auth/password/text()"); + if (index->auth_type != AUTH_TYPE_NONE && (index->auth_realm == NULL || index->auth_username == NULL || index->auth_passwd == NULL)) { + log_error ("Authentication requested but not all information provided. Ignoring.\n"); + index->auth_type = AUTH_TYPE_NONE; + } + /* Section Items */ count = xml_file_node_get_children_count (xml, "/gallery/items/*"); index->items = g_ptr_array_new (); @@ -276,6 +290,9 @@ free_album_data (TAlbum *album) g_free (album->meta_author); g_free (album->meta_description); g_free (album->meta_keywords); + g_free (album->auth_realm); + g_free (album->auth_username); + g_free (album->auth_passwd); g_strfreev (album->extra_files); if (album->items) { -- cgit v1.2.3