summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorWim Taymans <wim.taymans@collabora.co.uk>2011-01-12 00:35:28 +0100
committerWim Taymans <wim.taymans@gmail.com>2011-01-12 00:35:28 +0100
commitc59d9e2970a9ca78f127e35e78dce808235c6cae (patch)
tree57a92b46a617d89a096084025614a12c96c71cf9
parent5fb5f750208c7f35422a7fc3405fdb9b35b86fdc (diff)
client: delegate setup of auth to the manager
Delegate the configuration of the authentication tokens to the manager object when configured.
-rw-r--r--gst/rtsp-server/rtsp-auth.c47
-rw-r--r--gst/rtsp-server/rtsp-auth.h7
-rw-r--r--gst/rtsp-server/rtsp-client.c11
3 files changed, 61 insertions, 4 deletions
diff --git a/gst/rtsp-server/rtsp-auth.c b/gst/rtsp-server/rtsp-auth.c
index ff83c1b..81855c2 100644
--- a/gst/rtsp-server/rtsp-auth.c
+++ b/gst/rtsp-server/rtsp-auth.c
@@ -36,6 +36,9 @@ static void gst_rtsp_auth_set_property (GObject * object, guint propid,
const GValue * value, GParamSpec * pspec);
static void gst_rtsp_auth_finalize (GObject * obj);
+static gboolean default_setup_auth (GstRTSPAuth * auth, GstRTSPClient * client,
+ GstRTSPUrl * uri, GstRTSPSession * session, GstRTSPMessage * request,
+ GstRTSPMessage * response);
static gboolean default_check_method (GstRTSPAuth * auth, GstRTSPMethod method,
GstRTSPClient * client, GstRTSPUrl * uri, GstRTSPSession * session,
GstRTSPMessage * request);
@@ -53,6 +56,7 @@ gst_rtsp_auth_class_init (GstRTSPAuthClass * klass)
gobject_class->set_property = gst_rtsp_auth_set_property;
gobject_class->finalize = gst_rtsp_auth_finalize;
+ klass->setup_auth = default_setup_auth;
klass->check_method = default_check_method;
GST_DEBUG_CATEGORY_INIT (rtsp_auth_debug, "rtspauth", 0, "GstRTSPAuth");
@@ -136,6 +140,49 @@ gst_rtsp_auth_set_basic (GstRTSPAuth * auth, const gchar * basic)
}
static gboolean
+default_setup_auth (GstRTSPAuth * auth, GstRTSPClient * client,
+ GstRTSPUrl * uri, GstRTSPSession * session, GstRTSPMessage * request,
+ GstRTSPMessage * response)
+{
+ /* we only have Basic for now */
+ gst_rtsp_message_add_header (response, GST_RTSP_HDR_WWW_AUTHENTICATE,
+ "Basic ");
+
+ return TRUE;
+}
+
+/**
+ * gst_rtsp_auth_setup_auth:
+ * @auth: a #GstRTSPAuth
+ * @client: the client
+ * @uri: the requested uri
+ * @session: the session
+ * @request: the request
+ * @response: the response
+ *
+ * Add authentication tokens to @response.
+ *
+ * Returns: FALSE if something is wrong.
+ */
+gboolean
+gst_rtsp_auth_setup_auth (GstRTSPAuth * auth, GstRTSPClient * client,
+ GstRTSPUrl * uri, GstRTSPSession * session, GstRTSPMessage * request,
+ GstRTSPMessage * response)
+{
+ gboolean result = FALSE;
+ GstRTSPAuthClass *klass;
+
+ klass = GST_RTSP_AUTH_GET_CLASS (auth);
+
+ GST_DEBUG_OBJECT (auth, "setup auth");
+
+ if (klass->setup_auth)
+ result = klass->setup_auth (auth, client, uri, session, request, response);
+
+ return result;
+}
+
+static gboolean
default_check_method (GstRTSPAuth * auth, GstRTSPMethod method,
GstRTSPClient * client, GstRTSPUrl * uri, GstRTSPSession * session,
GstRTSPMessage * request)
diff --git a/gst/rtsp-server/rtsp-auth.h b/gst/rtsp-server/rtsp-auth.h
index 85ac733..786d561 100644
--- a/gst/rtsp-server/rtsp-auth.h
+++ b/gst/rtsp-server/rtsp-auth.h
@@ -56,6 +56,10 @@ struct _GstRTSPAuth {
struct _GstRTSPAuthClass {
GObjectClass parent_class;
+ gboolean (*setup_auth) (GstRTSPAuth *auth, GstRTSPClient * client,
+ GstRTSPUrl * uri, GstRTSPSession * session, GstRTSPMessage * request,
+ GstRTSPMessage *response);
+
gboolean (*check_method) (GstRTSPAuth *auth, GstRTSPMethod method,
GstRTSPClient * client, GstRTSPUrl * uri,
GstRTSPSession * session, GstRTSPMessage * request);
@@ -67,6 +71,9 @@ GstRTSPAuth * gst_rtsp_auth_new (void);
void gst_rtsp_auth_set_basic (GstRTSPAuth *auth, const gchar * basic);
+gboolean gst_rtsp_auth_setup_auth (GstRTSPAuth *auth, GstRTSPClient * client,
+ GstRTSPUrl * uri, GstRTSPSession * session,
+ GstRTSPMessage * request, GstRTSPMessage *response);
gboolean gst_rtsp_auth_check_method (GstRTSPAuth *auth, GstRTSPMethod method,
GstRTSPClient * client, GstRTSPUrl * uri,
GstRTSPSession * session, GstRTSPMessage * request);
diff --git a/gst/rtsp-server/rtsp-client.c b/gst/rtsp-server/rtsp-client.c
index 8465a97..757f08f 100644
--- a/gst/rtsp-server/rtsp-client.c
+++ b/gst/rtsp-server/rtsp-client.c
@@ -252,7 +252,7 @@ send_generic_response (GstRTSPClient * client, GstRTSPStatusCode code,
send_response (client, NULL, &response);
}
-static gboolean
+static void
handle_unauthorized_request (GstRTSPClient * client, GstRTSPUrl * uri,
GstRTSPSession * session, GstRTSPMessage * request)
{
@@ -260,11 +260,14 @@ handle_unauthorized_request (GstRTSPClient * client, GstRTSPUrl * uri,
gst_rtsp_message_init_response (&response, GST_RTSP_STS_UNAUTHORIZED,
gst_rtsp_status_as_text (GST_RTSP_STS_UNAUTHORIZED), request);
- gst_rtsp_message_add_header (&response, GST_RTSP_HDR_WWW_AUTHENTICATE,
- "Basic ");
+
+ if (client->auth) {
+ /* and let the authentication manager setup the auth tokens */
+ gst_rtsp_auth_setup_auth (client->auth, client, uri, session, request,
+ &response);
+ }
send_response (client, session, &response);
- return;
}