-
Notifications
You must be signed in to change notification settings - Fork 28
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Signed-off-by: mqf20 <mingqingfoo@gmail.com>
- Loading branch information
Showing
32 changed files
with
600 additions
and
532 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,36 +1,36 @@ | ||
package entitystore | ||
|
||
import ( | ||
"github.com/cedar-policy/cedar-go" | ||
"github.com/cedar-policy/cedar-go/types" | ||
) | ||
|
||
// AsEntities converts EntityStore's native objects into cedar.Entities, to be passed to the Cedar authorization engine | ||
// AsEntities converts EntityStore's native objects into types.Entities, to be passed to the Cedar authorization engine | ||
// when it evaluates a request. | ||
func (e *EntityStore) AsEntities() (cedar.Entities, error) { | ||
func (e *EntityStore) AsEntities() (types.Entities, error) { | ||
|
||
es := make(cedar.Entities) | ||
es := make(types.Entities) | ||
|
||
// process users | ||
|
||
for _, user := range e.Users { | ||
es[user.EUID.EntityUID.EntityUID] = *user.AsCedarEntity() | ||
es[user.EUID.EntityUID.EntityUID] = user.AsCedarEntity() | ||
} | ||
|
||
// process teams | ||
|
||
for _, team := range e.Teams { | ||
es[team.UID.EntityUID.EntityUID] = *team.AsCedarEntity() | ||
es[team.UID.EntityUID.EntityUID] = team.AsCedarEntity() | ||
} | ||
|
||
// process lists | ||
|
||
for _, list := range e.Lists { | ||
es[list.UID.EntityUID.EntityUID] = *list.AsCedarEntity() | ||
es[list.UID.EntityUID.EntityUID] = list.AsCedarEntity() | ||
} | ||
|
||
// process application | ||
|
||
es[e.App.EUID.EntityUID] = *e.App.AsCedarEntity() | ||
es[e.App.EUID.EntityUID] = e.App.AsCedarEntity() | ||
|
||
return es, nil | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
21 changes: 21 additions & 0 deletions
21
tinytodo-go/internal/app/server/entitystore/entity/app/app.go
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
package app | ||
|
||
import ( | ||
"github.com/cedar-policy/cedar-examples/tinytodo-go/internal/app/server/entitystore/entityuid" | ||
"github.com/cedar-policy/cedar-go/types" | ||
) | ||
|
||
// App represents the application entity (in this case, TinyTodo). | ||
type App struct { | ||
EUID entityuid.EntityUID `json:"euid"` | ||
} | ||
|
||
// AsCedarEntity converts App into a types.Entity, to be passed to the Cedar authorization engine when it evaluates a | ||
// request. | ||
func (a *App) AsCedarEntity() *types.Entity { | ||
return &types.Entity{ | ||
UID: a.EUID.EntityUID, | ||
//Parents: nil, | ||
//Attributes: nil, | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
package entity | ||
|
||
import ( | ||
"github.com/cedar-policy/cedar-go/types" | ||
) | ||
|
||
type Entity interface { | ||
AsCedarEntity() *types.Entity | ||
} |
Oops, something went wrong.