(c *gin.Context)
| 37 | } |
| 38 | |
| 39 | func userOAuthAuthorize(c *gin.Context) { |
| 40 | r := struct { |
| 41 | Provider string `json:"provider" form:"provider" uri:"provider" binding:"required"` |
| 42 | Callback string `json:"callback" form:"callback" binding:"omitempty,url"` |
| 43 | }{} |
| 44 | |
| 45 | _ = c.ShouldBindUri(&r) |
| 46 | |
| 47 | if err := c.ShouldBind(&r); err != nil { |
| 48 | _ = c.AbortWithError(http.StatusBadRequest, err) |
| 49 | return |
| 50 | } |
| 51 | |
| 52 | projectDB, err := getCurrentProjectDB(c) |
| 53 | if err != nil { |
| 54 | _ = c.AbortWithError(http.StatusForbidden, err) |
| 55 | return |
| 56 | } |
| 57 | |
| 58 | _, miscConfig, err := model.GetProjectMiscConfig(projectDB) |
| 59 | if err != nil || !miscConfig.IsEnabled() { |
| 60 | _ = c.AbortWithError(http.StatusForbidden, err) |
| 61 | return |
| 62 | } |
| 63 | |
| 64 | _, oauthConfig, err := model.GetProjectOAuthConfig(projectDB, r.Provider) |
| 65 | if err != nil { |
| 66 | _ = c.AbortWithError(http.StatusForbidden, err) |
| 67 | return |
| 68 | } |
| 69 | |
| 70 | if !oauthConfig.IsEnabled() { |
| 71 | _ = c.AbortWithError(http.StatusForbidden, errors.New("oauth provider disabled")) |
| 72 | return |
| 73 | } |
| 74 | |
| 75 | auth.HandleUserAuth( |
| 76 | c, |
| 77 | r.Provider, |
| 78 | oauthConfig.ClientID, |
| 79 | oauthConfig.ClientSecret, |
| 80 | r.Callback, |
| 81 | ) |
| 82 | } |
| 83 | |
| 84 | func userOAuthCallback(c *gin.Context) { |
| 85 | // cross tab communication to authorize |
nothing calls this directly
no test coverage detected