mirror of
https://github.com/jambonz/jambonz-api-server.git
synced 2026-07-04 19:21:53 +00:00
Feature/jwt auth (#75)
* initial changes for jwt auth * return permissions as an array of string * Add JWT expiration environment variable (#74) * allow fromHost in createCall REST API * add JWT_EXPIRES_IN=<mins> env variable, 60 mins by default * add jwt expiration in register.js and signin.js * fix tests - add permissions and scope to encoded obj in jwt Co-authored-by: Dave Horton <daveh@beachdognet.com> Co-authored-by: eglehelms <e.helms@cognigy.com> * return only the jwt-token in the api response Co-authored-by: EgleH <egle.helms@gmail.com> Co-authored-by: eglehelms <e.helms@cognigy.com>
This commit is contained in:
+6
-2
@@ -18,7 +18,9 @@ test('Create Call Success With Synthesizer in Payload', async (t) => {
|
||||
const service_provider_sid = await createServiceProvider(request, 'account_has_synthesizer');
|
||||
const account_sid = await createAccount(request, service_provider_sid, 'account_has_synthesizer');
|
||||
const token = jwt.sign({
|
||||
account_sid
|
||||
account_sid,
|
||||
scope: "account",
|
||||
permissions: ["PROVISION_USERS", "PROVISION_SERVICES", "VIEW_ONLY"]
|
||||
}, process.env.JWT_SECRET, { expiresIn: '1h' });
|
||||
const authUser = { bearer: token };
|
||||
const speech_sid = await createGoogleSpeechCredentials(request, account_sid, null, authUser, true, true)
|
||||
@@ -58,7 +60,9 @@ test('Create Call Success Without Synthesizer in Payload', async (t) => {
|
||||
const service_provider_sid = await createServiceProvider(request, 'account2_has_synthesizer');
|
||||
const account_sid = await createAccount(request, service_provider_sid, 'account2_has_synthesizer');
|
||||
const token = jwt.sign({
|
||||
account_sid
|
||||
account_sid,
|
||||
scope: "account",
|
||||
permissions: ["PROVISION_USERS", "PROVISION_SERVICES", "VIEW_ONLY"]
|
||||
}, process.env.JWT_SECRET, { expiresIn: '1h' });
|
||||
const authUser = { bearer: token };
|
||||
const speech_sid = await createGoogleSpeechCredentials(request, account_sid, null, authUser, true, true)
|
||||
|
||||
@@ -24,12 +24,16 @@ test('recent calls tests', async(t) => {
|
||||
const account_sid = await createAccount(request, service_provider_sid);
|
||||
|
||||
const token = jwt.sign({
|
||||
account_sid
|
||||
account_sid,
|
||||
scope: "account",
|
||||
permissions: ["PROVISION_USERS", "PROVISION_SERVICES", "VIEW_ONLY"]
|
||||
}, process.env.JWT_SECRET, { expiresIn: '1h' });
|
||||
const authUser = {bearer: token};
|
||||
|
||||
const tokenSP = jwt.sign({
|
||||
service_provider_sid
|
||||
service_provider_sid,
|
||||
scope: "account",
|
||||
permissions: ["PROVISION_USERS", "PROVISION_SERVICES", "VIEW_ONLY"]
|
||||
}, process.env.JWT_SECRET, { expiresIn: '1h' });
|
||||
const authUserSP = {bearer: token};
|
||||
|
||||
|
||||
@@ -50,7 +50,10 @@ test('speech credentials tests', async(t) => {
|
||||
await deleteObjectBySid(request, `/ServiceProviders/${service_provider_sid}/SpeechCredentials`, speech_credential_sid);
|
||||
|
||||
const token = jwt.sign({
|
||||
account_sid
|
||||
account_sid,
|
||||
account_sid,
|
||||
scope: "account",
|
||||
permissions: ["PROVISION_USERS", "PROVISION_SERVICES", "VIEW_ONLY"]
|
||||
}, process.env.JWT_SECRET, { expiresIn: '1h' });
|
||||
const authUser = {bearer: token};
|
||||
|
||||
|
||||
Reference in New Issue
Block a user