Beispiel #1
0
// 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)
}
Beispiel #2
0
// 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
}