mirror of
https://github.com/documize/community.git
synced 2025-08-09 23:45:28 +02:00
github config from table
This commit is contained in:
parent
3d79cdd95e
commit
768bedb701
2 changed files with 14 additions and 9 deletions
|
@ -33,9 +33,4 @@ func (*github) Meta() TypeMeta {
|
||||||
|
|
||||||
func init() {
|
func init() {
|
||||||
sectionsMap["github"] = &github{}
|
sectionsMap["github"] = &github{}
|
||||||
|
|
||||||
// TODO make both soft and alterable at runtime
|
|
||||||
gh.ClientID = "8574d0c34142dcdc53f6"
|
|
||||||
gh.ClientSecret = "628e04d1575e234fbf477ff7b5f7dbfc95074c9e"
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -23,13 +23,23 @@ import (
|
||||||
"strings"
|
"strings"
|
||||||
|
|
||||||
"github.com/documize/community/wordsmith/log"
|
"github.com/documize/community/wordsmith/log"
|
||||||
|
"github.com/documize/community/documize/api/request"
|
||||||
|
|
||||||
// vendored locally
|
|
||||||
gogithub "github.com/google/go-github/github"
|
gogithub "github.com/google/go-github/github"
|
||||||
"golang.org/x/oauth2"
|
"golang.org/x/oauth2"
|
||||||
)
|
)
|
||||||
|
|
||||||
var ClientID, ClientSecret string
|
const configKey = "SECTION-GITHUB"
|
||||||
|
|
||||||
|
func clientID() string{
|
||||||
|
return request.ConfigString(configKey,"clientID")
|
||||||
|
}
|
||||||
|
func clientSecret() string{
|
||||||
|
return request.ConfigString(configKey,"clientSecret")
|
||||||
|
}
|
||||||
|
func authorizationCallbackURL() string{
|
||||||
|
return request.ConfigString(configKey,"authorizationCallbackURL")
|
||||||
|
}
|
||||||
|
|
||||||
type GithubT struct {
|
type GithubT struct {
|
||||||
|
|
||||||
|
@ -458,8 +468,8 @@ func Callback(res http.ResponseWriter, req *http.Request) error {
|
||||||
state := req.URL.Query().Get("state")
|
state := req.URL.Query().Get("state")
|
||||||
|
|
||||||
ghurl := "https://github.com/login/oauth/access_token"
|
ghurl := "https://github.com/login/oauth/access_token"
|
||||||
vals := "client_id=" + ClientID
|
vals := "client_id=" + clientID()
|
||||||
vals += "&client_secret=" + ClientSecret
|
vals += "&client_secret=" + clientSecret()
|
||||||
vals += "&code=" + code
|
vals += "&code=" + code
|
||||||
vals += "&state=" + state
|
vals += "&state=" + state
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue