MCPcopy
hub / github.com/writefreely/writefreely / configureGiteaOauth

Function configureGiteaOauth

oauth.go:277–307  ·  view source on GitHub ↗
(parentHandler *Handler, r *mux.Router, app *App)

Source from the content-addressed store, hash-verified

275}
276
277func configureGiteaOauth(parentHandler *Handler, r *mux.Router, app *App) {
278 if app.Config().GiteaOauth.ClientID != "" {
279 callbackLocation := app.Config().App.Host + "/oauth/callback/gitea"
280
281 var callbackProxy *callbackProxyClient = nil
282 if app.Config().GiteaOauth.CallbackProxy != "" {
283 callbackProxy = &callbackProxyClient{
284 server: app.Config().GiteaOauth.CallbackProxyAPI,
285 callbackLocation: app.Config().App.Host + "/oauth/callback/gitea",
286 httpClient: config.DefaultHTTPClient(),
287 }
288 callbackLocation = app.Config().GiteaOauth.CallbackProxy
289 }
290
291 oauthClient := giteaOauthClient{
292 ClientID: app.Config().GiteaOauth.ClientID,
293 ClientSecret: app.Config().GiteaOauth.ClientSecret,
294 ExchangeLocation: app.Config().GiteaOauth.Host + "/login/oauth/access_token",
295 InspectLocation: app.Config().GiteaOauth.Host + "/login/oauth/userinfo",
296 AuthLocation: app.Config().GiteaOauth.Host + "/login/oauth/authorize",
297 HttpClient: config.DefaultHTTPClient(),
298 CallbackLocation: callbackLocation,
299 Scope: "openid profile email",
300 MapUserID: "sub",
301 MapUsername: "login",
302 MapDisplayName: "full_name",
303 MapEmail: "email",
304 }
305 configureOauthRoutes(parentHandler, r, app, oauthClient, callbackProxy)
306 }
307}
308
309func configureOauthRoutes(parentHandler *Handler, r *mux.Router, app *App, oauthClient oauthClient, callbackProxy *callbackProxyClient) {
310 handler := &oauthHandler{

Callers 1

InitRoutesFunction · 0.85

Calls 3

DefaultHTTPClientFunction · 0.92
configureOauthRoutesFunction · 0.85
ConfigMethod · 0.65

Tested by

no test coverage detected