Exemplo n.º 1
0
func (s *AEServer) HandleToken(w http.ResponseWriter, r *http.Request) {
	c := appengine.NewContext(r)
	log.Infof(c, "HANDLE TOKEN")
	resp := s.server.NewResponse()
	defer resp.Close()
	if ar := s.server.HandleAccessRequest(c, resp, r); ar != nil {
		switch ar.Type {
		case osin.IMPLICIT:
			log.Infof(c, "Passing through IMPLICIT %v", ar)
			ar.Authorized = true
		case osin.AUTHORIZATION_CODE:
			log.Infof(c, "Passing through CODE %v", ar)
			ar.Authorized = true
		case osin.REFRESH_TOKEN:
			ar.Authorized = true
		case osin.PASSWORD:
			log.Infof(c, "VERIFYING PASSWORD")
			if s.verifyPassword(c, ar.Username, ar.Password) {
				ar.Authorized = true
			}
		case osin.CLIENT_CREDENTIALS:
			ar.Authorized = true
		}
		s.server.FinishAccessRequest(c, resp, r, ar)
	}
	if resp.IsError && resp.InternalError != nil {
		log.Errorf(c, "%v", resp.InternalError)
	}
	if !resp.IsError {
		resp.Output["custom_parameter"] = 236663
	}
	osin.OutputJSON(resp, w, r)
}
Exemplo n.º 2
0
//HandleAppAuthTokenInfo Called implicitly by Endpoints API to gather information about the user
//USAGE: /appauth/tokenInfo?access_token=<access_token>
func (s *AEServer) HandleAppAuthTokenInfo(w http.ResponseWriter, r *http.Request) {
	c := appengine.NewContext(r)
	resp := s.server.NewResponse()
	defer resp.Close()

	if ir := s.HandleTokenInfoRequest(c, resp, r); ir != nil {
		s.FinishTokenInfoRequest(c, resp, ir)
	}
	osin.OutputJSON(resp, w, r)
}
Exemplo n.º 3
0
//HandleAuthorize handles implicit authorization
//USAGE:http://localhost:8080/authorize?response_type=token&client_id=47bef51d-1b4a-4028-b4a1-07dfe3116a9b&state=xyz&scope=everything
func (s *AEServer) HandleAuthorize(w http.ResponseWriter, r *http.Request) {
	c := appengine.NewContext(r)
	resp := s.server.NewResponse()
	defer resp.Close()

	if ar := s.server.HandleAuthorizeRequest(c, resp, r); ar != nil {
		ar.Authorized = true
		s.server.FinishAuthorizeRequest(c, resp, r, ar)
	}
	if resp.IsError && resp.InternalError != nil {
		log.Errorf(c, "%v", resp.InternalError)
	}
	if !resp.IsError {
		resp.Output["custom_parameter"] = 4567890567
	}
	log.Infof(c, "AUTHORIZED")
	osin.OutputJSON(resp, w, r)
}