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/job-manager.c | 26 ++++++++++++++++++++++++++ 1 file changed, 26 insertions(+) (limited to 'src/job-manager.c') diff --git a/src/job-manager.c b/src/job-manager.c index bf3b0df..8044b7f 100644 --- a/src/job-manager.c +++ b/src/job-manager.c @@ -35,6 +35,7 @@ #define DEFAULT_DATA_DIR_MODE S_IRUSR | S_IWUSR | S_IXUSR | S_IRGRP | S_IXGRP | S_IROTH | S_IXOTH +#define AUTH_PASSWD_FILE ".htpasswd" typedef struct { @@ -268,9 +269,34 @@ build_tree (TGallerySetup *setup, } } + /* Cleanup for auth */ + if (items->auth_type != AUTH_TYPE_NONE) { + /* We're appending by default to preserve user .htaccess file supplied as an extra file. + * Let's remove the target file to prevent endless appending when overwriting the dst structure. */ + s1 = g_build_filename (path_info->dest_dir, ".htaccess", NULL); + unlink (s1); + g_free (s1); + } + /* Copy extra files */ mirror_files (setup, items->extra_files, path_info->src_dir, path_info->dest_dir, " Copying extra files: "); + /* Write auth files */ + if (items->auth_type != AUTH_TYPE_NONE) { + if (setup->verbose) printf (" Writing auth files: "); + s1 = g_build_filename (path_info->dest_dir, AUTH_PASSWD_FILE, NULL); + if (write_auth_passwd_file (setup, s1, items) && setup->verbose) + printf ("%s ", AUTH_PASSWD_FILE); + g_free (s1); + s1 = g_build_filename (path_info->dest_dir, ".htaccess", NULL); + s2 = g_build_filename (setup->location_local_path, path_info->album_path, AUTH_PASSWD_FILE, NULL); + if (write_auth_htaccess_file (setup, s1, s2, items) && setup->verbose) + printf ("%s ", ".htaccess"); + g_free (s2); + g_free (s1); + if (setup->verbose) printf ("\n"); + } + /* Prepare target image directories */ for (l = g_list_first (setup->design->image_sizes); l; l = g_list_next (l)) { image_size = l->data; -- cgit v1.2.3