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


Golang common.User類代碼示例

本文整理匯總了Golang中common.User的典型用法代碼示例。如果您正苦於以下問題:Golang User類的具體用法?Golang User怎麽用?Golang User使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。


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

示例1: AuthorizeDeleteClusterAdmin

func (self *Permissions) AuthorizeDeleteClusterAdmin(user common.User) (ok bool, err common.AuthorizationError) {
	if !user.IsClusterAdmin() {
		return false, common.NewAuthorizationError("Insufficient permissions to delete cluster admin")
	}

	return true, ""
}
開發者ID:hanshenu,項目名稱:influxdb,代碼行數:7,代碼來源:permissions.go

示例2: ChangeDbUserPermissions

func (self *CoordinatorImpl) ChangeDbUserPermissions(requester common.User, db, username, readPermissions, writePermissions string) error {
	if !requester.IsClusterAdmin() && !requester.IsDbAdmin(db) {
		return common.NewAuthorizationError("Insufficient permissions")
	}

	return self.raftServer.ChangeDbUserPermissions(db, username, readPermissions, writePermissions)
}
開發者ID:qz267,項目名稱:influxdb,代碼行數:7,代碼來源:coordinator.go

示例3: AuthorizeDeleteQuery

func (self *Permissions) AuthorizeDeleteQuery(user common.User, db string) (ok bool, err common.AuthorizationError) {
	if !user.IsDbAdmin(db) {
		return false, common.NewAuthorizationError("Insufficient permission to write to %s", db)
	}

	return true, ""
}
開發者ID:hanshenu,項目名稱:influxdb,代碼行數:7,代碼來源:permissions.go

示例4: ListClusterAdmins

func (self *CoordinatorImpl) ListClusterAdmins(requester common.User) ([]string, error) {
	if !requester.IsClusterAdmin() {
		return nil, common.NewAuthorizationError("Insufficient permissions")
	}

	return self.clusterConfiguration.GetClusterAdmins(), nil
}
開發者ID:qz267,項目名稱:influxdb,代碼行數:7,代碼來源:coordinator.go

示例5: WriteSeriesData

func (self *CoordinatorImpl) WriteSeriesData(user common.User, db string, series []*protocol.Series) error {
	// make sure that the db exist
	if !self.clusterConfiguration.DatabasesExists(db) {
		return fmt.Errorf("Database %s doesn't exist", db)
	}

	for _, s := range series {
		seriesName := s.GetName()
		if user.HasWriteAccess(seriesName) {
			continue
		}
		return common.NewAuthorizationError("User %s doesn't have write permissions for %s", user.GetName(), seriesName)
	}

	err := self.CommitSeriesData(db, series, false)
	if err != nil {
		return err
	}

	for _, s := range series {
		self.ProcessContinuousQueries(db, s)
	}

	return err
}
開發者ID:hanshenu,項目名稱:influxdb,代碼行數:25,代碼來源:coordinator.go

示例6: DropDatabase

func (self *CoordinatorImpl) DropDatabase(user common.User, db string) error {
	if !user.IsClusterAdmin() {
		return common.NewAuthorizationError("Insufficient permission to drop database")
	}

	if self.clusterConfiguration.IsSingleServer() {
		if err := self.datastore.DropDatabase(db); err != nil {
			return err
		}
	} else {
		servers, _ := self.clusterConfiguration.GetServersToMakeQueryTo(&db)
		for _, server := range servers {
			if err := self.handleDropDatabase(server.server, db); err != nil {
				return err
			}
		}
	}

	// don't delete the metadata, we need the replication factor to be
	// able to replicate the request properly
	if err := self.raftServer.DropDatabase(db); err != nil {
		return err
	}

	return nil
}
開發者ID:schmurfy,項目名稱:influxdb,代碼行數:26,代碼來源:coordinator.go

示例7: ForceCompaction

func (self *CoordinatorImpl) ForceCompaction(user common.User) error {
	if !user.IsClusterAdmin() {
		return fmt.Errorf("Insufficient permissions to force a log compaction")
	}

	return self.raftServer.ForceLogCompaction()
}
開發者ID:qz267,項目名稱:influxdb,代碼行數:7,代碼來源:coordinator.go

示例8: ExecuteQuery

func (self *LevelDbDatastore) ExecuteQuery(user common.User, database string,
	query *parser.SelectQuery, yield func(*protocol.Series) error,
	ringFilter func(database, series *string, time *int64) bool) error {

	seriesAndColumns := query.GetReferencedColumns()
	hasAccess := true
	for series, columns := range seriesAndColumns {
		if regex, ok := series.GetCompiledRegex(); ok {
			seriesNames := self.getSeriesForDbAndRegex(database, regex)
			for _, name := range seriesNames {
				if !user.HasReadAccess(name) {
					hasAccess = false
					continue
				}
				err := self.executeQueryForSeries(database, name, columns, query, yield, ringFilter)
				if err != nil {
					return err
				}
			}
		} else {
			if !user.HasReadAccess(series.Name) {
				hasAccess = false
				continue
			}
			err := self.executeQueryForSeries(database, series.Name, columns, query, yield, ringFilter)
			if err != nil {
				return err
			}
		}
	}
	if !hasAccess {
		return fmt.Errorf("You don't have permission to access one or more time series")
	}
	return nil
}
開發者ID:rn2dy,項目名稱:influxdb,代碼行數:35,代碼來源:leveldb_datastore.go

示例9: AuthorizeDropDatabase

func (self *Permissions) AuthorizeDropDatabase(user common.User) (ok bool, err common.AuthorizationError) {
	if !user.IsClusterAdmin() {
		return false, common.NewAuthorizationError("Insufficient permissions to drop database")
	}

	return true, ""
}
開發者ID:hanshenu,項目名稱:influxdb,代碼行數:7,代碼來源:permissions.go

示例10: ListDbUsers

func (self *CoordinatorImpl) ListDbUsers(requester common.User, db string) ([]common.User, error) {
	if !requester.IsClusterAdmin() && !requester.IsDbAdmin(db) {
		return nil, common.NewAuthorizationError("Insufficient permissions")
	}

	return self.clusterConfiguration.GetDbUsers(db), nil
}
開發者ID:qz267,項目名稱:influxdb,代碼行數:7,代碼來源:coordinator.go

示例11: AuthorizeDropSeries

func (self *Permissions) AuthorizeDropSeries(user common.User, db string, seriesName string) (ok bool, err common.AuthorizationError) {
	if !user.IsDbAdmin(db) && !user.HasWriteAccess(seriesName) {
		return false, common.NewAuthorizationError("Insufficient permissions to drop series")
	}

	return true, ""
}
開發者ID:hanshenu,項目名稱:influxdb,代碼行數:7,代碼來源:permissions.go

示例12: AuthorizeListContinuousQueries

func (self *Permissions) AuthorizeListContinuousQueries(user common.User, db string) (ok bool, err common.AuthorizationError) {
	if !user.IsDbAdmin(db) {
		return false, common.NewAuthorizationError("Insufficient permissions to list continuous queries")
	}

	return true, ""
}
開發者ID:hanshenu,項目名稱:influxdb,代碼行數:7,代碼來源:permissions.go

示例13: AuthorizeChangeDbUserPermissions

func (self *Permissions) AuthorizeChangeDbUserPermissions(user common.User, db string) (ok bool, err common.AuthorizationError) {
	if !user.IsDbAdmin(db) {
		return false, common.NewAuthorizationError("Insufficient permissions to change db user permissions on %s", db)
	}

	return true, ""
}
開發者ID:hanshenu,項目名稱:influxdb,代碼行數:7,代碼來源:permissions.go

示例14: AuthorizeGrantDbUserAdmin

func (self *Permissions) AuthorizeGrantDbUserAdmin(user common.User, db string) (ok bool, err common.AuthorizationError) {
	if !user.IsDbAdmin(db) {
		return false, common.NewAuthorizationError("Insufficient permissions to grant db user admin privileges on %s", db)
	}

	return true, ""
}
開發者ID:hanshenu,項目名稱:influxdb,代碼行數:7,代碼來源:permissions.go

示例15: DropDatabase

func (self *CoordinatorImpl) DropDatabase(user common.User, db string) error {
	if !user.IsClusterAdmin() {
		return fmt.Errorf("Insufficient permission to drop database")
	}

	return self.raftServer.DropDatabase(db)
}
開發者ID:nvdnkpr,項目名稱:influxdb,代碼行數:7,代碼來源:coordinator.go


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