Skip to content

Commit

Permalink
Fixed an expiration oauth2 problem
Browse files Browse the repository at this point in the history
  • Loading branch information
frikky committed May 26, 2024
1 parent 819eee6 commit 5d54006
Show file tree
Hide file tree
Showing 3 changed files with 24 additions and 9 deletions.
4 changes: 2 additions & 2 deletions app_upload/stitcher.go
Original file line number Diff line number Diff line change
Expand Up @@ -844,8 +844,8 @@ func main() {
bucketName = os.Args[5]
}

appname := "shuffle-ai"
appversion := "1.0.0"
appname := "email"
appversion := "1.3.0"
err := deployConfigToBackend(appfolder, appname, appversion)
if err != nil {
log.Printf("[WARNING] Failed uploading config: %s", err)
Expand Down
21 changes: 17 additions & 4 deletions oauth2.go
Original file line number Diff line number Diff line change
Expand Up @@ -4002,10 +4002,23 @@ func RunOauth2Request(ctx context.Context, user User, appAuth AppAuthenticationS
// FIXME: Does this work with string?
//https://stackoverflow.com/questions/43870554/microsoft-oauth2-authentication-not-returning-refresh-token
parsedTime := strconv.FormatInt(int64(time.Now().Unix())+int64(oauthResp.ExpiresIn), 10)
appAuth.Fields = append(appAuth.Fields, AuthenticationStore{
Key: "expiration",
Value: parsedTime,
})
if oauthResp.ExpiresIn > 0 {
newauth := []AuthenticationStore{}
for _, item := range appAuth.Fields {
if item.Key == "expiration" {
continue
}

newauth = append(newauth, item)
}

newauth = append(newauth, AuthenticationStore{
Key: "expiration",
Value: parsedTime,
})

appAuth.Fields = newauth
}

if len(refreshUrl) > 0 && !refresh {
log.Printf("[DEBUG] Appending Oauth2 Refresh URL %s", refreshUrl)
Expand Down
8 changes: 5 additions & 3 deletions shared.go
Original file line number Diff line number Diff line change
Expand Up @@ -14565,7 +14565,8 @@ func handleKeyEncryption(data []byte, passphrase string) ([]byte, error) {
}

func HandleKeyDecryption(data []byte, passphrase string) ([]byte, error) {
log.Printf("[DEBUG] Passphrase: %s", passphrase)
//log.Printf("[DEBUG] Passphrase: %s", passphrase)
log.Printf("Decrypting key: %s", data)
key, err := create32Hash(passphrase)
if err != nil {
log.Printf("[ERROR] Failed hashing in decrypt: %s", err)
Expand Down Expand Up @@ -14600,7 +14601,8 @@ func HandleKeyDecryption(data []byte, passphrase string) ([]byte, error) {
nonce, ciphertext := parsedData[:nonceSize], parsedData[nonceSize:]
plaintext, err := gcm.Open(nil, nonce, ciphertext, nil)
if err != nil {
log.Printf("[ERROR] Error reading decryptionkey: %s - nonce: %s, ciphertext: %s", err, nonce, ciphertext)
//log.Printf("[ERROR] Error reading decryptionkey: %s - nonce: %s, ciphertext: %s", err, nonce, ciphertext)
log.Printf("[ERROR] Error reading decryptionkey: %s - nonce: %s", err, nonce)
return []byte{}, err
}

Expand Down Expand Up @@ -18791,7 +18793,7 @@ func PrepareWorkflowExecution(ctx context.Context, workflow Workflow, request *h
}

action.Parameters = append(action.Parameters, parameter)
log.Printf("[INFO] Adding parameter %s to subflow", parameter.Name)
//log.Printf("[INFO] Adding parameter %s to subflow", parameter.Name)
}

action.Parameters = append(action.Parameters, WorkflowAppActionParameter{
Expand Down

0 comments on commit 5d54006

Please sign in to comment.