OAuth providers

Signed-off-by: Ronni Skansing <rskansing@gmail.com>
This commit is contained in:
Ronni Skansing
2025-11-20 23:54:00 +01:00
parent cff927d477
commit f6eb87fa2b
31 changed files with 2627 additions and 60 deletions
+99
View File
@@ -1815,6 +1815,99 @@ export class API {
}
};
/**
* oauthProvider is the API for OAuth Provider related operations.
*/
oauthProvider = {
/**
* Get all OAuth Providers using pagination.
*
* @param {TableURLParams} options
* @param {string|null} companyID
* @returns {Promise<ApiResponse>}
*/
getAll: async (options, companyID) => {
return await getJSON(
this.getPath(`/oauth-provider?${appendQuery(options)}${this.appendCompanyQuery(companyID)}`)
);
},
/**
* Get an OAuth Provider by its ID.
*
* @param {string} id
* @returns {Promise<ApiResponse>}
*/
getByID: async (id) => {
return await getJSON(this.getPath(`/oauth-provider/${id}`));
},
/**
* Create a new OAuth Provider.
*
* @param {Object} provider
* @param {string} provider.name
* @param {string} provider.clientID
* @param {string} provider.clientSecret
* @param {string} provider.authURL
* @param {string} provider.tokenURL
* @param {string} provider.scopes
* @param {string} provider.companyID
* @returns {Promise<ApiResponse>}
*/
create: async (provider) => {
return await postJSON(this.getPath('/oauth-provider'), provider);
},
/**
* Update an OAuth Provider.
*
* @param {Object} provider
* @param {string} provider.id
* @param {string} provider.name
* @param {string} provider.clientID
* @param {string} provider.clientSecret
* @param {string} provider.authURL
* @param {string} provider.tokenURL
* @param {string} provider.scopes
* @param {string} provider.companyID
* @returns {Promise<ApiResponse>}
*/
update: async (provider) => {
return await patchJSON(this.getPath(`/oauth-provider/${provider.id}`), provider);
},
/**
* Delete an OAuth Provider.
*
* @param {string} id
* @returns {Promise<ApiResponse>}
*/
delete: async (id) => {
return await deleteJSON(this.getPath(`/oauth-provider/${id}`));
},
/**
* Get the authorization URL for an OAuth Provider.
*
* @param {string} id
* @returns {Promise<ApiResponse>}
*/
getAuthorizationURL: async (id) => {
return await getJSON(this.getPath(`/oauth-authorize/${id}`));
},
/**
* Remove authorization tokens from an OAuth Provider.
*
* @param {string} id
* @returns {Promise<ApiResponse>}
*/
removeAuthorization: async (id) => {
return await postJSON(this.getPath(`/oauth-provider/${id}/remove-authorization`), {});
}
};
/**
* user is the API for user related operations - these actions also affect the user's sessions
*/
@@ -2501,6 +2594,7 @@ export class API {
* @param {string} sender.customField2
* @param {string} sender.customField3
* @param {string} sender.customField4
* @param {string} sender.oauthProviderID
* @param {string} sender.requestMethod
* @param {string} sender.requestURL
* @param {APISenderHeader[]} sender.requestHeaders
@@ -2518,6 +2612,7 @@ export class API {
customField2,
customField3,
customField4,
oauthProviderID,
requestMethod,
requestURL,
requestHeaders,
@@ -2539,6 +2634,7 @@ export class API {
customField2: customField2,
customField3: customField3,
customField4: customField4,
oauthProviderID: oauthProviderID,
requestMethod: requestMethod,
requestURL: requestURL,
requestHeaders: requestHeaders,
@@ -2561,6 +2657,7 @@ export class API {
* @param {string} sender.customField2
* @param {string} sender.customField3
* @param {string} sender.customField4
* @param {string} sender.oauthProviderID
* @param {string} sender.requestMethod
* @param {string} sender.requestURL
* @param {APISenderHeader[]} sender.requestHeaders
@@ -2578,6 +2675,7 @@ export class API {
customField2,
customField3,
customField4,
oauthProviderID,
requestMethod,
requestURL,
requestHeaders,
@@ -2602,6 +2700,7 @@ export class API {
customField2: customField2,
customField3: customField3,
customField4: customField4,
oauthProviderID: oauthProviderID,
requestMethod: requestMethod,
requestURL: requestURL,
requestHeaders: requestHeaders,
@@ -125,6 +125,11 @@
api_senders: `<svg xmlns="http://www.w3.org/2000/svg" fill="none" viewBox="0 0 24 24" stroke-width="1.5" stroke="currentColor" class="size-6">
<path stroke-linecap="round" stroke-linejoin="round" d="M6 12 3.269 3.125A59.769 59.769 0 0 1 21.485 12 59.768 59.768 0 0 1 3.27 20.875L5.999 12Zm0 0h7.5" />
</svg>
`,
oauth_providers: `<svg xmlns="http://www.w3.org/2000/svg" fill="none" viewBox="0 0 24 24" stroke-width="1.5" stroke="currentColor" class="size-6">
<path stroke-linecap="round" stroke-linejoin="round" d="M9 12.75 11.25 15 15 9.75m-3-7.036A11.959 11.959 0 0 1 3.598 6 11.99 11.99 0 0 0 3 9.749c0 5.592 3.824 10.29 9 11.623 5.176-1.332 9-6.03 9-11.622 0-1.31-.21-2.571-.598-3.751h-.152c-3.196 0-6.1-1.248-8.25-3.285Z" />
</svg>
`,
proxy: `<svg xmlns="http://www.w3.org/2000/svg" fill="none" viewBox="0 0 24 24" stroke-width="1.5" stroke="currentColor" class="size-6">
@@ -149,7 +154,8 @@
'/email/': 'emails_overview',
'/attachment/': 'attachments',
'/smtp-configuration/': 'smtp_configurations',
'/api-sender/': 'api_senders'
'/api-sender/': 'api_senders',
'/oauth-provider/': 'oauth_providers'
};
return icons[iconMap[route] || 'dashboard']; // fallback to dashboard if route not found
@@ -67,6 +67,10 @@
<path stroke-linecap="round" stroke-linejoin="round" d="M6 12 3.269 3.125A59.769 59.769 0 0 1 21.485 12 59.768 59.768 0 0 1 3.27 20.875L5.999 12Zm0 0h7.5" />
</svg>`,
oauth_providers: `<svg xmlns="http://www.w3.org/2000/svg" fill="none" viewBox="0 0 24 24" stroke-width="1.5" stroke="currentColor" class="size-5">
<path stroke-linecap="round" stroke-linejoin="round" d="M9 12.75 11.25 15 15 9.75m-3-7.036A11.959 11.959 0 0 1 3.598 6 11.99 11.99 0 0 0 3 9.749c0 5.592 3.824 10.29 9 11.623 5.176-1.332 9-6.03 9-11.622 0-1.31-.21-2.571-.598-3.751h-.152c-3.196 0-6.1-1.248-8.25-3.285Z" />
</svg>`,
proxy: `<svg xmlns="http://www.w3.org/2000/svg" fill="none" viewBox="0 0 24 24" stroke-width="1.5" stroke="currentColor" class="size-5">
<path stroke-linecap="round" stroke-linejoin="round" d="M7.5 21 3 16.5m0 0L7.5 12M3 16.5h13.5m0-13.5L21 7.5m0 0L16.5 12M21 7.5H7.5" />
</svg>`,
@@ -123,6 +127,7 @@
'/attachment/': 'attachments',
'/smtp-configuration/': 'smtp_configurations',
'/api-sender/': 'api_senders',
'/oauth-provider/': 'oauth_providers',
'/profile/': 'profile',
'/sessions/': 'sessions',
'/user/': 'users',
@@ -10,6 +10,7 @@
export let confirm = false;
export let confirmWord = 'confirm';
export let permanent = true;
export let actionMessage = '';
let confirmText = '';
@@ -47,11 +48,19 @@
<h3 class="text-lg font-medium text-gray-900">Delete {type}</h3>
-->
<p class="mt-2 text-gray-600 dark:text-gray-400">
Are you sure you want to delete
{#if name?.length > 30}
<br />
{#if actionMessage}
{actionMessage}
{#if name?.length > 30}
<br />
{/if}
<span class="font-medium text-gray-900 dark:text-gray-300">"{name}"</span>?
{:else}
Are you sure you want to delete
{#if name?.length > 30}
<br />
{/if}
<span class="font-medium text-gray-900 dark:text-gray-300">"{name}"</span>?
{/if}
<span class="font-medium text-gray-900 dark:text-gray-300">"{name}"</span>?
</p>
</div>
+11 -1
View File
@@ -81,6 +81,10 @@ export const route = {
label: 'API Senders',
route: '/api-sender/'
},
oauthProviders: {
label: 'OAuth',
route: '/oauth-provider/'
},
allowDeny: {
label: 'Filters',
route: '/filter/'
@@ -122,7 +126,13 @@ export const menu = [
{
label: 'Emails',
type: 'submenu',
items: [route.emails, route.attachments, route.smtpConfigurations, route.apiSenders]
items: [
route.emails,
route.attachments,
route.smtpConfigurations,
route.apiSenders,
route.oauthProviders
]
}
];