Przeglądaj źródła

Read Abacus API key from server env var

master
Nano 6 dni temu
rodzic
commit
ad6caa909c
2 zmienionych plików z 41 dodań i 2 usunięć
  1. +2
    -2
      app/controllers/AdminController.asp
  2. +39
    -0
      core/helpers.asp

+ 2
- 2
app/controllers/AdminController.asp Wyświetl plik

@@ -151,8 +151,8 @@ Class AdminController_Class
End Sub End Sub


Private Sub GeneratePostContentFromAI(ByRef post, ByRef generatedSummary, ByRef generatedBody) Private Sub GeneratePostContentFromAI(ByRef post, ByRef generatedSummary, ByRef generatedBody)
Dim apiKey : apiKey = Trim(CStr(GetAppSetting("AbacusApiKey")))
If Len(apiKey) = 0 Or LCase(apiKey) = "nothing" Then
Dim apiKey : apiKey = Trim(CStr(GetSecureSetting("AbacusApiKey", "ABACUS_API_KEY")))
If Len(apiKey) = 0 Then
Err.Raise 1, "AdminController.GeneratePostContentFromAI", "Abacus API key is not configured." Err.Raise 1, "AdminController.GeneratePostContentFromAI", "Abacus API key is not configured."
End If End If




+ 39
- 0
core/helpers.asp Wyświetl plik

@@ -56,6 +56,45 @@ Public Function GetAppSetting(key)
GetAppSetting = "nothing" GetAppSetting = "nothing"
End Function End Function


Public Function GetEnvironmentValue(name)
Dim shell, env, value
value = ""

On Error Resume Next
Set shell = Server.CreateObject("WScript.Shell")
Set env = shell.Environment("PROCESS")
If Err.Number = 0 Then
value = env(name)
If Err.Number <> 0 Then
Err.Clear
value = ""
End If
Else
Err.Clear
End If
On Error GoTo 0

GetEnvironmentValue = Trim(CStr(value))
End Function

Public Function GetSecureSetting(key, envName)
Dim value

value = Trim(CStr(GetAppSetting(key)))
If Len(value) > 0 And LCase(value) <> "nothing" Then
GetSecureSetting = value
Exit Function
End If

value = Trim(CStr(GetEnvironmentValue(envName)))
If Len(value) > 0 Then
GetSecureSetting = value
Exit Function
End If

GetSecureSetting = ""
End Function

Public Sub ShowServerVariables Public Sub ShowServerVariables
Dim varName, htmlTable Dim varName, htmlTable
htmlTable = "<table border='1' cellspacing='0' cellpadding='5'>" htmlTable = "<table border='1' cellspacing='0' cellpadding='5'>"


Ładowanie…
Anuluj
Zapisz

Powered by TurnKey Linux.