Skip to content

Commit

Permalink
Made oauth2 translate to oauth2-app every time
Browse files Browse the repository at this point in the history
  • Loading branch information
frikky committed Mar 20, 2024
1 parent 2ccf572 commit f77d4cd
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 3 deletions.
4 changes: 4 additions & 0 deletions codegen.go
Original file line number Diff line number Diff line change
Expand Up @@ -1030,6 +1030,8 @@ func GenerateYaml(swagger *openapi3.Swagger, newmd5 string) (*openapi3.Swagger,
} else {
log.Printf("[DEBUG] Set up Oauth2 config for app %s during generation", api.Name)
api.Authentication.Type = "oauth2"


api.Authentication.RedirectUri = parsed.AuthorizationCode.AuthorizationUrl
api.Authentication.TokenUri = parsed.AuthorizationCode.TokenUrl
api.Authentication.RefreshUri = parsed.AuthorizationCode.RefreshUrl
Expand All @@ -1050,8 +1052,10 @@ func GenerateYaml(swagger *openapi3.Swagger, newmd5 string) (*openapi3.Swagger,
}

// November 2023: password & client_credentials
// Fix mar 2024: set type to oauth2-app
if len(newValue) > 0 {
api.Authentication.GrantType = newValue
api.Authentication.Type = "oauth2-app"
}

log.Printf("[DEBUG] Got special app build grant type: %s", newValue)
Expand Down
14 changes: 11 additions & 3 deletions shared.go
Original file line number Diff line number Diff line change
Expand Up @@ -591,6 +591,7 @@ func HandleGetOrg(resp http.ResponseWriter, request *http.Request) {
DeleteCache(ctx, fmt.Sprintf("%s_workflows", user.ActiveOrg.Id))
DeleteCache(ctx, fmt.Sprintf("%s_workflows", user.Id))
DeleteCache(ctx, fmt.Sprintf("apps_%s", user.Id))
DeleteCache(ctx, fmt.Sprintf("apps_%s", user.ActiveOrg.Id))
DeleteCache(ctx, fmt.Sprintf("user_%s", user.Username))
DeleteCache(ctx, fmt.Sprintf("user_%s", user.Id))
}
Expand Down Expand Up @@ -1005,6 +1006,7 @@ func HandleLogout(resp http.ResponseWriter, request *http.Request) {
DeleteCache(ctx, fmt.Sprintf("%s_workflows", userInfo.ActiveOrg.Id))
DeleteCache(ctx, fmt.Sprintf("%s_workflows", userInfo.Id))
DeleteCache(ctx, fmt.Sprintf("apps_%s", userInfo.Id))
DeleteCache(ctx, fmt.Sprintf("apps_%s", userInfo.ActiveOrg.Id))
DeleteCache(ctx, fmt.Sprintf("user_%s", strings.ToLower(userInfo.Username)))
DeleteCache(ctx, fmt.Sprintf("user_%s", userInfo.Id))
DeleteCache(ctx, fmt.Sprintf("session_%s", userInfo.Session))
Expand All @@ -1017,6 +1019,7 @@ func HandleLogout(resp http.ResponseWriter, request *http.Request) {
DeleteCache(ctx, fmt.Sprintf("%s_workflows", userInfo.ActiveOrg.Id))
DeleteCache(ctx, fmt.Sprintf("%s_workflows", userInfo.Id))
DeleteCache(ctx, fmt.Sprintf("apps_%s", userInfo.Id))
DeleteCache(ctx, fmt.Sprintf("apps_%s", userInfo.ActiveOrg.Id))
DeleteCache(ctx, fmt.Sprintf("user_%s", strings.ToLower(userInfo.Username)))
DeleteCache(ctx, fmt.Sprintf("user_%s", userInfo.Id))
DeleteCache(ctx, fmt.Sprintf("session_%s", userInfo.Session))
Expand Down Expand Up @@ -1076,6 +1079,7 @@ func HandleLogout(resp http.ResponseWriter, request *http.Request) {
DeleteCache(ctx, fmt.Sprintf("%s_workflows", userInfo.ActiveOrg.Id))
DeleteCache(ctx, fmt.Sprintf("%s_workflows", userInfo.Id))
DeleteCache(ctx, fmt.Sprintf("apps_%s", userInfo.Id))
DeleteCache(ctx, fmt.Sprintf("apps_%s", userInfo.ActiveOrg.Id))
if runReturn == true {
DeleteCache(ctx, fmt.Sprintf("user_%s", strings.ToLower(userInfo.Username)))
DeleteCache(ctx, fmt.Sprintf("session_%s", userInfo.Session))
Expand Down Expand Up @@ -1493,6 +1497,7 @@ func AddAppAuthentication(resp http.ResponseWriter, request *http.Request) {
log.Printf("[WARNING] Failed setting app %s for org %s during appauth", org.Id)
} else {
DeleteCache(ctx, fmt.Sprintf("apps_%s", user.Id))
DeleteCache(ctx, fmt.Sprintf("apps_%s", user.ActiveOrg.Id))
DeleteCache(ctx, fmt.Sprintf("workflowapps-sorted-100"))
DeleteCache(ctx, fmt.Sprintf("workflowapps-sorted-500"))
DeleteCache(ctx, fmt.Sprintf("workflowapps-sorted-1000"))
Expand Down Expand Up @@ -8119,6 +8124,7 @@ func HandleChangeUserOrg(resp http.ResponseWriter, request *http.Request) {
// Cleanup cache for the user
DeleteCache(ctx, fmt.Sprintf("%s_workflows", user.Id))
DeleteCache(ctx, fmt.Sprintf("apps_%s", user.Id))
DeleteCache(ctx, fmt.Sprintf("apps_%s", user.ActiveOrg.Id))
DeleteCache(ctx, fmt.Sprintf("user_%s", user.Username))
DeleteCache(ctx, fmt.Sprintf("user_%s", user.Id))
DeleteCache(ctx, fmt.Sprintf(user.ApiKey))
Expand Down Expand Up @@ -8170,6 +8176,7 @@ func HandleCreateSubOrg(resp http.ResponseWriter, request *http.Request) {
DeleteCache(ctx, fmt.Sprintf("user_%s", inneruser.Id))
DeleteCache(ctx, fmt.Sprintf("%s_workflows", inneruser.Id))
DeleteCache(ctx, fmt.Sprintf("apps_%s", inneruser.Id))
DeleteCache(ctx, fmt.Sprintf("apps_%s", inneruser.ActiveOrg.Id))
DeleteCache(ctx, fmt.Sprintf("user_%s", inneruser.Username))
DeleteCache(ctx, fmt.Sprintf("user_%s", inneruser.Id))
}
Expand Down Expand Up @@ -10029,6 +10036,7 @@ func HandleLogin(resp http.ResponseWriter, request *http.Request) {

DeleteCache(ctx, fmt.Sprintf("%s_workflows", userdata.Id))
DeleteCache(ctx, fmt.Sprintf("apps_%s", userdata.Id))
DeleteCache(ctx, fmt.Sprintf("apps_%s", userdata.ActiveOrg.Id))
DeleteCache(ctx, fmt.Sprintf("user_%s", userdata.Username))
DeleteCache(ctx, fmt.Sprintf("user_%s", userdata.Id))

Expand Down Expand Up @@ -12661,6 +12669,7 @@ func ActivateWorkflowApp(resp http.ResponseWriter, request *http.Request) {
} else {
log.Printf("[INFO] Added public app %s (%s) to org %s (%s)", app.Name, app.ID, user.ActiveOrg.Name, user.ActiveOrg.Id)
DeleteCache(ctx, fmt.Sprintf("apps_%s", user.Id))
DeleteCache(ctx, fmt.Sprintf("apps_%s", user.ActiveOrg.Id))
}
}
}
Expand Down Expand Up @@ -15732,6 +15741,7 @@ func HandleSSO(resp http.ResponseWriter, request *http.Request) {

DeleteCache(ctx, fmt.Sprintf("%s_workflows", user.Id))
DeleteCache(ctx, fmt.Sprintf("apps_%s", user.Id))
DeleteCache(ctx, fmt.Sprintf("apps_%s", user.ActiveOrg.Id))
DeleteCache(ctx, fmt.Sprintf("user_%s", user.Username))
DeleteCache(ctx, fmt.Sprintf("user_%s", user.Id))
}
Expand Down Expand Up @@ -22863,7 +22873,7 @@ func DistributeAppToEnvironments(ctx context.Context, org Org, appnames []string
continue
}

log.Printf("[DEBUG] Distributing app image %s to environment: %s\n\n", strings.Join(appnames, ", "), env.Name)
log.Printf("[DEBUG] Distributing app image %s to environment: %s", strings.Join(appnames, ", "), env.Name)

// Add to the queue
request := ExecutionRequest{
Expand All @@ -22879,8 +22889,6 @@ func DistributeAppToEnvironments(ctx context.Context, org Org, appnames []string
log.Printf("[ERROR] Failed setting workflow queue for env: %s", err)
continue
}

log.Printf("[DEBUG] Added image download to queue for env: %s", env.Name)
}

return nil
Expand Down

0 comments on commit f77d4cd

Please sign in to comment.