當前位置: 首頁>>代碼示例>>Golang>>正文


Golang AuthorizeRequest.UserData方法代碼示例

本文整理匯總了Golang中github.com/RangelReale/osin.AuthorizeRequest.UserData方法的典型用法代碼示例。如果您正苦於以下問題:Golang AuthorizeRequest.UserData方法的具體用法?Golang AuthorizeRequest.UserData怎麽用?Golang AuthorizeRequest.UserData使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在github.com/RangelReale/osin.AuthorizeRequest的用法示例。


在下文中一共展示了AuthorizeRequest.UserData方法的4個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Golang代碼示例。

示例1: handleLoginPage

func (o *OAuthHandler) handleLoginPage(ar *osin.AuthorizeRequest, w http.ResponseWriter, r *http.Request) bool {
	_ = "breakpoint"
	r.ParseForm()
	username := ""
	password := ""
	loginError := false
	if r.Method == "POST" {
		username = r.Form.Get("username")
		password = r.Form.Get("password")
		user, _ := userRepo.Login(username, password)
		ar.UserData = user
		loginError = (user == nil)
		if user != nil || loginError == false {
			return true
		}
		//return (user != nil)
	}
	page := &LoginPage{
		ResponseType: ar.Type,
		ClientId:     ar.Client.GetId(),
		State:        ar.State,
		RedirectUri:  url.QueryEscape(ar.RedirectUri),
		Username:     username,
		LoginError:   loginError,
	}
	renderLoginPage(w, page)
	return false
}
開發者ID:credli,項目名稱:finderserpmobility,代碼行數:28,代碼來源:oauth.go

示例2: inner_GET_authorize

func inner_GET_authorize(c martini.Context, sess sessions.Session, r *http.Request, ar *osin.AuthorizeRequest) bool {
	var (
		identity = ActiveIdentity(c)
		source   = current_url(r)
		handler  martini.Handler
	)

	if identity != nil {
		ar.UserData = identity
		sess.Delete("flow")
		return true
	} else {
		sess.Set("flow", FlowState{
			Type:    AuthorizeFlow,
			Source:  source,
			StartAt: time.Now(),
		})

		if provider := r.URL.Query().Get("p"); provider == "" {
			handler = show_provider_chooser()
		} else {
			handler = redirect_to_provider(provider)
		}
	}

	c.Invoke(handler)
	return false
}
開發者ID:rogeriomarques,項目名稱:oapx,代碼行數:28,代碼來源:flow.go

示例3: HandleAuthorize

// HandleAuthorize implements osinserver.AuthorizeHandler to ensure the AuthorizeRequest is authenticated.
// If the request is authenticated, UserData and Authorized are set and false is returned.
// If the request is not authenticated, the auth handler is called and the request is not authorized
func (h *AuthorizeAuthenticator) HandleAuthorize(ar *osin.AuthorizeRequest, w http.ResponseWriter) (bool, error) {
	info, ok, err := h.request.AuthenticateRequest(ar.HttpRequest)
	if err != nil {
		return h.errorHandler.AuthenticationError(err, w, ar.HttpRequest)
	}
	if !ok {
		return h.handler.AuthenticationNeeded(ar.Client, w, ar.HttpRequest)
	}
	ar.UserData = info
	ar.Authorized = true
	return false, nil
}
開發者ID:johnmccawley,項目名稱:origin,代碼行數:15,代碼來源:authenticator.go

示例4: HandleAuthorize

// HandleAuthorize implements osinserver.AuthorizeHandler to ensure the AuthorizeRequest is authenticated.
// If the request is authenticated, UserData and Authorized are set and false is returned.
// If the request is not authenticated, the auth handler is called and the request is not authorized
func (h *AuthorizeAuthenticator) HandleAuthorize(ar *osin.AuthorizeRequest, w http.ResponseWriter) (bool, error) {
	info, ok, err := h.request.AuthenticateRequest(ar.HttpRequest)
	if err != nil {
		glog.V(4).Infof("OAuth authentication error: %v", err)
		return h.errorHandler.AuthenticationError(err, w, ar.HttpRequest)
	}
	if !ok {
		return h.handler.AuthenticationNeeded(ar.Client, w, ar.HttpRequest)
	}
	glog.V(4).Infof("OAuth authentication succeeded: %#v", info)
	ar.UserData = info
	ar.Authorized = true
	return false, nil
}
開發者ID:RomainVabre,項目名稱:origin,代碼行數:17,代碼來源:authenticator.go


注:本文中的github.com/RangelReale/osin.AuthorizeRequest.UserData方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。