Exemple #1
0
func createProject() {
	db := model.DB()
	project := model.Project{
		UUID: uuid.NewV4().String(),
	}
	db.Create(&project)

	fmt.Printf("Created a new project.\n")
	fmt.Printf("Project UUID - %s\n", project.UUID)
	fmt.Printf("Project Master Key - %s\n", project.MasterKey().Value)
	fmt.Printf("Project Read Key - %s\n", project.ReadKey().Value)
	fmt.Printf("Project Write Key - %s\n", project.WriteKey().Value)
}
Exemple #2
0
func boundScope(project *model.Project, authKey string, scopes ...model.ApiScope) bool {
	ok := false

	for _, scope := range scopes {
		switch scope {
		case model.ApiReadKey:
			ok = (project.ReadKey().Value == authKey)
		case model.ApiWriteKey:
			ok = (project.WriteKey().Value == authKey)
		case model.ApiMasterKey:
			ok = (project.MasterKey().Value == authKey)
		}

		if ok {
			return ok
		}
	}

	return ok
}