Commit 40bb04b6 authored by Philipp Schafft's avatar Philipp Schafft 🦁

Feature: Added a unique ID to each auth_t.

This added a unique ID to each auth_t instance so it can be refered
to e.g. by the web interface for mangement functionallity. Mostly
stolen from connection.[ch].
See #2123
parent 25eec226
...@@ -51,6 +51,19 @@ struct auth_stack_tag { ...@@ -51,6 +51,19 @@ struct auth_stack_tag {
/* code */ /* code */
static mutex_t _auth_lock; /* protects _current_id */
static volatile unsigned long _current_id = 0;
static unsigned long _next_auth_id(void) {
unsigned long id;
thread_mutex_lock(&_auth_lock);
id = _current_id++;
thread_mutex_unlock(&_auth_lock);
return id;
}
static auth_client *auth_client_setup (client_t *client) static auth_client *auth_client_setup (client_t *client)
{ {
/* This will look something like "Basic QWxhZGRpbjpvcGVuIHNlc2FtZQ==" */ /* This will look something like "Basic QWxhZGRpbjpvcGVuIHNlc2FtZQ==" */
...@@ -424,6 +437,7 @@ auth_t *auth_get_authenticator(xmlNodePtr node) ...@@ -424,6 +437,7 @@ auth_t *auth_get_authenticator(xmlNodePtr node)
thread_mutex_create(&auth->lock); thread_mutex_create(&auth->lock);
auth->refcount = 1; auth->refcount = 1;
auth->id = _next_auth_id();
auth->type = (char*)xmlGetProp(node, XMLSTR("type")); auth->type = (char*)xmlGetProp(node, XMLSTR("type"));
auth->role = (char*)xmlGetProp(node, XMLSTR("name")); auth->role = (char*)xmlGetProp(node, XMLSTR("name"));
...@@ -532,11 +546,13 @@ auth_t *auth_get_authenticator(xmlNodePtr node) ...@@ -532,11 +546,13 @@ auth_t *auth_get_authenticator(xmlNodePtr node)
void auth_initialise (void) void auth_initialise (void)
{ {
thread_mutex_create(&_auth_lock);
} }
void auth_shutdown (void) void auth_shutdown (void)
{ {
ICECAST_LOG_INFO("Auth shutdown"); ICECAST_LOG_INFO("Auth shutdown");
thread_mutex_destroy(&_auth_lock);
} }
/* authstack functions */ /* authstack functions */
......
...@@ -68,6 +68,9 @@ typedef struct auth_client_tag ...@@ -68,6 +68,9 @@ typedef struct auth_client_tag
typedef struct auth_tag typedef struct auth_tag
{ {
/* unique ID */
unsigned long id;
char *mount; char *mount;
/* filters */ /* filters */
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment