mirror of
https://github.com/anomalyco/opencode.git
synced 2026-04-24 06:45:22 +00:00
fix(console): use client credentials for salesforce
Simplify Salesforce lead auth so the console only depends on the connected app client credentials and no longer requires unused username/password secrets.
This commit is contained in:
@@ -204,8 +204,6 @@ const AWS_SES_SECRET_ACCESS_KEY = new sst.Secret("AWS_SES_SECRET_ACCESS_KEY")
|
||||
const SALESFORCE_CLIENT_ID = new sst.Secret("SALESFORCE_CLIENT_ID")
|
||||
const SALESFORCE_CLIENT_SECRET = new sst.Secret("SALESFORCE_CLIENT_SECRET")
|
||||
const SALESFORCE_INSTANCE_URL = new sst.Secret("SALESFORCE_INSTANCE_URL")
|
||||
const SALESFORCE_USERNAME = new sst.Secret("SALESFORCE_USERNAME")
|
||||
const SALESFORCE_PASSWORD = new sst.Secret("SALESFORCE_PASSWORD")
|
||||
|
||||
const logProcessor = new sst.cloudflare.Worker("LogProcessor", {
|
||||
handler: "packages/console/function/src/log-processor.ts",
|
||||
@@ -228,8 +226,6 @@ new sst.cloudflare.x.SolidStart("Console", {
|
||||
SALESFORCE_CLIENT_ID,
|
||||
SALESFORCE_CLIENT_SECRET,
|
||||
SALESFORCE_INSTANCE_URL,
|
||||
SALESFORCE_USERNAME,
|
||||
SALESFORCE_PASSWORD,
|
||||
ZEN_BLACK_PRICE,
|
||||
ZEN_LITE_PRICE,
|
||||
new sst.Secret("ZEN_LIMITS"),
|
||||
|
||||
@@ -5,8 +5,6 @@ export {}
|
||||
const url = process.env.SALESFORCE_INSTANCE_URL?.replace(/\/$/, "")
|
||||
const clientId = process.env.SALESFORCE_CLIENT_ID
|
||||
const clientSecret = process.env.SALESFORCE_CLIENT_SECRET
|
||||
const username = process.env.SALESFORCE_USERNAME
|
||||
const password = process.env.SALESFORCE_PASSWORD
|
||||
|
||||
if (!url || !clientId || !clientSecret) {
|
||||
console.error("Missing SALESFORCE_INSTANCE_URL, SALESFORCE_CLIENT_ID, or SALESFORCE_CLIENT_SECRET")
|
||||
@@ -14,10 +12,9 @@ if (!url || !clientId || !clientSecret) {
|
||||
}
|
||||
|
||||
const body = new URLSearchParams({
|
||||
grant_type: username && password ? "password" : "client_credentials",
|
||||
grant_type: "client_credentials",
|
||||
client_id: clientId,
|
||||
client_secret: clientSecret,
|
||||
...(username && password ? { username, password } : {}),
|
||||
})
|
||||
|
||||
async function main() {
|
||||
|
||||
@@ -8,19 +8,15 @@ async function login() {
|
||||
const url = baseUrl()
|
||||
const clientId = process.env.SALESFORCE_CLIENT_ID
|
||||
const clientSecret = process.env.SALESFORCE_CLIENT_SECRET
|
||||
const username = process.env.SALESFORCE_USERNAME
|
||||
const password = process.env.SALESFORCE_PASSWORD
|
||||
if (!url || !clientId || !clientSecret) {
|
||||
console.error("Salesforce credentials are incomplete")
|
||||
return null
|
||||
}
|
||||
|
||||
const usePassword = username && password
|
||||
const params = new URLSearchParams({
|
||||
grant_type: usePassword ? "password" : "client_credentials",
|
||||
grant_type: "client_credentials",
|
||||
client_id: clientId,
|
||||
client_secret: clientSecret,
|
||||
...(usePassword && { username, password }),
|
||||
})
|
||||
|
||||
const res = await fetch(`${url}/services/oauth2/token`, {
|
||||
|
||||
Reference in New Issue
Block a user