当前位置: 首页>>代码示例>>Golang>>正文


Golang handlers.NewRedirectGrant函数代码示例

本文整理汇总了Golang中github.com/openshift/origin/pkg/auth/oauth/handlers.NewRedirectGrant函数的典型用法代码示例。如果您正苦于以下问题:Golang NewRedirectGrant函数的具体用法?Golang NewRedirectGrant怎么用?Golang NewRedirectGrant使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。


在下文中一共展示了NewRedirectGrant函数的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Golang代码示例。

示例1: getGrantHandler

// getGrantHandler returns the object that handles approving or rejecting grant requests
func (c *AuthConfig) getGrantHandler(mux cmdutil.Mux, auth authenticator.Request, clientregistry clientregistry.Getter, authregistry clientauthregistry.Registry) handlers.GrantHandler {
	startGrantServer := false

	var saGrantHandler handlers.GrantHandler
	switch c.Options.GrantConfig.ServiceAccountMethod {
	case configapi.GrantHandlerDeny:
		saGrantHandler = handlers.NewEmptyGrant()
	case configapi.GrantHandlerPrompt:
		startGrantServer = true
		saGrantHandler = handlers.NewRedirectGrant(OpenShiftApprovePrefix)
	default:
		glog.Fatalf("No grant handler found that matches %v.  The oauth server cannot start!", c.Options.GrantConfig.ServiceAccountMethod)
	}

	var standardGrantHandler handlers.GrantHandler
	switch c.Options.GrantConfig.Method {
	case configapi.GrantHandlerDeny:
		standardGrantHandler = handlers.NewEmptyGrant()
	case configapi.GrantHandlerAuto:
		standardGrantHandler = handlers.NewAutoGrant()
	case configapi.GrantHandlerPrompt:
		startGrantServer = true
		standardGrantHandler = handlers.NewRedirectGrant(OpenShiftApprovePrefix)
	default:
		glog.Fatalf("No grant handler found that matches %v.  The oauth server cannot start!", c.Options.GrantConfig.Method)
	}

	if startGrantServer {
		grantServer := grant.NewGrant(c.getCSRF(), auth, grant.DefaultFormRenderer, clientregistry, authregistry)
		grantServer.Install(mux, OpenShiftApprovePrefix)
	}

	return handlers.NewServiceAccountAwareGrant(standardGrantHandler, saGrantHandler)
}
开发者ID:ZenoRewn,项目名称:origin,代码行数:35,代码来源:auth.go

示例2: getGrantHandler

// getGrantHandler returns the object that handles approving or rejecting grant requests
func (c *AuthConfig) getGrantHandler(mux cmdutil.Mux, auth authenticator.Request, clientregistry clientregistry.Getter, authregistry clientauthregistry.Registry) handlers.GrantHandler {
	// check that the global default strategy is something we honor
	if !configapi.ValidGrantHandlerTypes.Has(string(c.Options.GrantConfig.Method)) {
		glog.Fatalf("No grant handler found that matches %v.  The OAuth server cannot start!", c.Options.GrantConfig.Method)
	}

	// Since any OAuth client could require prompting, we will unconditionally
	// start the GrantServer here.
	grantServer := grant.NewGrant(c.getCSRF(), auth, grant.DefaultFormRenderer, clientregistry, authregistry)
	grantServer.Install(mux, OpenShiftApprovePrefix)

	// Set defaults for standard clients. These can be overridden.
	return handlers.NewPerClientGrant(handlers.NewRedirectGrant(OpenShiftApprovePrefix),
		oauthapi.GrantHandlerType(c.Options.GrantConfig.Method))
}
开发者ID:abhgupta,项目名称:origin,代码行数:16,代码来源:auth.go

示例3: getGrantHandler

// getGrantHandler returns the object that handles approving or rejecting grant requests
func (c *AuthConfig) getGrantHandler(mux cmdutil.Mux, auth authenticator.Request, clientregistry clientregistry.Registry, authregistry clientauthregistry.Registry) handlers.GrantHandler {
	switch c.Options.GrantConfig.Method {
	case configapi.GrantHandlerDeny:
		return handlers.NewEmptyGrant()

	case configapi.GrantHandlerAuto:
		return handlers.NewAutoGrant()

	case configapi.GrantHandlerPrompt:
		grantServer := grant.NewGrant(c.getCSRF(), auth, grant.DefaultFormRenderer, clientregistry, authregistry)
		grantServer.Install(mux, OpenShiftApprovePrefix)
		return handlers.NewRedirectGrant(OpenShiftApprovePrefix)

	default:
		glog.Fatalf("No grant handler found that matches %v.  The oauth server cannot start!", c.Options.GrantConfig.Method)
	}

	return nil
}
开发者ID:redlocal,项目名称:origin,代码行数:20,代码来源:auth.go


注:本文中的github.com/openshift/origin/pkg/auth/oauth/handlers.NewRedirectGrant函数示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。