Skip to content

Commit

Permalink
Fixed the name change problem in auth
Browse files Browse the repository at this point in the history
  • Loading branch information
frikky committed Jul 19, 2024
1 parent dd2d985 commit ce6e5b6
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 9 deletions.
8 changes: 7 additions & 1 deletion oauth2.go
Original file line number Diff line number Diff line change
Expand Up @@ -3580,11 +3580,17 @@ func GetOauth2ApplicationPermissionToken(ctx context.Context, user User, appAuth
refreshData += fmt.Sprintf("&scope=%s", strings.Replace(scope, ",", " ", -1))
}

if strings.Contains(refreshData, "user_impersonation") && strings.Contains (refreshData, "azure.com") && !strings.Contains(refreshData, "resource="){

if strings.Contains(refreshData, "user_impersonation") && strings.Contains (refreshData, "azure") && !strings.Contains(refreshData, "resource="){
// Add "resource" for microsoft hings
refreshData += "&resource=https://management.azure.com"
}

/*
if strings.Contains(refreshData, "client_credentials") && strings.Contains (refreshData, "azure") && !strings.Contains(refreshData, "resource="){
refreshData += "&resource=https://management.azure.com"
}
*/

log.Printf("[DEBUG] Oauth2 REFRESH DATA: %#v. URL: %#v", refreshData, tokenUrl)

Expand Down
19 changes: 11 additions & 8 deletions shared.go
Original file line number Diff line number Diff line change
Expand Up @@ -1685,7 +1685,6 @@ func AddAppAuthentication(resp http.ResponseWriter, request *http.Request) {
}

if !originalAuth.Active {

// Forcing it active
appAuth.Active = true

Expand All @@ -1704,7 +1703,7 @@ func AddAppAuthentication(resp http.ResponseWriter, request *http.Request) {
return
}

if appAuth.Type != "oauth2" && appAuth.Type != "oauth" && appAuth.Type != "oauth2-app" {
//if appAuth.Type != "oauth2" && appAuth.Type != "oauth" && appAuth.Type != "oauth2-app" {
for fieldIndex, field := range appAuth.Fields {
if !strings.Contains(field.Value, "Secret. Replaced") {
continue
Expand Down Expand Up @@ -1779,8 +1778,8 @@ func AddAppAuthentication(resp http.ResponseWriter, request *http.Request) {

// Setting this to ensure that any new config is encrypted anew
appAuth.Encrypted = false
} else {
}
//} else {
//}
} else {
// ID sometimes used in creation as well

Expand Down Expand Up @@ -20495,10 +20494,14 @@ func PrepareWorkflowExecution(ctx context.Context, workflow Workflow, request *h
parsedKey := fmt.Sprintf("%s_%d_%s_%s", curAuth.OrgId, curAuth.Created, curAuth.Label, field.Key)
newValue, err := HandleKeyDecryption([]byte(field.Value), parsedKey)
if err != nil {
log.Printf("[ERROR] Failed decryption (3) in auth org %s for %s: %s. Auth label: %s", curAuth.OrgId, field.Key, err, curAuth.Label)
setField = false
//fieldLength = 0
break
if field.Key != "access_token" {
log.Printf("[ERROR] Failed decryption (3) in auth org %s for %s: %s. Auth label: %s", curAuth.OrgId, field.Key, err, curAuth.Label)
setField = false
//fieldLength = 0
break
} else {
continue
}
}

// Remove / at end of urls
Expand Down

0 comments on commit ce6e5b6

Please sign in to comment.