Compare commits

...

5 Commits

Author SHA1 Message Date
415d275e75 fix build docker
All checks were successful
continuous-integration/drone/push Build is passing
2019-09-11 17:59:07 +02:00
b68e4e364f fix repo
All checks were successful
continuous-integration/drone/push Build is passing
2019-09-11 17:51:08 +02:00
c6f4508b16 test Docker build
Some checks failed
continuous-integration/drone/push Build is failing
2019-09-11 17:42:26 +02:00
8affa39a68 Fix vet
All checks were successful
continuous-integration/drone/push Build is passing
2019-09-11 17:30:11 +02:00
43392b12bd fix lint 2019-09-11 17:30:11 +02:00
6 changed files with 27 additions and 6 deletions

View File

@ -25,12 +25,27 @@ steps:
commands:
- go vet ./...
- name: docker
image: plugins/docker
settings:
registry: reg.meutel.net
repo: reg.meutel.net/go-bouquins
username:
from_secret: registry_login
password:
from_secret: registry_password
auto_tag: true
when:
event:
- tag
trigger:
event:
- push
- tag
---
kind: signature
hmac: 663682f7b45c7f2629991785fc04170d60a0232719bac11d29620882ad857277
hmac: 0f5318785e361ab48470f37a93f15cb218f6f2a22dbdd2ec2f16298dd7577ada
...

View File

@ -493,6 +493,7 @@ func (app *Bouquins) IndexPage(res http.ResponseWriter, req *http.Request) error
return app.render(res, tplIndex, model)
}
// CalibreFileServer serves files from calibre path
func (app *Bouquins) CalibreFileServer() http.Handler {
calibre := app.Conf.CalibrePath
handler := http.StripPrefix(URLCalibre, http.FileServer(http.Dir(calibre)))

View File

@ -9,7 +9,7 @@ import (
"golang.org/x/oauth2"
)
// GithubProvider implements OAuth2 client with github.com
// GiteaProvider implements OAuth2 client with custom gitea server
type GiteaProvider string
type giteaProfile struct {
@ -61,7 +61,11 @@ func (p GiteaProvider) Config(conf *Conf) *oauth2.Config {
ClientID: c.ClientID,
ClientSecret: c.ClientSecret,
RedirectURL: conf.ExternalURL + "/callback",
Endpoint: oauth2.Endpoint{c.AuthURL, c.TokenURL, oauth2.AuthStyleAutoDetect},
Endpoint: oauth2.Endpoint{
AuthURL: c.AuthURL,
TokenURL: c.TokenURL,
AuthStyle: oauth2.AuthStyleAutoDetect,
},
}
}
}
@ -75,11 +79,11 @@ func (p GiteaProvider) GetUser(app *Bouquins, token *oauth2.Token) (string, erro
apiReq.Header.Add("Authorization", "token "+token.AccessToken)
client := &http.Client{}
response, err := client.Do(apiReq)
defer response.Body.Close()
if err != nil {
log.Println("Auth error", err)
return "", fmt.Errorf("Authentification error")
}
defer response.Body.Close()
dec := json.NewDecoder(response.Body)
var profile giteaProfile

View File

@ -61,11 +61,11 @@ func (p GithubProvider) GetUser(app *Bouquins, token *oauth2.Token) (string, err
apiReq.Header.Add("Authorization", "token "+token.AccessToken)
client := &http.Client{}
response, err := client.Do(apiReq)
defer response.Body.Close()
if err != nil {
log.Println("Auth error", err)
return "", fmt.Errorf("Authentification error")
}
defer response.Body.Close()
dec := json.NewDecoder(response.Body)
var emails []githubEmail

View File

@ -62,11 +62,11 @@ func (p GoogleProvider) Config(conf *Conf) *oauth2.Config {
// GetUser returns github primary email
func (p GoogleProvider) GetUser(app *Bouquins, token *oauth2.Token) (string, error) {
apiRes, err := http.Post("https://www.googleapis.com/oauth2/v2/tokeninfo?access_token="+token.AccessToken, "application/json", nil)
defer apiRes.Body.Close()
if err != nil {
log.Println("Auth error", err)
return "", fmt.Errorf("Authentification error")
}
defer apiRes.Body.Close()
dec := json.NewDecoder(apiRes.Body)
var tokenInfo googleTokenInfo
err = dec.Decode(&tokenInfo)

1
go.sum
View File

@ -16,6 +16,7 @@ golang.org/x/net v0.0.0-20180724234803-3673e40ba225/go.mod h1:mL1N/T3taQHkDXs73r
golang.org/x/net v0.0.0-20190108225652-1e06a53dbb7e h1:bRhVy7zSSasaqNksaRZiA5EEI+Ei4I1nO5Jh72wfHlg=
golang.org/x/net v0.0.0-20190108225652-1e06a53dbb7e/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4=
golang.org/x/net v0.0.0-20190311183353-d8887717615a/go.mod h1:t9HGtf8HONx5eT2rtn7q6eTqICYqUVnKs3thJo3Qplg=
golang.org/x/net v0.0.0-20190620200207-3b0461eec859 h1:R/3boaszxrf1GEUWTVDzSKVwLmSJpwZ1yqXm8j0v2QI=
golang.org/x/net v0.0.0-20190620200207-3b0461eec859/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s=
golang.org/x/oauth2 v0.0.0-20190604053449-0f29369cfe45 h1:SVwTIAaPC2U/AvvLNZ2a7OVsmBpC8L5BlwK1whH3hm0=
golang.org/x/oauth2 v0.0.0-20190604053449-0f29369cfe45/go.mod h1:gOpvHmFTYa4IltrdGE7lF6nIHvwfUNPOp7c8zoXwtLw=