Compare commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
c8b65f86c9 |
@@ -6,8 +6,7 @@ class Api::V1::Accounts::Microsoft::AuthorizationsController < Api::V1::Accounts
|
|||||||
{
|
{
|
||||||
redirect_uri: "#{base_url}/microsoft/callback",
|
redirect_uri: "#{base_url}/microsoft/callback",
|
||||||
scope: scope,
|
scope: scope,
|
||||||
state: state,
|
state: state
|
||||||
prompt: 'consent'
|
|
||||||
}
|
}
|
||||||
)
|
)
|
||||||
if redirect_url
|
if redirect_url
|
||||||
|
|||||||
@@ -265,12 +265,6 @@
|
|||||||
display_title: 'Analytics Token'
|
display_title: 'Analytics Token'
|
||||||
description: 'The Amplitude analytics API key for Chatwoot cloud'
|
description: 'The Amplitude analytics API key for Chatwoot cloud'
|
||||||
type: secret
|
type: secret
|
||||||
- name: CHATWOOT_CLOUD_SIGNALS_API_TOKEN
|
|
||||||
value:
|
|
||||||
display_title: 'Signals API Token'
|
|
||||||
description: 'Internal API token for Signals to sync Chatwoot cloud attribution data'
|
|
||||||
locked: true
|
|
||||||
type: secret
|
|
||||||
- name: CLEARBIT_API_KEY
|
- name: CLEARBIT_API_KEY
|
||||||
value:
|
value:
|
||||||
display_title: 'Clearbit API Key'
|
display_title: 'Clearbit API Key'
|
||||||
|
|||||||
@@ -555,11 +555,6 @@ Rails.application.routes.draw do
|
|||||||
end
|
end
|
||||||
resources :email_channel_migrations, only: [:create]
|
resources :email_channel_migrations, only: [:create]
|
||||||
end
|
end
|
||||||
if ChatwootApp.chatwoot_cloud?
|
|
||||||
namespace :internal do
|
|
||||||
resources :accounts, only: [:index]
|
|
||||||
end
|
|
||||||
end
|
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|||||||
@@ -34,10 +34,10 @@ module Enterprise::SuperAdmin::AppConfigsController
|
|||||||
end
|
end
|
||||||
|
|
||||||
def internal_config_options
|
def internal_config_options
|
||||||
%w[CHATWOOT_INBOX_TOKEN CHATWOOT_INBOX_HMAC_KEY CLOUD_ANALYTICS_TOKEN CHATWOOT_CLOUD_SIGNALS_API_TOKEN CLEARBIT_API_KEY
|
%w[CHATWOOT_INBOX_TOKEN CHATWOOT_INBOX_HMAC_KEY CLOUD_ANALYTICS_TOKEN CLEARBIT_API_KEY CONTEXT_DEV_API_KEY DASHBOARD_SCRIPTS
|
||||||
CONTEXT_DEV_API_KEY DASHBOARD_SCRIPTS INACTIVE_WHATSAPP_NUMBERS SKIP_INCOMING_BCC_PROCESSING CAPTAIN_CLOUD_PLAN_LIMITS
|
INACTIVE_WHATSAPP_NUMBERS SKIP_INCOMING_BCC_PROCESSING CAPTAIN_CLOUD_PLAN_LIMITS ACCOUNT_SECURITY_NOTIFICATION_WEBHOOK_URL
|
||||||
ACCOUNT_SECURITY_NOTIFICATION_WEBHOOK_URL CHATWOOT_INSTANCE_ADMIN_EMAIL OG_IMAGE_CDN_URL OG_IMAGE_CLIENT_REF CLOUDFLARE_API_KEY
|
CHATWOOT_INSTANCE_ADMIN_EMAIL OG_IMAGE_CDN_URL OG_IMAGE_CLIENT_REF CLOUDFLARE_API_KEY CLOUDFLARE_ZONE_ID BLOCKED_EMAIL_DOMAINS
|
||||||
CLOUDFLARE_ZONE_ID BLOCKED_EMAIL_DOMAINS OTEL_PROVIDER LANGFUSE_PUBLIC_KEY LANGFUSE_SECRET_KEY LANGFUSE_BASE_URL]
|
OTEL_PROVIDER LANGFUSE_PUBLIC_KEY LANGFUSE_SECRET_KEY LANGFUSE_BASE_URL]
|
||||||
end
|
end
|
||||||
|
|
||||||
def captain_config_options
|
def captain_config_options
|
||||||
|
|||||||
@@ -1,38 +0,0 @@
|
|||||||
# frozen_string_literal: true
|
|
||||||
|
|
||||||
class Platform::Api::V1::Internal::AccountsController < ActionController::API
|
|
||||||
DEFAULT_LIMIT = 100
|
|
||||||
MAX_LIMIT = 1000
|
|
||||||
|
|
||||||
before_action :ensure_chatwoot_cloud
|
|
||||||
before_action :authenticate_internal_token!
|
|
||||||
|
|
||||||
def index
|
|
||||||
@accounts = filtered_accounts.limit(limit)
|
|
||||||
end
|
|
||||||
|
|
||||||
private
|
|
||||||
|
|
||||||
def ensure_chatwoot_cloud
|
|
||||||
render json: { error: 'Not found' }, status: :not_found unless ChatwootApp.chatwoot_cloud?
|
|
||||||
end
|
|
||||||
|
|
||||||
def authenticate_internal_token!
|
|
||||||
token = request.headers[:api_access_token] || request.headers[:HTTP_API_ACCESS_TOKEN]
|
|
||||||
config_token = GlobalConfigService.load('CHATWOOT_CLOUD_SIGNALS_API_TOKEN', nil)
|
|
||||||
return if token.present? && config_token.present? && ActiveSupport::SecurityUtils.secure_compare(token, config_token)
|
|
||||||
|
|
||||||
render json: { error: 'Invalid access_token' }, status: :unauthorized
|
|
||||||
end
|
|
||||||
|
|
||||||
def filtered_accounts
|
|
||||||
scope = Account.order(:created_at, :id)
|
|
||||||
scope = scope.where('created_at >= ?', Time.zone.at(params[:since].to_i)) if params[:since].present?
|
|
||||||
scope = scope.where('created_at <= ?', Time.zone.at(params[:until].to_i)) if params[:until].present?
|
|
||||||
scope
|
|
||||||
end
|
|
||||||
|
|
||||||
def limit
|
|
||||||
params.fetch(:limit, DEFAULT_LIMIT).to_i.clamp(1, MAX_LIMIT)
|
|
||||||
end
|
|
||||||
end
|
|
||||||
@@ -1,14 +0,0 @@
|
|||||||
json.array! @accounts do |account|
|
|
||||||
json.id account.id
|
|
||||||
json.name account.name
|
|
||||||
json.created_at account.created_at
|
|
||||||
json.updated_at account.updated_at
|
|
||||||
json.status account.status
|
|
||||||
json.plan_name account.custom_attributes['plan_name']
|
|
||||||
json.stripe_customer_id account.custom_attributes['stripe_customer_id']
|
|
||||||
json.stripe_price_id account.custom_attributes['stripe_price_id']
|
|
||||||
json.stripe_product_id account.custom_attributes['stripe_product_id']
|
|
||||||
json.subscription_status account.custom_attributes['subscription_status']
|
|
||||||
json.limits account.limits
|
|
||||||
json.marketing_attribution account.internal_attributes['marketing_attribution']
|
|
||||||
end
|
|
||||||
@@ -43,6 +43,7 @@ RSpec.describe 'Microsoft Authorization API', type: :request do
|
|||||||
]
|
]
|
||||||
expect(params['scope']).to eq(expected_scope)
|
expect(params['scope']).to eq(expected_scope)
|
||||||
expect(params['redirect_uri']).to eq(["#{ENV.fetch('FRONTEND_URL', 'http://localhost:3000')}/microsoft/callback"])
|
expect(params['redirect_uri']).to eq(["#{ENV.fetch('FRONTEND_URL', 'http://localhost:3000')}/microsoft/callback"])
|
||||||
|
expect(url).not_to match(/(?:\?|&)prompt=/)
|
||||||
|
|
||||||
# Validate state parameter exists and can be decoded back to the account
|
# Validate state parameter exists and can be decoded back to the account
|
||||||
expect(params['state']).to be_present
|
expect(params['state']).to be_present
|
||||||
|
|||||||
Reference in New Issue
Block a user