Allow restriction for one DVR configuration mapped to one user

In some use cases, it may be usefull to not allow selection of the
DVR configuration for the end-users. Map the DVR configuration by name
matching the username for these restricted users (DVR configuration must
be identical to the username, otherwise the default configuration is used).

Signed-off-by: Jaroslav Kysela <perex@perex.cz>
This commit is contained in:
Jaroslav Kysela 2012-03-01 17:37:07 +01:00
parent b8778005b4
commit d8788062ab
4 changed files with 43 additions and 3 deletions

View file

@ -391,6 +391,7 @@ access_record_build(access_entry_t *ae)
htsmsg_add_u32(e, "streaming", ae->ae_rights & ACCESS_STREAMING ? 1 : 0);
htsmsg_add_u32(e, "dvr" , ae->ae_rights & ACCESS_RECORDER ? 1 : 0);
htsmsg_add_u32(e, "dvrallcfg", ae->ae_rights & ACCESS_RECORDER_ALL ? 1 : 0);
htsmsg_add_u32(e, "webui" , ae->ae_rights & ACCESS_WEB_INTERFACE ? 1 : 0);
htsmsg_add_u32(e, "admin" , ae->ae_rights & ACCESS_ADMIN ? 1 : 0);
@ -480,6 +481,9 @@ access_record_update(void *opaque, const char *id, htsmsg_t *values,
if(!htsmsg_get_u32(values, "dvr", &u32))
access_update_flag(ae, ACCESS_RECORDER, u32);
if(!htsmsg_get_u32(values, "dvrallcfg", &u32))
access_update_flag(ae, ACCESS_RECORDER_ALL, u32);
if(!htsmsg_get_u32(values, "admin", &u32))
access_update_flag(ae, ACCESS_ADMIN, u32);

View file

@ -58,7 +58,8 @@ typedef struct access_ticket {
#define ACCESS_STREAMING 0x1
#define ACCESS_WEB_INTERFACE 0x2
#define ACCESS_RECORDER 0x4
#define ACCESS_ADMIN 0x8
#define ACCESS_RECORDER_ALL 0x8
#define ACCESS_ADMIN 0x10
#define ACCESS_FULL 0x3f
/**

View file

@ -624,6 +624,9 @@ extjs_confignames(http_connection_t *hc, const char *remain, void *opaque)
out = htsmsg_create_map();
array = htsmsg_create_list();
if (http_access_verify(hc, ACCESS_RECORDER_ALL))
goto skip;
LIST_FOREACH(cfg, &dvrconfigs, config_link) {
e = htsmsg_create_map();
htsmsg_add_str(e, "identifier", cfg->dvr_config_name);
@ -634,6 +637,7 @@ extjs_confignames(http_connection_t *hc, const char *remain, void *opaque)
htsmsg_add_msg(array, NULL, e);
}
skip:
htsmsg_add_msg(out, "entries", array);
} else {
@ -787,6 +791,18 @@ extjs_dvr(http_connection_t *hc, const char *remain, void *opaque)
return HTTP_STATUS_BAD_REQUEST;
}
if (http_access_verify(hc, ACCESS_RECORDER_ALL)) {
config_name = NULL;
LIST_FOREACH(cfg, &dvrconfigs, config_link) {
if (strcmp(cfg->dvr_config_name, hc->hc_username) == 0) {
config_name = cfg->dvr_config_name;
break;
}
}
if (config_name == NULL)
tvhlog(LOG_INFO,"dvr","User '%s' has no dvr config with identical name, using default...", hc->hc_username);
}
dvr_entry_create_by_event(config_name,
e, hc->hc_representative, NULL, DVR_PRIO_NORMAL);
@ -857,6 +873,18 @@ extjs_dvr(http_connection_t *hc, const char *remain, void *opaque)
if(stop < start)
stop += 86400;
if (http_access_verify(hc, ACCESS_RECORDER_ALL)) {
config_name = NULL;
LIST_FOREACH(cfg, &dvrconfigs, config_link) {
if (strcmp(cfg->dvr_config_name, hc->hc_username) == 0) {
config_name = cfg->dvr_config_name;
break;
}
}
if (config_name == NULL)
tvhlog(LOG_INFO,"dvr","User '%s' has no dvr config with identical name, using default...", hc->hc_username);
}
dvr_entry_create(config_name,
ch, start, stop, title, NULL, hc->hc_representative,
NULL, NULL, 0, dvr_pri2val(pri));

View file

@ -20,6 +20,12 @@ tvheadend.acleditor = function() {
width: 100
});
var dvrallcfgColumn = new Ext.grid.CheckColumn({
header: "All Configs (VR)",
dataIndex: 'dvrallcfg',
width: 100
});
var webuiColumn = new Ext.grid.CheckColumn({
header: "Web Interface",
dataIndex: 'webui',
@ -52,6 +58,7 @@ tvheadend.acleditor = function() {
},
streamingColumn,
dvrColumn,
dvrallcfgColumn,
webuiColumn,
adminColumn,
{
@ -63,14 +70,14 @@ tvheadend.acleditor = function() {
]);
var UserRecord = Ext.data.Record.create([
'enabled','streaming','dvr','admin','webui','username',
'enabled','streaming','dvr','dvrallcfg','admin','webui','username',
'prefix','password','comment'
]);
return new tvheadend.tableEditor('Access control', 'accesscontrol', cm,
UserRecord,
[enabledColumn, streamingColumn,
dvrColumn, webuiColumn,
dvrColumn, dvrallcfgColumn, webuiColumn,
adminColumn],
null,
'config_access.html', 'group');