本文整理匯總了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
}
示例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
}
示例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
}
示例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
}