docs: update docs
[platform/upstream/gstreamer.git] / gst / rtsp-server / rtsp-auth.h
1 /* GStreamer
2  * Copyright (C) 2010 Wim Taymans <wim.taymans at gmail.com>
3  *
4  * This library is free software; you can redistribute it and/or
5  * modify it under the terms of the GNU Library General Public
6  * License as published by the Free Software Foundation; either
7  * version 2 of the License, or (at your option) any later version.
8  *
9  * This library is distributed in the hope that it will be useful,
10  * but WITHOUT ANY WARRANTY; without even the implied warranty of
11  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
12  * Library General Public License for more details.
13  *
14  * You should have received a copy of the GNU Library General Public
15  * License along with this library; if not, write to the
16  * Free Software Foundation, Inc., 51 Franklin St, Fifth Floor,
17  * Boston, MA 02110-1301, USA.
18  */
19
20 #include <gst/gst.h>
21
22 #ifndef __GST_RTSP_AUTH_H__
23 #define __GST_RTSP_AUTH_H__
24
25 typedef struct _GstRTSPAuth GstRTSPAuth;
26 typedef struct _GstRTSPAuthClass GstRTSPAuthClass;
27 typedef struct _GstRTSPAuthPrivate GstRTSPAuthPrivate;
28
29 #include "rtsp-client.h"
30 #include "rtsp-token.h"
31
32 G_BEGIN_DECLS
33
34 #define GST_TYPE_RTSP_AUTH              (gst_rtsp_auth_get_type ())
35 #define GST_IS_RTSP_AUTH(obj)           (G_TYPE_CHECK_INSTANCE_TYPE ((obj), GST_TYPE_RTSP_AUTH))
36 #define GST_IS_RTSP_AUTH_CLASS(klass)   (G_TYPE_CHECK_CLASS_TYPE ((klass), GST_TYPE_RTSP_AUTH))
37 #define GST_RTSP_AUTH_GET_CLASS(obj)    (G_TYPE_INSTANCE_GET_CLASS ((obj), GST_TYPE_RTSP_AUTH, GstRTSPAuthClass))
38 #define GST_RTSP_AUTH(obj)              (G_TYPE_CHECK_INSTANCE_CAST ((obj), GST_TYPE_RTSP_AUTH, GstRTSPAuth))
39 #define GST_RTSP_AUTH_CLASS(klass)      (G_TYPE_CHECK_CLASS_CAST ((klass), GST_TYPE_RTSP_AUTH, GstRTSPAuthClass))
40 #define GST_RTSP_AUTH_CAST(obj)         ((GstRTSPAuth*)(obj))
41 #define GST_RTSP_AUTH_CLASS_CAST(klass) ((GstRTSPAuthClass*)(klass))
42
43 /**
44  * GstRTSPAuth:
45  *
46  * The authentication structure.
47  */
48 struct _GstRTSPAuth {
49   GObject       parent;
50
51   GstRTSPAuthPrivate *priv;
52 };
53
54 /**
55  * GstRTSPAuthClass:
56  * @setup: called when an unauthorized resource has been accessed and
57  *         authentication needs to be requested to the client. The default
58  *         implementation adds basic authentication to the response.
59  * @authenticate: check the authentication of a client. The default implementation
60  *         checks if the authentication in the header matches one of the basic
61  *         authentication tokens. This function should set the authgroup field
62  *         in the state.
63  * @check: check if a resource can be accessed. this function should
64  *         call validate to authenticate the client when needed. The default
65  *         implementation disallows unauthenticated access to all methods
66  *         except OPTIONS.
67  *
68  * The authentication class.
69  */
70 struct _GstRTSPAuthClass {
71   GObjectClass  parent_class;
72
73   gboolean           (*setup)        (GstRTSPAuth *auth, GstRTSPClientState *state);
74   gboolean           (*authenticate) (GstRTSPAuth *auth, GstRTSPClientState *state);
75   gboolean           (*check)        (GstRTSPAuth *auth, GstRTSPClientState *state,
76                                       const gchar *check);
77 };
78
79 GType               gst_rtsp_auth_get_type          (void);
80
81 GstRTSPAuth *       gst_rtsp_auth_new               (void);
82
83 void                gst_rtsp_auth_add_basic         (GstRTSPAuth *auth, const gchar * basic,
84                                                      GstRTSPToken *token);
85 void                gst_rtsp_auth_remove_basic      (GstRTSPAuth *auth, const gchar * basic);
86
87 gboolean            gst_rtsp_auth_setup             (GstRTSPAuth *auth, GstRTSPClientState *state);
88
89 gboolean            gst_rtsp_auth_check             (const gchar *check);
90
91
92 /* helpers */
93 gchar *             gst_rtsp_auth_make_basic        (const gchar * user, const gchar * pass);
94
95 /* checks */
96 /**
97  * GST_RTSP_AUTH_CHECK_URL:
98  *
99  * Check the URL and methods
100  */
101 #define GST_RTSP_AUTH_CHECK_URL                      "auth.check.url"
102 /**
103  * GST_RTSP_AUTH_CHECK_MEDIA_FACTORY_ACCESS:
104  *
105  * Check if access is allowed to a factory
106  */
107 #define GST_RTSP_AUTH_CHECK_MEDIA_FACTORY_ACCESS     "auth.check.media.factory.access"
108 /**
109  * GST_RTSP_AUTH_CHECK_MEDIA_FACTORY_CONSTRUCT:
110  *
111  * Check if media can be constructed from a media factory
112  */
113 #define GST_RTSP_AUTH_CHECK_MEDIA_FACTORY_CONSTRUCT  "auth.check.media.factory.construct"
114
115
116 /* tokens */
117 /**
118  * GST_RTSP_MEDIA_FACTORY_ROLE:
119  *
120  * G_TYPE_STRING, the role to use when dealing with media factories
121  */
122 #define GST_RTSP_MEDIA_FACTORY_ROLE      "media.factory.role"
123
124 /* permissions */
125 /**
126  * GST_RTSP_MEDIA_FACTORY_PERM_ACCESS:
127  *
128  * G_TYPE_BOOLEAN, %TRUE if the media can be accessed, %FALSE will
129  * return a 404 Not Found error when trying to access the media.
130  */
131 #define GST_RTSP_MEDIA_FACTORY_PERM_ACCESS      "media.factory.access"
132 /**
133  * GST_RTSP_MEDIA_FACTORY_PERM_CONSTRUCT:
134  *
135  * G_TYPE_BOOLEAN, %TRUE if the media can be constructed, %FALSE will
136  * return a 404 Not Found error when trying to access the media.
137  */
138 #define GST_RTSP_MEDIA_FACTORY_PERM_CONSTRUCT   "media.factory.construct"
139
140
141 G_END_DECLS
142
143 #endif /* __GST_RTSP_AUTH_H__ */