MCPcopy Create free account
hub / github.com/CovenantSQL/CovenantSQL / userOAuthAuthorize

Function userOAuthAuthorize

cmd/cql-proxy/api/user_oauth.go:39–82  ·  view source on GitHub ↗
(c *gin.Context)

Source from the content-addressed store, hash-verified

37}
38
39func 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
84func userOAuthCallback(c *gin.Context) {
85 // cross tab communication to authorize

Callers

nothing calls this directly

Calls 6

GetProjectMiscConfigFunction · 0.92
GetProjectOAuthConfigFunction · 0.92
HandleUserAuthFunction · 0.92
getCurrentProjectDBFunction · 0.85
NewMethod · 0.65
IsEnabledMethod · 0.45

Tested by

no test coverage detected