(parentHandler *Handler, r *mux.Router, app *App)
| 275 | } |
| 276 | |
| 277 | func 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 | |
| 309 | func configureOauthRoutes(parentHandler *Handler, r *mux.Router, app *App, oauthClient oauthClient, callbackProxy *callbackProxyClient) { |
| 310 | handler := &oauthHandler{ |
no test coverage detected