Skip to content

Commit

Permalink
Merge branch 'main' into SAC-29-Scrape-Clubs-By-Filters
Browse files Browse the repository at this point in the history
  • Loading branch information
michael-brennan2005 committed Feb 27, 2024
2 parents 00162dd + 6714fab commit 8934844
Show file tree
Hide file tree
Showing 68 changed files with 12,849 additions and 2,296 deletions.
1 change: 1 addition & 0 deletions .gitattributes
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
*.sql linguist-detectable=false
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -4,3 +4,4 @@ sac-cli
node_modules
.vscode
.trunk
.env.dev
17 changes: 8 additions & 9 deletions backend/go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ require (
github.com/garrettladley/mattress v0.3.2
github.com/go-playground/validator/v10 v10.18.0
github.com/goccy/go-json v0.10.2
github.com/gofiber/fiber/v2 v2.52.0
github.com/gofiber/fiber/v2 v2.52.1
github.com/gofiber/swagger v1.0.0
github.com/golang-jwt/jwt v3.2.2+incompatible
github.com/google/uuid v1.6.0
Expand All @@ -26,20 +26,20 @@ require (
github.com/awnumar/memcall v0.2.0 // indirect
github.com/awnumar/memguard v0.22.4 // indirect
github.com/h2non/parth v0.0.0-20190131123155-b4df798d6542 // indirect
github.com/philhofer/fwd v1.1.2 // indirect
github.com/tinylib/msgp v1.1.8 // indirect
)

require (
github.com/KyleBanks/depth v1.2.1 // indirect
github.com/PuerkitoBio/purell v1.1.1 // indirect
github.com/PuerkitoBio/urlesc v0.0.0-20170810143723-de5bf2ad4578 // indirect
github.com/andybalholm/brotli v1.0.5 // indirect
github.com/davecgh/go-spew v1.1.2-0.20180830191138-d8f796af33cc // indirect
github.com/fsnotify/fsnotify v1.7.0 // indirect
github.com/gabriel-vasile/mimetype v1.4.3 // indirect
github.com/go-openapi/jsonpointer v0.19.5 // indirect
github.com/go-openapi/jsonreference v0.19.6 // indirect
github.com/go-openapi/spec v0.20.4 // indirect
github.com/go-openapi/swag v0.19.15 // indirect
github.com/go-openapi/jsonpointer v0.20.2 // indirect
github.com/go-openapi/jsonreference v0.20.4 // indirect
github.com/go-openapi/spec v0.20.14 // indirect
github.com/go-openapi/swag v0.22.9 // indirect
github.com/go-playground/locales v0.14.1 // indirect
github.com/go-playground/universal-translator v0.18.1 // indirect
github.com/hashicorp/hcl v1.0.0 // indirect
Expand Down Expand Up @@ -76,8 +76,7 @@ require (
golang.org/x/exp v0.0.0-20230905200255-921286631fa9 // indirect
golang.org/x/net v0.21.0 // indirect
golang.org/x/sys v0.17.0 // indirect
golang.org/x/tools v0.13.0 // indirect
golang.org/x/tools v0.18.0 // indirect
gopkg.in/ini.v1 v1.67.0 // indirect
gopkg.in/yaml.v2 v2.4.0 // indirect
gopkg.in/yaml.v3 v3.0.1 // indirect
)
82 changes: 44 additions & 38 deletions backend/go.sum

Large diffs are not rendered by default.

118 changes: 63 additions & 55 deletions backend/src/auth/permissions.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,82 +5,90 @@ import "github.com/GenerateNU/sac/backend/src/models"
type Permission string

const (
UserReadAll Permission = "user:readAll"
UserRead Permission = "user:read"
UserWrite Permission = "user:write"
UserDelete Permission = "user:delete"
// User Management
UserRead Permission = "user:read"
UserWrite Permission = "user:write"
UserDelete Permission = "user:delete"
UserManageProfile Permission = "user:manage_profile"
UserReadAll Permission = "user:read_all"

TagReadAll Permission = "tag:readAll"
TagRead Permission = "tag:read"
TagWrite Permission = "tag:write"
TagCreate Permission = "tag:create"
TagDelete Permission = "tag:delete"
// Tag Management
TagRead Permission = "tag:read"
TagCreate Permission = "tag:create"
TagWrite Permission = "tag:write"
TagDelete Permission = "tag:delete"

ClubReadAll Permission = "club:readAll"
ClubRead Permission = "club:read"
ClubWrite Permission = "club:write"
ClubCreate Permission = "club:create"
ClubDelete Permission = "club:delete"
// Club Management
ClubRead Permission = "club:read"
ClubCreate Permission = "club:create"
ClubWrite Permission = "club:write"
ClubDelete Permission = "club:delete"
ClubManageMembers Permission = "club:manage_members"
ClubManageFollowers Permission = "club:manage_followers"

PointOfContactReadAll Permission = "pointOfContact:readAll"
PointOfContactRead Permission = "pointOfContact:read"
PointOfContactCreate Permission = "pointOfContact:create"
PointOfContactWrite Permission = "pointOfContact:write"
PointOfContactDelete Permission = "pointOfContact:delete"
// Point of Contact Management
PointOfContactRead Permission = "pointOfContact:read"
PointOfContactCreate Permission = "pointOfContact:create"
PointOfContactWrite Permission = "pointOfContact:write"
PointOfContactDelete Permission = "pointOfContact:delete"

CommentReadAll Permission = "comment:readAll"
CommentRead Permission = "comment:read"
CommentCreate Permission = "comment:create"
CommentWrite Permission = "comment:write"
CommentDelete Permission = "comment:delete"
// Comment Management
CommentRead Permission = "comment:read"
CommentCreate Permission = "comment:create"
CommentWrite Permission = "comment:write"
CommentDelete Permission = "comment:delete"

EventReadAll Permission = "event:readAll"
EventRead Permission = "event:read"
EventWrite Permission = "event:write"
EventCreate Permission = "event:create"
EventDelete Permission = "event:delete"
// Event Management
EventRead Permission = "event:read"
EventCreate Permission = "event:create"
EventWrite Permission = "event:write"
EventDelete Permission = "event:delete"
EventManageRSVPs Permission = "event:manage_rsvps"

ContactReadAll Permission = "contact:readAll"
ContactRead Permission = "contact:read"
ContactWrite Permission = "contact:write"
ContactCreate Permission = "contact:create"
ContactDelete Permission = "contact:delete"
// Contact Management
ContactRead Permission = "contact:read"
ContactCreate Permission = "contact:create"
ContactWrite Permission = "contact:write"
ContactDelete Permission = "contact:delete"

CategoryReadAll Permission = "category:readAll"
CategoryRead Permission = "category:read"
CategoryWrite Permission = "category:write"
CategoryCreate Permission = "category:create"
CategoryDelete Permission = "category:delete"
// Category Management
CategoryRead Permission = "category:read"
CategoryCreate Permission = "category:create"
CategoryWrite Permission = "category:write"
CategoryDelete Permission = "category:delete"

NotificationReadAll Permission = "notification:readAll"
NotificationRead Permission = "notification:read"
NotificationWrite Permission = "notification:write"
NotificationCreate Permission = "notification:create"
NotificationDelete Permission = "notification:delete"
// Notification Management
NotificationRead Permission = "notification:read"
NotificationCreate Permission = "notification:create"
NotificationWrite Permission = "notification:write"
NotificationDelete Permission = "notification:delete"

// Global Permissions (for convenience)
ReadAll Permission = "all:read"
CreateAll Permission = "all:create"
WriteAll Permission = "all:write"
DeleteAll Permission = "all:delete"
)

var rolePermissions = map[models.UserRole][]Permission{
models.Super: {
UserRead, UserReadAll, UserWrite, UserDelete,
UserRead, UserWrite, UserDelete, UserManageProfile, UserReadAll,
TagRead, TagCreate, TagWrite, TagDelete,
ClubRead, ClubCreate, ClubWrite, ClubDelete,
ClubRead, ClubCreate, ClubWrite, ClubDelete, ClubManageMembers, ClubManageFollowers,
PointOfContactRead, PointOfContactCreate, PointOfContactWrite, PointOfContactDelete,
CommentRead, CommentCreate, CommentWrite, CommentDelete,
EventRead, EventCreate, EventWrite, EventDelete,
EventRead, EventCreate, EventWrite, EventDelete, EventManageRSVPs,
ContactRead, ContactCreate, ContactWrite, ContactDelete,
CategoryRead, CategoryCreate, CategoryWrite, CategoryDelete,
NotificationRead, NotificationCreate, NotificationWrite, NotificationDelete,
UserReadAll, TagReadAll, ClubReadAll, PointOfContactReadAll, CommentReadAll, EventReadAll, ContactReadAll, CategoryReadAll, NotificationReadAll,
ReadAll, CreateAll, WriteAll, DeleteAll,
},
models.Student: {
UserRead,
UserRead, UserManageProfile,
TagRead,
ClubRead,
PointOfContactRead,
CommentRead,
EventRead,
ContactRead,
CategoryRead,
ClubRead, EventRead,
CommentRead, CommentCreate,
ContactRead, PointOfContactRead,
NotificationRead,
},
}
Expand Down
4 changes: 2 additions & 2 deletions backend/src/config/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ const (
EnvironmentProduction Environment = "production"
)

func GetConfiguration(path string) (*Settings, error) {
func GetConfiguration(path string, useDevDotEnv bool) (*Settings, error) {
var environment Environment
if env := os.Getenv("APP_ENVIRONMENT"); env != "" {
environment = Environment(env)
Expand All @@ -66,7 +66,7 @@ func GetConfiguration(path string) (*Settings, error) {
v.AddConfigPath(path)

if environment == EnvironmentLocal {
return readLocal(v, path)
return readLocal(v, path, useDevDotEnv)
} else {
return readProd(v)
}
Expand Down
9 changes: 7 additions & 2 deletions backend/src/config/local.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import (
"github.com/spf13/viper"
)

func readLocal(v *viper.Viper, path string) (*Settings, error) {
func readLocal(v *viper.Viper, path string, useDevDotEnv bool) (*Settings, error) {
var intermediateSettings intermediateSettings

env := string(EnvironmentLocal)
Expand All @@ -27,7 +27,12 @@ func readLocal(v *viper.Viper, path string) (*Settings, error) {
return nil, fmt.Errorf("failed to convert intermediate settings into final settings: %w", err)
}

err = godotenv.Load(fmt.Sprintf("%s/.env.template", path))
if useDevDotEnv {
err = godotenv.Load(fmt.Sprintf("%s/.env.dev", path))
} else {
err = godotenv.Load(fmt.Sprintf("%s/.env.template", path))
}

if err != nil {
return nil, fmt.Errorf("failed to load %s/.env.template: %w", path, err)
}
Expand Down
Loading

0 comments on commit 8934844

Please sign in to comment.