summaryrefslogtreecommitdiff
path: root/app/domain
diff options
context:
space:
mode:
Diffstat (limited to 'app/domain')
-rw-r--r--app/domain/identifiable.go6
-rw-r--r--app/domain/sparkle.go8
-rw-r--r--app/domain/user.go13
3 files changed, 25 insertions, 2 deletions
diff --git a/app/domain/identifiable.go b/app/domain/identifiable.go
index 06bec07..190f20c 100644
--- a/app/domain/identifiable.go
+++ b/app/domain/identifiable.go
@@ -1,11 +1,15 @@
package domain
-import "github.com/xlgmokha/x/pkg/x"
+import (
+ v1 "github.com/authzed/authzed-go/proto/authzed/api/v1"
+ "github.com/xlgmokha/x/pkg/x"
+)
type Identifiable interface {
GetID() ID
SetID(id ID) error
ToGID() string
+ ToObjectReference() *v1.ObjectReference
}
func WithID[T Identifiable](id ID) x.Configure[T] {
diff --git a/app/domain/sparkle.go b/app/domain/sparkle.go
index d4f70b2..2ea5a53 100644
--- a/app/domain/sparkle.go
+++ b/app/domain/sparkle.go
@@ -4,6 +4,7 @@ import (
"errors"
"regexp"
+ v1 "github.com/authzed/authzed-go/proto/authzed/api/v1"
"gitlab.com/gitlab-org/software-supply-chain-security/authorization/sparkled/pkg/pls"
)
@@ -53,6 +54,13 @@ func (s *Sparkle) ToGID() string {
return "gid://sparkle/Sparkle/" + s.ID.String()
}
+func (self *Sparkle) ToObjectReference() *v1.ObjectReference {
+ return &v1.ObjectReference{
+ ObjectType: "sparkle",
+ ObjectId: self.ID.String(),
+ }
+}
+
func (s *Sparkle) Validate() error {
if s.Sparklee == "" {
return SparkleeIsRequired
diff --git a/app/domain/user.go b/app/domain/user.go
index 52cd780..88930c5 100644
--- a/app/domain/user.go
+++ b/app/domain/user.go
@@ -1,6 +1,9 @@
package domain
-import "github.com/xlgmokha/x/pkg/x"
+import (
+ v1 "github.com/authzed/authzed-go/proto/authzed/api/v1"
+ "github.com/xlgmokha/x/pkg/x"
+)
type User struct {
ID ID `json:"id" jsonapi:"primary,users"`
@@ -37,3 +40,11 @@ func (self *User) Sparkle(sparklee string, reason string) *Sparkle {
func (self *User) ToGID() string {
return "gid://sparkle/User/" + self.ID.String()
}
+
+func (self *User) ToObjectReference() *v1.ObjectReference {
+ // TODO:: Username is easy for demos but will need to change to ID
+ return &v1.ObjectReference{
+ ObjectType: "user",
+ ObjectId: self.Username,
+ }
+}