• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

Golang common.NewAuthorizationError函数代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

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



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

示例1: AuthenticateClusterAdmin

func (self *ClusterConfiguration) AuthenticateClusterAdmin(username, password string) (common.User, error) {
	user := self.clusterAdmins[username]
	if user == nil {
		return nil, common.NewAuthorizationError("Invalid username/password")
	}
	if user.isValidPwd(password) {
		return user, nil
	}
	return nil, common.NewAuthorizationError("Invalid username/password")
}
开发者ID:Wikia,项目名称:influxdb,代码行数:10,代码来源:cluster_configuration.go


示例2: AuthenticateDbUser

func (self *ClusterConfiguration) AuthenticateDbUser(db, username, password string) (common.User, error) {
	dbUsers := self.dbUsers[db]
	if dbUsers == nil || dbUsers[username] == nil {
		return nil, common.NewAuthorizationError("Invalid username/password")
	}
	user := dbUsers[username]
	if user.isValidPwd(password) {
		return user, nil
	}
	return nil, common.NewAuthorizationError("Invalid username/password")
}
开发者ID:Wikia,项目名称:influxdb,代码行数:11,代码来源:cluster_configuration.go


示例3: 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:Wikia,项目名称:influxdb,代码行数:7,代码来源:permissions.go


示例4: AuthorizeDropSeries

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

	return true, ""
}
开发者ID:Wikia,项目名称:influxdb,代码行数:7,代码来源:permissions.go


示例5: AuthorizeDeleteContinuousQuery

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

	return true, ""
}
开发者ID:Wikia,项目名称:influxdb,代码行数:7,代码来源:permissions.go


示例6: 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:Wikia,项目名称:influxdb,代码行数:7,代码来源:permissions.go


示例7: 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:Wikia,项目名称:influxdb,代码行数:7,代码来源:permissions.go


示例8: 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:Wikia,项目名称:influxdb,代码行数:7,代码来源:permissions.go


示例9: AuthorizeChangeClusterAdminPassword

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

	return true, ""
}
开发者ID:Wikia,项目名称:influxdb,代码行数:7,代码来源:permissions.go


示例10: AuthorizeChangeDbUserPassword

func (self *Permissions) AuthorizeChangeDbUserPassword(user common.User, db string, targetUsername string) (ok bool, err common.AuthorizationError) {
	if !user.IsDbAdmin(db) && !(user.GetDb() == db && user.GetName() == targetUsername) {
		return false, common.NewAuthorizationError("Insufficient permissions to change db user password for %s on %s", targetUsername, db)
	}

	return true, ""
}
开发者ID:Wikia,项目名称:influxdb,代码行数:7,代码来源:permissions.go


示例11: 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:Wikia,项目名称:influxdb,代码行数:7,代码来源:permissions.go


示例12: WriteSeriesData

func (self *Coordinator) 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:Wikia,项目名称:influxdb,代码行数:25,代码来源:coordinator.go


示例13: AuthorizeListQueries

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

	return true, ""
}
开发者ID:Wikia,项目名称:influxdb,代码行数:7,代码来源:permissions.go


示例14: AuthorizeSelectQuery

func (self *Permissions) AuthorizeSelectQuery(user common.User, db string, querySpec *parser.QuerySpec) (ok bool, err common.AuthorizationError) {
	// if this isn't a regex query do the permission check here
	fromClause := querySpec.SelectQuery().GetFromClause()

	for _, n := range fromClause.Names {
		if _, ok := n.Name.GetCompiledRegex(); ok {
			break
		} else if name := n.Name.Name; !user.HasReadAccess(name) {
			return false, common.NewAuthorizationError("User doesn't have read access to %s", name)
		}
	}
	return true, ""
}
开发者ID:Wikia,项目名称:influxdb,代码行数:13,代码来源:permissions.go


示例15: TestAuthorizeGrantDbUserAdmin

func (self *PermissionsSuite) TestAuthorizeGrantDbUserAdmin(c *C) {
	var ok bool
	var err common.AuthorizationError

	authErr := common.NewAuthorizationError("Insufficient permissions to grant db user admin privileges on db")

	ok, err = self.permissions.AuthorizeGrantDbUserAdmin(self.commonUser, "db")
	c.Assert(ok, Equals, false)
	c.Assert(err, Equals, authErr)

	ok, _ = self.permissions.AuthorizeGrantDbUserAdmin(self.dbAdmin, "db")
	c.Assert(ok, Equals, true)

	ok, _ = self.permissions.AuthorizeGrantDbUserAdmin(self.clusterAdmin, "db")
	c.Assert(ok, Equals, true)
}
开发者ID:Wikia,项目名称:influxdb,代码行数:16,代码来源:permissions_test.go


示例16: TestAuthorizeListContinuousQueries

func (self *PermissionsSuite) TestAuthorizeListContinuousQueries(c *C) {
	var ok bool
	var err common.AuthorizationError

	authErr := common.NewAuthorizationError("Insufficient permissions to list continuous queries")

	ok, err = self.permissions.AuthorizeListContinuousQueries(self.commonUser, "db")
	c.Assert(ok, Equals, false)
	c.Assert(err, Equals, authErr)

	ok, _ = self.permissions.AuthorizeListContinuousQueries(self.dbAdmin, "db")
	c.Assert(ok, Equals, true)

	ok, _ = self.permissions.AuthorizeListContinuousQueries(self.clusterAdmin, "db")
	c.Assert(ok, Equals, true)
}
开发者ID:Wikia,项目名称:influxdb,代码行数:16,代码来源:permissions_test.go


示例17: TestAuthorizeChangeDbUserPermissions

func (self *PermissionsSuite) TestAuthorizeChangeDbUserPermissions(c *C) {
	var ok bool
	var err common.AuthorizationError

	authErr := common.NewAuthorizationError("Insufficient permissions to change db user permissions on db")

	ok, err = self.permissions.AuthorizeChangeDbUserPermissions(self.commonUser, "db")
	c.Assert(ok, Equals, false)
	c.Assert(err, Equals, authErr)

	ok, _ = self.permissions.AuthorizeChangeDbUserPermissions(self.dbAdmin, "db")
	c.Assert(ok, Equals, true)

	ok, _ = self.permissions.AuthorizeChangeDbUserPermissions(self.clusterAdmin, "db")
	c.Assert(ok, Equals, true)
}
开发者ID:Wikia,项目名称:influxdb,代码行数:16,代码来源:permissions_test.go


示例18: TestAuthorizeDeleteQuery

func (self *PermissionsSuite) TestAuthorizeDeleteQuery(c *C) {
	var ok bool
	var err common.AuthorizationError

	authErr := common.NewAuthorizationError("Insufficient permission to write to db")

	ok, err = self.permissions.AuthorizeDeleteQuery(self.commonUser, "db")
	c.Assert(ok, Equals, false)
	c.Assert(err, Equals, authErr)

	ok, _ = self.permissions.AuthorizeDeleteQuery(self.dbAdmin, "db")
	c.Assert(ok, Equals, true)

	ok, _ = self.permissions.AuthorizeDeleteQuery(self.clusterAdmin, "db")
	c.Assert(ok, Equals, true)
}
开发者ID:Wikia,项目名称:influxdb,代码行数:16,代码来源:permissions_test.go


示例19: TestAuthorizeDropDatabase

func (self *PermissionsSuite) TestAuthorizeDropDatabase(c *C) {
	var ok bool
	var err common.AuthorizationError

	authErr := common.NewAuthorizationError("Insufficient permissions to drop database")

	ok, err = self.permissions.AuthorizeDropDatabase(self.commonUser)
	c.Assert(ok, Equals, false)
	c.Assert(err, Equals, authErr)

	ok, _ = self.permissions.AuthorizeDropDatabase(self.dbAdmin)
	c.Assert(ok, Equals, false)
	c.Assert(err, Equals, authErr)

	ok, _ = self.permissions.AuthorizeDropDatabase(self.clusterAdmin)
	c.Assert(ok, Equals, true)
}
开发者ID:Wikia,项目名称:influxdb,代码行数:17,代码来源:permissions_test.go


示例20: TestAuthorizeChangeClusterAdminPassword

func (self *PermissionsSuite) TestAuthorizeChangeClusterAdminPassword(c *C) {
	var ok bool
	var err common.AuthorizationError

	authErr := common.NewAuthorizationError("Insufficient permissions to change cluster admin password")

	ok, err = self.permissions.AuthorizeChangeClusterAdminPassword(self.commonUser)
	c.Assert(ok, Equals, false)
	c.Assert(err, Equals, authErr)

	ok, _ = self.permissions.AuthorizeChangeClusterAdminPassword(self.dbAdmin)
	c.Assert(ok, Equals, false)
	c.Assert(err, Equals, authErr)

	ok, _ = self.permissions.AuthorizeChangeClusterAdminPassword(self.clusterAdmin)
	c.Assert(ok, Equals, true)
}
开发者ID:Wikia,项目名称:influxdb,代码行数:17,代码来源:permissions_test.go



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Golang common.User类代码示例发布时间:2022-05-28
下一篇:
Golang raft.Server类代码示例发布时间:2022-05-28
热门推荐
热门话题
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap