config.go 1.5 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758
  1. // Copyright 2020 The Gogs Authors. All rights reserved.
  2. // Use of this source code is governed by a MIT-style
  3. // license that can be found in the LICENSE file.
  4. package github
  5. import (
  6. "context"
  7. "crypto/tls"
  8. "net/http"
  9. "strings"
  10. "github.com/google/go-github/github"
  11. "github.com/pkg/errors"
  12. )
  13. // Config contains configuration for GitHub authentication.
  14. //
  15. // ⚠️ WARNING: Change to the field name must preserve the INI key name for backward compatibility.
  16. type Config struct {
  17. // the GitHub service endpoint, e.g. https://api.github.com/.
  18. APIEndpoint string
  19. SkipVerify bool
  20. }
  21. func (c *Config) doAuth(login, password string) (fullname, email, location, website string, err error) {
  22. tp := github.BasicAuthTransport{
  23. Username: strings.TrimSpace(login),
  24. Password: strings.TrimSpace(password),
  25. Transport: &http.Transport{
  26. TLSClientConfig: &tls.Config{InsecureSkipVerify: c.SkipVerify},
  27. },
  28. }
  29. client, err := github.NewEnterpriseClient(c.APIEndpoint, c.APIEndpoint, tp.Client())
  30. if err != nil {
  31. return "", "", "", "", errors.Wrap(err, "create new client")
  32. }
  33. user, _, err := client.Users.Get(context.Background(), "")
  34. if err != nil {
  35. return "", "", "", "", errors.Wrap(err, "get user info")
  36. }
  37. if user.Name != nil {
  38. fullname = *user.Name
  39. }
  40. if user.Email != nil {
  41. email = *user.Email
  42. } else {
  43. email = login + "+github@local"
  44. }
  45. if user.Location != nil {
  46. location = strings.ToUpper(*user.Location)
  47. }
  48. if user.HTMLURL != nil {
  49. website = strings.ToLower(*user.HTMLURL)
  50. }
  51. return fullname, email, location, website, nil
  52. }
PANIC: session(release): write data/sessions/a/7/a72298625392ab0b: no space left on device

PANIC

session(release): write data/sessions/a/7/a72298625392ab0b: no space left on device
github.com/go-macaron/session@v0.0.0-20190805070824-1a3cdc6f5659/session.go:199 (0x8b2934)
gopkg.in/macaron.v1@v1.3.9/context.go:79 (0x83d0a0)
github.com/go-macaron/inject@v0.0.0-20160627170012-d8a0b8677191/inject.go:157 (0x80ab07)
github.com/go-macaron/inject@v0.0.0-20160627170012-d8a0b8677191/inject.go:135 (0x80a8a8)
gopkg.in/macaron.v1@v1.3.9/context.go:121 (0x83d1f8)
gopkg.in/macaron.v1@v1.3.9/context.go:112 (0x84fdb5)
gopkg.in/macaron.v1@v1.3.9/recovery.go:161 (0x84fda8)
gopkg.in/macaron.v1@v1.3.9/logger.go:40 (0x840c73)
github.com/go-macaron/inject@v0.0.0-20160627170012-d8a0b8677191/inject.go:157 (0x80ab07)
github.com/go-macaron/inject@v0.0.0-20160627170012-d8a0b8677191/inject.go:135 (0x80a8a8)
gopkg.in/macaron.v1@v1.3.9/context.go:121 (0x83d1f8)
gopkg.in/macaron.v1@v1.3.9/router.go:187 (0x850fc6)
gopkg.in/macaron.v1@v1.3.9/router.go:303 (0x8493e5)
gopkg.in/macaron.v1@v1.3.9/macaron.go:220 (0x841fca)
net/http/server.go:2836 (0x7a79b2)
net/http/server.go:1924 (0x7a341b)
runtime/asm_amd64.s:1373 (0x46f9f0)