Make ClientID a constant
This commit is contained in:
parent
bc180ca8b3
commit
d8da433a6d
|
@ -37,6 +37,10 @@ import (
|
||||||
"github.com/pstuifzand/ekster/pkg/util"
|
"github.com/pstuifzand/ekster/pkg/util"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
const (
|
||||||
|
ClientID string = "https://p83.nl/microsub-client"
|
||||||
|
)
|
||||||
|
|
||||||
var (
|
var (
|
||||||
pool *redis.Pool
|
pool *redis.Pool
|
||||||
port int
|
port int
|
||||||
|
@ -62,7 +66,6 @@ type session struct {
|
||||||
Me string `redis:"me"`
|
Me string `redis:"me"`
|
||||||
RedirectURI string `redis:"redirect_uri"`
|
RedirectURI string `redis:"redirect_uri"`
|
||||||
State string `redis:"state"`
|
State string `redis:"state"`
|
||||||
ClientID string `redis:"client_id"`
|
|
||||||
LoggedIn bool `redis:"logged_in"`
|
LoggedIn bool `redis:"logged_in"`
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -182,10 +185,9 @@ func (h *mainHandler) ServeHTTP(w http.ResponseWriter, r *http.Request) {
|
||||||
|
|
||||||
reqData := url.Values{}
|
reqData := url.Values{}
|
||||||
reqData.Set("code", code)
|
reqData.Set("code", code)
|
||||||
reqData.Set("client_id", sess.ClientID)
|
reqData.Set("client_id", ClientID)
|
||||||
reqData.Set("redirect_uri", sess.RedirectURI)
|
reqData.Set("redirect_uri", sess.RedirectURI)
|
||||||
|
|
||||||
// resp, err := http.PostForm(sess.AuthorizationEndpoint, reqData)
|
|
||||||
req, err := http.NewRequest(http.MethodPost, sess.AuthorizationEndpoint, strings.NewReader(reqData.Encode()))
|
req, err := http.NewRequest(http.MethodPost, sess.AuthorizationEndpoint, strings.NewReader(reqData.Encode()))
|
||||||
if err != nil {
|
if err != nil {
|
||||||
fmt.Fprintf(w, "ERROR: %q\n", err)
|
fmt.Fprintf(w, "ERROR: %q\n", err)
|
||||||
|
@ -277,7 +279,6 @@ func (h *mainHandler) ServeHTTP(w http.ResponseWriter, r *http.Request) {
|
||||||
log.Println(authURL)
|
log.Println(authURL)
|
||||||
|
|
||||||
state := util.RandStringBytes(16)
|
state := util.RandStringBytes(16)
|
||||||
clientID := "https://p83.nl/microsub-client"
|
|
||||||
redirectURI := fmt.Sprintf("%s/auth/callback", os.Getenv("EKSTER_BASEURL"))
|
redirectURI := fmt.Sprintf("%s/auth/callback", os.Getenv("EKSTER_BASEURL"))
|
||||||
|
|
||||||
sess := session{
|
sess := session{
|
||||||
|
@ -285,7 +286,6 @@ func (h *mainHandler) ServeHTTP(w http.ResponseWriter, r *http.Request) {
|
||||||
Me: meURL.String(),
|
Me: meURL.String(),
|
||||||
State: state,
|
State: state,
|
||||||
RedirectURI: redirectURI,
|
RedirectURI: redirectURI,
|
||||||
ClientID: clientID,
|
|
||||||
LoggedIn: false,
|
LoggedIn: false,
|
||||||
}
|
}
|
||||||
saveSession(sessionVar, &sess, conn)
|
saveSession(sessionVar, &sess, conn)
|
||||||
|
@ -293,7 +293,7 @@ func (h *mainHandler) ServeHTTP(w http.ResponseWriter, r *http.Request) {
|
||||||
q := authURL.Query()
|
q := authURL.Query()
|
||||||
q.Add("response_type", "id")
|
q.Add("response_type", "id")
|
||||||
q.Add("me", meURL.String())
|
q.Add("me", meURL.String())
|
||||||
q.Add("client_id", clientID)
|
q.Add("client_id", ClientID)
|
||||||
q.Add("redirect_uri", redirectURI)
|
q.Add("redirect_uri", redirectURI)
|
||||||
q.Add("state", state)
|
q.Add("state", state)
|
||||||
authURL.RawQuery = q.Encode()
|
authURL.RawQuery = q.Encode()
|
||||||
|
|
Loading…
Reference in New Issue
Block a user