Example #1
0
func (s *authService) loadAuthSession(session sess.Session) (goth.Session, error) {
	marshalledAuth, ok := session.Get(s.Config.SessionKey).(string)
	if !ok {
		return nil, errors.New("No auth session found")
	}

	authSession, err := s.provider.UnmarshalSession(marshalledAuth)
	if err != nil {
		return nil, err
	}

	return authSession, nil
}
Example #2
0
func (s *authService) beginAuth(res http.ResponseWriter, req *http.Request, session sess.Session) {
	authSession, err := s.provider.BeginAuth(getState(req))
	if err != nil {
		log.Error(fmt.Sprintf("Error creating auth session: %v", err))
		return
	}
	session.Save(s.Config.SessionKey, authSession.Marshal())

	url, err := authSession.GetAuthURL()
	if err != nil {
		log.Error(fmt.Sprintf("Could not get Auth URL: %v", err))
	}

	http.Redirect(res, req, url, http.StatusTemporaryRedirect)
}
Example #3
0
func (s *authService) saveAuthSession(session sess.Session, authSession goth.Session) {
	session.Save(s.Config.SessionKey, authSession.Marshal())
}