Skip to content

Commit 2a5e5cc

Browse files
Fix: hasura permissions
1 parent 28a55fb commit 2a5e5cc

File tree

2 files changed

+23
-1
lines changed

2 files changed

+23
-1
lines changed

hasura/api.go

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -162,3 +162,15 @@ func (api *API) CreateSelectPermissions(table, role string, perm Permission) err
162162
}
163163
return api.post("/v1/query", nil, req, nil)
164164
}
165+
166+
// DropSelectPermissions -
167+
func (api *API) DropSelectPermissions(table, role string) error {
168+
req := request{
169+
Type: "drop_select_permission",
170+
Args: map[string]interface{}{
171+
"table": table,
172+
"role": role,
173+
},
174+
}
175+
return api.post("/v1/query", nil, req, nil)
176+
}

hasura/hasura.go

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,6 @@ func Create(hasura config.Hasura, cfg config.Database, views []string, models ..
5353
if !ok {
5454
continue
5555
}
56-
5756
name := tableData["name"]
5857
if _, ok := tables[name.(string)]; !ok {
5958
dataTables = append(dataTables, table)
@@ -74,6 +73,17 @@ func Create(hasura config.Hasura, cfg config.Database, views []string, models ..
7473
return err
7574
}
7675
}
76+
if err := api.DropSelectPermissions(views[i], "user"); err != nil {
77+
return err
78+
}
79+
if err := api.CreateSelectPermissions(views[i], "user", Permission{
80+
Limit: hasura.RowsLimit,
81+
AllowAggs: hasura.EnableAggregations,
82+
Columns: "*",
83+
Filter: map[string]interface{}{},
84+
}); err != nil {
85+
return err
86+
}
7787
}
7888

7989
return nil

0 commit comments

Comments
 (0)