mirror of
https://github.com/jambonz/jambonz-api-server.git
synced 2026-07-04 19:21:53 +00:00
support for login
This commit is contained in:
+17
-5
@@ -1,6 +1,5 @@
|
||||
/* SQLEditor (MySQL (2))*/
|
||||
|
||||
SET FOREIGN_KEY_CHECKS = 0;
|
||||
|
||||
DROP TABLE IF EXISTS `call_routes`;
|
||||
|
||||
@@ -10,6 +9,8 @@ DROP TABLE IF EXISTS `lcr_routes`;
|
||||
|
||||
DROP TABLE IF EXISTS `api_keys`;
|
||||
|
||||
DROP TABLE IF EXISTS `users`;
|
||||
|
||||
DROP TABLE IF EXISTS `phone_numbers`;
|
||||
|
||||
DROP TABLE IF EXISTS `sip_gateways`;
|
||||
@@ -24,8 +25,6 @@ DROP TABLE IF EXISTS `service_providers`;
|
||||
|
||||
DROP TABLE IF EXISTS `webhooks`;
|
||||
|
||||
SET FOREIGN_KEY_CHECKS = 1;
|
||||
|
||||
CREATE TABLE IF NOT EXISTS `call_routes`
|
||||
(
|
||||
`call_route_sid` CHAR(36) NOT NULL UNIQUE ,
|
||||
@@ -51,9 +50,19 @@ CREATE TABLE IF NOT EXISTS `api_keys`
|
||||
`token` CHAR(36) NOT NULL UNIQUE ,
|
||||
`account_sid` CHAR(36),
|
||||
`service_provider_sid` CHAR(36),
|
||||
`expires_at` TIMESTAMP,
|
||||
PRIMARY KEY (`api_key_sid`)
|
||||
) ENGINE=InnoDB COMMENT='An authorization token that is used to access the REST api';
|
||||
|
||||
CREATE TABLE IF NOT EXISTS `users`
|
||||
(
|
||||
`user_sid` CHAR(36) NOT NULL UNIQUE ,
|
||||
`name` CHAR(36) NOT NULL UNIQUE ,
|
||||
`hashed_password` VARCHAR(1024) NOT NULL,
|
||||
`salt` CHAR(16) NOT NULL,
|
||||
PRIMARY KEY (`user_sid`)
|
||||
);
|
||||
|
||||
CREATE TABLE IF NOT EXISTS `voip_carriers`
|
||||
(
|
||||
`voip_carrier_sid` CHAR(36) NOT NULL UNIQUE ,
|
||||
@@ -97,7 +106,7 @@ PRIMARY KEY (`lcr_carrier_set_entry_sid`)
|
||||
CREATE TABLE IF NOT EXISTS `sip_gateways`
|
||||
(
|
||||
`sip_gateway_sid` CHAR(36),
|
||||
`ipv4` VARCHAR(32) NOT NULL COMMENT 'ip address or DNS name of the gateway. For gateways providing inbound calling service, ip address is required.',
|
||||
`ipv4` VARCHAR(128) NOT NULL COMMENT 'ip address or DNS name of the gateway. For gateways providing inbound calling service, ip address is required.',
|
||||
`port` INTEGER NOT NULL DEFAULT 5060 COMMENT 'sip signaling port',
|
||||
`inbound` BOOLEAN NOT NULL COMMENT 'if true, whitelist this IP to allow inbound calls from the gateway',
|
||||
`outbound` BOOLEAN NOT NULL COMMENT 'if true, include in least-cost routing when placing calls to the PSTN',
|
||||
@@ -114,7 +123,8 @@ CREATE TABLE IF NOT EXISTS `applications`
|
||||
`call_hook_sid` CHAR(36) COMMENT 'webhook to call for inbound calls to phone numbers owned by this account',
|
||||
`call_status_hook_sid` CHAR(36) COMMENT 'webhook to call for call status events',
|
||||
`speech_synthesis_vendor` VARCHAR(64) NOT NULL DEFAULT 'google',
|
||||
`speech_synthesis_voice` VARCHAR(64) NOT NULL DEFAULT 'en-US-Wavenet-C',
|
||||
`speech_synthesis_language` VARCHAR(12) NOT NULL DEFAULT 'en-US',
|
||||
`speech_synthesis_voice` VARCHAR(64),
|
||||
`speech_recognizer_vendor` VARCHAR(64) NOT NULL DEFAULT 'google',
|
||||
`speech_recognizer_language` VARCHAR(64) NOT NULL DEFAULT 'en-US',
|
||||
PRIMARY KEY (`application_sid`)
|
||||
@@ -154,6 +164,8 @@ ALTER TABLE `api_keys` ADD FOREIGN KEY account_sid_idxfk_1 (`account_sid`) REFER
|
||||
CREATE INDEX `api_keys_service_provider_sid_idx` ON `api_keys` (`service_provider_sid`);
|
||||
ALTER TABLE `api_keys` ADD FOREIGN KEY service_provider_sid_idxfk (`service_provider_sid`) REFERENCES `service_providers` (`service_provider_sid`);
|
||||
|
||||
CREATE INDEX `users_user_sid_idx` ON `users` (`user_sid`);
|
||||
CREATE INDEX `users_name_idx` ON `users` (`name`);
|
||||
CREATE INDEX `voip_carriers_voip_carrier_sid_idx` ON `voip_carriers` (`voip_carrier_sid`);
|
||||
CREATE INDEX `voip_carriers_name_idx` ON `voip_carriers` (`name`);
|
||||
ALTER TABLE `voip_carriers` ADD FOREIGN KEY account_sid_idxfk_2 (`account_sid`) REFERENCES `accounts` (`account_sid`);
|
||||
|
||||
+64
-10
@@ -1,5 +1,48 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<SQLContainer>
|
||||
<SQLTable>
|
||||
<name><![CDATA[users]]></name>
|
||||
<schema><![CDATA[]]></schema>
|
||||
<location>
|
||||
<x>1560.00</x>
|
||||
<y>65.00</y>
|
||||
</location>
|
||||
<size>
|
||||
<width>250.00</width>
|
||||
<height>110.00</height>
|
||||
</size>
|
||||
<zorder>11</zorder>
|
||||
<SQLField>
|
||||
<name><![CDATA[user_sid]]></name>
|
||||
<type><![CDATA[CHAR(36)]]></type>
|
||||
<primaryKey>1</primaryKey>
|
||||
<indexed><![CDATA[1]]></indexed>
|
||||
<notNull><![CDATA[1]]></notNull>
|
||||
<uid><![CDATA[F33F9604-ADC9-46E3-AE51-A2A839A81758]]></uid>
|
||||
<unique><![CDATA[1]]></unique>
|
||||
</SQLField>
|
||||
<SQLField>
|
||||
<name><![CDATA[name]]></name>
|
||||
<type><![CDATA[CHAR(36)]]></type>
|
||||
<indexed><![CDATA[1]]></indexed>
|
||||
<notNull><![CDATA[1]]></notNull>
|
||||
<uid><![CDATA[6E8DE796-46DA-4644-AA7F-1A75D9B834FB]]></uid>
|
||||
<unique><![CDATA[1]]></unique>
|
||||
</SQLField>
|
||||
<SQLField>
|
||||
<name><![CDATA[hashed_password]]></name>
|
||||
<type><![CDATA[VARCHAR(1024)]]></type>
|
||||
<notNull><![CDATA[1]]></notNull>
|
||||
<uid><![CDATA[3E7E38A2-96FC-4E28-BF10-332823FB17F1]]></uid>
|
||||
</SQLField>
|
||||
<SQLField>
|
||||
<name><![CDATA[salt]]></name>
|
||||
<type><![CDATA[CHAR(16)]]></type>
|
||||
<notNull><![CDATA[1]]></notNull>
|
||||
<uid><![CDATA[F21A170F-5922-4749-A062-6C7516051560]]></uid>
|
||||
</SQLField>
|
||||
<uid><![CDATA[2A735FAB-592C-42E5-9C8B-06B109314799]]></uid>
|
||||
</SQLTable>
|
||||
<SQLTable>
|
||||
<name><![CDATA[voip_carriers]]></name>
|
||||
<schema><![CDATA[]]></schema>
|
||||
@@ -83,7 +126,7 @@
|
||||
</location>
|
||||
<size>
|
||||
<width>252.00</width>
|
||||
<height>100.00</height>
|
||||
<height>120.00</height>
|
||||
</size>
|
||||
<zorder>1</zorder>
|
||||
<SQLField>
|
||||
@@ -132,6 +175,11 @@
|
||||
<indexed><![CDATA[1]]></indexed>
|
||||
<uid><![CDATA[3F553F20-AA47-471E-A650-0B4CEC9DCB0A]]></uid>
|
||||
</SQLField>
|
||||
<SQLField>
|
||||
<name><![CDATA[expires_at]]></name>
|
||||
<type><![CDATA[TIMESTAMP]]></type>
|
||||
<uid><![CDATA[DE86BC18-858E-4D7E-9B83-891DB2861434]]></uid>
|
||||
</SQLField>
|
||||
<labelWindowIndex><![CDATA[10]]></labelWindowIndex>
|
||||
<objectComment><![CDATA[An authorization token that is used to access the REST api]]></objectComment>
|
||||
<ui.treeExpanded><![CDATA[1]]></ui.treeExpanded>
|
||||
@@ -529,7 +577,7 @@
|
||||
</SQLField>
|
||||
<SQLField>
|
||||
<name><![CDATA[ipv4]]></name>
|
||||
<type><![CDATA[VARCHAR(32)]]></type>
|
||||
<type><![CDATA[VARCHAR(128)]]></type>
|
||||
<notNull><![CDATA[1]]></notNull>
|
||||
<objectComment><![CDATA[ip address or DNS name of the gateway. For gateways providing inbound calling service, ip address is required.]]></objectComment>
|
||||
<uid><![CDATA[F18DB7D4-F902-4863-870C-CB07032AE17C]]></uid>
|
||||
@@ -611,7 +659,7 @@
|
||||
</location>
|
||||
<size>
|
||||
<width>345.00</width>
|
||||
<height>220.00</height>
|
||||
<height>240.00</height>
|
||||
</size>
|
||||
<zorder>0</zorder>
|
||||
<SQLField>
|
||||
@@ -683,11 +731,17 @@
|
||||
<notNull><![CDATA[1]]></notNull>
|
||||
<uid><![CDATA[05D3C937-255D-44A5-A102-40303FA37CF1]]></uid>
|
||||
</SQLField>
|
||||
<SQLField>
|
||||
<name><![CDATA[speech_synthesis_language]]></name>
|
||||
<type><![CDATA[VARCHAR(12)]]></type>
|
||||
<defaultValue><![CDATA[en-US]]></defaultValue>
|
||||
<notNull><![CDATA[1]]></notNull>
|
||||
<uid><![CDATA[2498FC63-58A1-40AF-8502-ABC4F1F5F541]]></uid>
|
||||
</SQLField>
|
||||
<SQLField>
|
||||
<name><![CDATA[speech_synthesis_voice]]></name>
|
||||
<type><![CDATA[VARCHAR(64)]]></type>
|
||||
<defaultValue><![CDATA[en-US-Wavenet-C]]></defaultValue>
|
||||
<notNull><![CDATA[1]]></notNull>
|
||||
<notNull><![CDATA[0]]></notNull>
|
||||
<uid><![CDATA[929D66F0-64B9-4D7C-AB4B-24F131E1178F]]></uid>
|
||||
</SQLField>
|
||||
<SQLField>
|
||||
@@ -850,17 +904,17 @@
|
||||
<overviewPanelHidden><![CDATA[0]]></overviewPanelHidden>
|
||||
<pageBoundariesVisible><![CDATA[0]]></pageBoundariesVisible>
|
||||
<PageGridVisible><![CDATA[0]]></PageGridVisible>
|
||||
<RightSidebarWidth><![CDATA[2146.000000]]></RightSidebarWidth>
|
||||
<RightSidebarWidth><![CDATA[1855.000000]]></RightSidebarWidth>
|
||||
<sidebarIndex><![CDATA[2]]></sidebarIndex>
|
||||
<snapToGrid><![CDATA[0]]></snapToGrid>
|
||||
<SourceSidebarWidth><![CDATA[0.000000]]></SourceSidebarWidth>
|
||||
<SQLEditorFileFormatVersion><![CDATA[4]]></SQLEditorFileFormatVersion>
|
||||
<uid><![CDATA[58C99A00-06C9-478C-A667-C63842E088F3]]></uid>
|
||||
<windowHeight><![CDATA[1322.000000]]></windowHeight>
|
||||
<windowLocationX><![CDATA[2553.000000]]></windowLocationX>
|
||||
<windowLocationY><![CDATA[95.000000]]></windowLocationY>
|
||||
<windowHeight><![CDATA[1143.000000]]></windowHeight>
|
||||
<windowLocationX><![CDATA[2861.000000]]></windowLocationX>
|
||||
<windowLocationY><![CDATA[274.000000]]></windowLocationY>
|
||||
<windowScrollOrigin><![CDATA[{0, 0}]]></windowScrollOrigin>
|
||||
<windowWidth><![CDATA[2423.000000]]></windowWidth>
|
||||
<windowWidth><![CDATA[2247.000000]]></windowWidth>
|
||||
</SQLDocumentInfo>
|
||||
<AllowsIndexRenamingOnInsert><![CDATA[1]]></AllowsIndexRenamingOnInsert>
|
||||
<defaultLabelExpanded><![CDATA[1]]></defaultLabelExpanded>
|
||||
|
||||
@@ -28,6 +28,9 @@ paths:
|
||||
account_sid:
|
||||
type: string
|
||||
description: account scope for the generated api key
|
||||
expiry_secs:
|
||||
type: number
|
||||
description: duration of key validity, in seconds
|
||||
responses:
|
||||
201:
|
||||
description: api key successfully created
|
||||
@@ -64,6 +67,80 @@ paths:
|
||||
404:
|
||||
description: api key or account not found
|
||||
|
||||
/login:
|
||||
post:
|
||||
summary: login a user and receive an api token
|
||||
operationId: loginUser
|
||||
requestBody:
|
||||
content:
|
||||
application/json:
|
||||
schema:
|
||||
type: object
|
||||
properties:
|
||||
username:
|
||||
type: string
|
||||
description: login username
|
||||
password:
|
||||
type: string
|
||||
description: login password
|
||||
required:
|
||||
- username
|
||||
- password
|
||||
responses:
|
||||
200:
|
||||
description: login succeeded
|
||||
content:
|
||||
application/json:
|
||||
schema: '#/components/schemas/SuccessfulLogin'
|
||||
403:
|
||||
description: login failed
|
||||
content:
|
||||
application/json:
|
||||
schema:
|
||||
$ref: '#/components/schemas/GeneralError'
|
||||
500:
|
||||
description: system error
|
||||
content:
|
||||
application/json:
|
||||
schema:
|
||||
$ref: '#/components/schemas/GeneralError'
|
||||
/User/{UserSid}:
|
||||
put:
|
||||
summary: update a user password
|
||||
operationId: updateUser
|
||||
requestBody:
|
||||
content:
|
||||
application/json:
|
||||
schema:
|
||||
type: object
|
||||
properties:
|
||||
old_password:
|
||||
type: string
|
||||
description: existing password, which is to be replaced
|
||||
new_password:
|
||||
type: string
|
||||
description: new password
|
||||
required:
|
||||
- old_password
|
||||
- new_password
|
||||
responses:
|
||||
200:
|
||||
description: password successfully changed
|
||||
content:
|
||||
application/json:
|
||||
schema: '#/components/schemas/SuccessfulLogin'
|
||||
403:
|
||||
description: password change failed
|
||||
content:
|
||||
application/json:
|
||||
schema:
|
||||
$ref: '#/components/schemas/GeneralError'
|
||||
500:
|
||||
description: system error
|
||||
content:
|
||||
application/json:
|
||||
schema:
|
||||
$ref: '#/components/schemas/GeneralError'
|
||||
/VoipCarriers:
|
||||
post:
|
||||
summary: create voip carrier
|
||||
@@ -1240,6 +1317,17 @@ components:
|
||||
scheme: bearer
|
||||
bearerFormat: token
|
||||
schemas:
|
||||
SuccessfulLogin:
|
||||
type: object
|
||||
properties:
|
||||
user_sid:
|
||||
type: string
|
||||
api_token:
|
||||
type: string
|
||||
change_password:
|
||||
type: boolean
|
||||
required:
|
||||
- user_sid
|
||||
SuccessfulApiKeyAdd:
|
||||
type: object
|
||||
required:
|
||||
|
||||
Reference in New Issue
Block a user