added azure sign in

This commit is contained in:
0xdcarns
2021-10-22 15:07:45 -04:00
parent 36d60eba64
commit f39e16fbc9
4 changed files with 134 additions and 8 deletions

View File

@@ -26,7 +26,7 @@ type githubOauthUser struct {
AccessToken string `json:"accesstoken" bson:"accesstoken"`
}
// == handle google authentication here ==
// == handle github authentication here ==
func initGithub(redirectURL string, clientID string, clientSecret string) {
auth_provider = &oauth2.Config{
@@ -81,13 +81,13 @@ func handleGithubCallback(w http.ResponseWriter, r *http.Request) {
return
}
logic.Log("completed github oauth sigin in for "+content.Login, 0)
http.Redirect(w, r, servercfg.GetFrontendURL()+"?login="+jwt+"&email="+content.Login, http.StatusPermanentRedirect)
logic.Log("completed github OAuth sigin in for "+content.Login, 1)
http.Redirect(w, r, servercfg.GetFrontendURL()+"?login="+jwt+"&user="+content.Login, http.StatusPermanentRedirect)
}
func getGithubUserInfo(state string, code string) (*githubOauthUser, error) {
if state != oauth_state_string {
return nil, fmt.Errorf("invalid oauth state")
return nil, fmt.Errorf("invalid OAuth state")
}
var token, err = auth_provider.Exchange(oauth2.NoContext, code)
if err != nil {