Skip to content

Commit 547717b

Browse files
committed
Added AUTH_JWT module
In some cases ( ie. WebRTC ) the user authenticates on another layer ( eg. on the actual website ), so it makes no sense to double-authenticate it on the SIP layer. Thus, the WebRTC client will simply present the JWT auth token it received from the server, and pass it on to OpenSIPS ( ie. Authorization: Bearer jwt_token_here ) which will use that for authentication purposes.
1 parent 3930165 commit 547717b

24 files changed

+1831
-1
lines changed

Makefile.conf.template

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
#aaa_radius= Radius implementation for the AAA API from the core | Radius client development library, typically radiusclient-ng 0.5.0 or higher
2+
#auth_jwt= JWT auth support | JWT client development library, libjwt-dev
23
#b2b_logic= Logic engine of B2BUA, responsible of actually implementing the B2BUA services | xml parsing development library, typically libxml2-dev
34
#cachedb_cassandra= Implementation of a cache system designed to work with Cassandra servers | thrift 0.6.1
45
#cachedb_couchbase= Implementation of a cache system designed to work with CouchBase servers | libcouchbase >= 2.0
@@ -62,7 +63,7 @@
6263
#xmpp= Gateway between OpenSIPS and a jabber server. It enables the exchange of IMs between SIP clients and XMPP(jabber) clients. | parsing/building XML files, typically libexpat1-devel
6364
#uuid= UUID generator | uuid-dev
6465

65-
exclude_modules?= aaa_radius b2b_logic cachedb_cassandra cachedb_couchbase cachedb_memcached cachedb_mongodb cachedb_redis carrierroute cgrates compression cpl_c db_berkeley db_http db_mysql db_oracle db_perlvdb db_postgres db_sqlite db_unixodbc dialplan emergency event_rabbitmq h350 httpd identity jabber json ldap lua mi_xmlrpc_ng mmgeoip osp perl pi_http presence presence_dialoginfo presence_mwi presence_xml presence_dfks proto_sctp proto_tls proto_wss pua pua_bla pua_dialoginfo pua_mi pua_usrloc pua_xmpp python regex rabbitmq rabbitmq_consumer rest_client rls siprec sngtc snmpstats stir_shaken tls_mgm uuid xcap xcap_client xml xmpp
66+
exclude_modules?= aaa_radius auth_jwt b2b_logic cachedb_cassandra cachedb_couchbase cachedb_memcached cachedb_mongodb cachedb_redis carrierroute cgrates compression cpl_c db_berkeley db_http db_mysql db_oracle db_perlvdb db_postgres db_sqlite db_unixodbc dialplan emergency event_rabbitmq h350 httpd identity jabber json ldap lua mi_xmlrpc_ng mmgeoip osp perl pi_http presence presence_dialoginfo presence_mwi presence_xml presence_dfks proto_sctp proto_tls proto_wss pua pua_bla pua_dialoginfo pua_mi pua_usrloc pua_xmpp python regex rabbitmq rabbitmq_consumer rest_client rls siprec sngtc snmpstats stir_shaken tls_mgm uuid xcap xcap_client xml xmpp
6667

6768
include_modules?=
6869

db/schema/auth_jwt_profiles.xml

Lines changed: 53 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,53 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<!DOCTYPE table PUBLIC "-//opensips.org//DTD DBSchema V1.1//EN"
3+
"https://opensips.org/pub/opensips/dbschema/dtd/1.1/dbschema.dtd" [
4+
5+
<!ENTITY % entities SYSTEM "entities.xml">
6+
%entities;
7+
8+
]>
9+
10+
<table id="jwt_profiles" xmlns:db="http://docbook.org/ns/docbook">
11+
<name>jwt_profiles</name>
12+
<version>1</version>
13+
<type db="mysql">&MYSQL_TABLE_TYPE;</type>
14+
<description>
15+
<db:para>This table is used by the AUTH_JWT module to read the actual JWT profiles info
16+
More information can be found at: &OPENSIPS_MOD_DOC;auth_jwt.html.
17+
</db:para>
18+
</description>
19+
20+
<column id="id">
21+
<name>id</name>
22+
<type>unsigned int</type>
23+
<size>&table_id_len;</size>
24+
<autoincrement/>
25+
<natural/>
26+
<primary/>
27+
<type db="dbtext">int,auto</type>
28+
<description>Table key, not used by module</description>
29+
</column>
30+
31+
<column id="tag">
32+
<name>tag</name>
33+
<type>string</type>
34+
<size>128</size>
35+
<description>Unique ID of the JWT profile</description>
36+
</column>
37+
38+
<column id="sip_username">
39+
<name>sip_username</name>
40+
<type>string</type>
41+
<size>128</size>
42+
<description>The SIP username associated with the JWT profile
43+
</description>
44+
</column>
45+
46+
<index>
47+
<name>jwt_tag_idx</name>
48+
<colref linkend="tag"/>
49+
<unique/>
50+
</index>
51+
52+
53+
</table>

db/schema/auth_jwt_secrets.xml

Lines changed: 60 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,60 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<!DOCTYPE table PUBLIC "-//opensips.org//DTD DBSchema V1.1//EN"
3+
"https://opensips.org/pub/opensips/dbschema/dtd/1.1/dbschema.dtd" [
4+
5+
<!ENTITY % entities SYSTEM "entities.xml">
6+
%entities;
7+
8+
]>
9+
10+
<table id="jwt_secrets" xmlns:db="http://docbook.org/ns/docbook">
11+
<name>jwt_secrets</name>
12+
<version>1</version>
13+
<type db="mysql">&MYSQL_TABLE_TYPE;</type>
14+
<description>
15+
<db:para>This table is used by the AUTH_JWT module to read the actual JWT secrets which are used for authentication
16+
More information can be found at: &OPENSIPS_MOD_DOC;auth_jwt.html.
17+
</db:para>
18+
</description>
19+
20+
<column id="id">
21+
<name>id</name>
22+
<type>unsigned int</type>
23+
<size>&table_id_len;</size>
24+
<autoincrement/>
25+
<natural/>
26+
<primary/>
27+
<type db="dbtext">int,auto</type>
28+
<description>Table key, not used by module</description>
29+
</column>
30+
31+
<column id="corresponding_tag">
32+
<name>corresponding_tag</name>
33+
<type>string</type>
34+
<size>128</size>
35+
<description>JWT profile tag which this secret belongs to</description>
36+
</column>
37+
38+
<column id="secret">
39+
<name>secret</name>
40+
<type>string</type>
41+
<size>2048</size>
42+
<description>The KEY used for signing the JWT
43+
</description>
44+
</column>
45+
46+
<column id="start_ts">
47+
<name>start_ts</name>
48+
<type>int</type>
49+
<description>UNIX TS for the START period on which the JWT secret is valid
50+
</description>
51+
</column>
52+
53+
<column id="end_ts">
54+
<name>end_ts</name>
55+
<type>int</type>
56+
<description>UNIX TS for the END period on which the JWT secret is valid
57+
</description>
58+
</column>
59+
60+
</table>

db/schema/opensips-authjwt.xml

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<!DOCTYPE database PUBLIC "-//opensips.org//DTD DBSchema V1.1//EN"
3+
"https://opensips.org/pub/opensips/dbschema/dtd/1.1/dbschema.dtd" [
4+
5+
<!ENTITY % entities SYSTEM "entities.xml">
6+
%entities;
7+
8+
]>
9+
10+
<database xmlns:xi="http://www.w3.org/2001/XInclude">
11+
<name>Dynamic Routing</name>
12+
<xi:include href="auth_jwt_profiles.xml"/>
13+
<xi:include href="auth_jwt_secrets.xml"/>
14+
</database>

modules/auth_jwt/Makefile

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
# $Id$
2+
#
3+
# JWT Authentication
4+
#
5+
#
6+
# WARNING: do not run this directly, it should be run by the master Makefile
7+
8+
include ../../Makefile.defs
9+
auto_gen=
10+
NAME=auth_jwt.so
11+
LIBS+=-ljwt
12+
13+
include ../../Makefile.modules

0 commit comments

Comments
 (0)