diff --git a/.idea/workspace.xml b/.idea/workspace.xml
index 252b80d..29e883c 100644
--- a/.idea/workspace.xml
+++ b/.idea/workspace.xml
@@ -4,11 +4,74 @@
-
+
+
-
-
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
@@ -80,11 +143,11 @@
+
-
@@ -155,7 +218,6 @@
-
@@ -180,20 +242,10 @@
-
+
+
true
-
-
-
-
- file://$PROJECT_DIR$/pkg/internal/services/ticket_token.go
- 105
-
-
-
-
-
\ No newline at end of file
diff --git a/pkg/internal/models/account_groups.go b/pkg/authkit/models/account_groups.go
similarity index 100%
rename from pkg/internal/models/account_groups.go
rename to pkg/authkit/models/account_groups.go
diff --git a/pkg/internal/models/accounts.go b/pkg/authkit/models/accounts.go
similarity index 100%
rename from pkg/internal/models/accounts.go
rename to pkg/authkit/models/accounts.go
diff --git a/pkg/internal/models/audit.go b/pkg/authkit/models/audit.go
similarity index 100%
rename from pkg/internal/models/audit.go
rename to pkg/authkit/models/audit.go
diff --git a/pkg/internal/models/auth.go b/pkg/authkit/models/auth.go
similarity index 100%
rename from pkg/internal/models/auth.go
rename to pkg/authkit/models/auth.go
diff --git a/pkg/internal/models/badges.go b/pkg/authkit/models/badges.go
similarity index 100%
rename from pkg/internal/models/badges.go
rename to pkg/authkit/models/badges.go
diff --git a/pkg/internal/models/base.go b/pkg/authkit/models/base.go
similarity index 100%
rename from pkg/internal/models/base.go
rename to pkg/authkit/models/base.go
diff --git a/pkg/internal/models/bot.go b/pkg/authkit/models/bot.go
similarity index 100%
rename from pkg/internal/models/bot.go
rename to pkg/authkit/models/bot.go
diff --git a/pkg/internal/models/clients.go b/pkg/authkit/models/clients.go
similarity index 100%
rename from pkg/internal/models/clients.go
rename to pkg/authkit/models/clients.go
diff --git a/pkg/internal/models/events.go b/pkg/authkit/models/events.go
similarity index 100%
rename from pkg/internal/models/events.go
rename to pkg/authkit/models/events.go
diff --git a/pkg/internal/models/notifications.go b/pkg/authkit/models/notifications.go
similarity index 100%
rename from pkg/internal/models/notifications.go
rename to pkg/authkit/models/notifications.go
diff --git a/pkg/internal/models/preferences.go b/pkg/authkit/models/preferences.go
similarity index 100%
rename from pkg/internal/models/preferences.go
rename to pkg/authkit/models/preferences.go
diff --git a/pkg/internal/models/profiles.go b/pkg/authkit/models/profiles.go
similarity index 100%
rename from pkg/internal/models/profiles.go
rename to pkg/authkit/models/profiles.go
diff --git a/pkg/internal/models/realms.go b/pkg/authkit/models/realms.go
similarity index 100%
rename from pkg/internal/models/realms.go
rename to pkg/authkit/models/realms.go
diff --git a/pkg/internal/models/relationships.go b/pkg/authkit/models/relationships.go
similarity index 100%
rename from pkg/internal/models/relationships.go
rename to pkg/authkit/models/relationships.go
diff --git a/pkg/internal/models/reports.go b/pkg/authkit/models/reports.go
similarity index 100%
rename from pkg/internal/models/reports.go
rename to pkg/authkit/models/reports.go
diff --git a/pkg/internal/models/sign_record.go b/pkg/authkit/models/sign_record.go
similarity index 100%
rename from pkg/internal/models/sign_record.go
rename to pkg/authkit/models/sign_record.go
diff --git a/pkg/internal/models/statuses.go b/pkg/authkit/models/statuses.go
similarity index 100%
rename from pkg/internal/models/statuses.go
rename to pkg/authkit/models/statuses.go
diff --git a/pkg/internal/models/tokens.go b/pkg/authkit/models/tokens.go
similarity index 100%
rename from pkg/internal/models/tokens.go
rename to pkg/authkit/models/tokens.go
diff --git a/pkg/authkit/parser.go b/pkg/authkit/parser.go
new file mode 100644
index 0000000..9ed42e8
--- /dev/null
+++ b/pkg/authkit/parser.go
@@ -0,0 +1,27 @@
+package authkit
+
+import (
+ "git.solsynth.dev/hydrogen/passport/pkg/authkit/models"
+ "git.solsynth.dev/hypernet/nexus/pkg/nex/sec"
+ "github.com/goccy/go-json"
+ "github.com/gofiber/fiber/v2"
+)
+
+// GetAccountFromUserInfo returns the account from the user info
+// This method will not to query the database, it will parse the token and get the subject of the userinfo token
+func GetAccountFromUserInfo(info *sec.UserInfo) models.Account {
+ raw, _ := json.Marshal(info.Metadata)
+
+ // We assume the token is signed by the same version of service
+ // So directly read the data out of the metadata
+ var out models.Account
+ _ = json.Unmarshal(raw, &out)
+ return out
+}
+
+func ParseAccountMiddleware(c *fiber.Ctx) error {
+ if info, ok := c.Locals("nex_user").(*sec.UserInfo); ok {
+ c.Locals("user", GetAccountFromUserInfo(info))
+ }
+ return c.Next()
+}
diff --git a/pkg/internal/database/migrator.go b/pkg/internal/database/migrator.go
index f70f450..3e3c9f7 100644
--- a/pkg/internal/database/migrator.go
+++ b/pkg/internal/database/migrator.go
@@ -1,7 +1,7 @@
package database
import (
- "git.solsynth.dev/hydrogen/passport/pkg/internal/models"
+ "git.solsynth.dev/hydrogen/passport/pkg/authkit/models"
"gorm.io/gorm"
)
diff --git a/pkg/internal/grpc/auth.go b/pkg/internal/grpc/auth.go
index 2a551be..11eaa42 100644
--- a/pkg/internal/grpc/auth.go
+++ b/pkg/internal/grpc/auth.go
@@ -2,10 +2,10 @@ package grpc
import (
"context"
+ "git.solsynth.dev/hydrogen/passport/pkg/authkit/models"
"git.solsynth.dev/hypernet/nexus/pkg/nex"
"git.solsynth.dev/hydrogen/passport/pkg/internal/database"
- "git.solsynth.dev/hydrogen/passport/pkg/internal/models"
"github.com/samber/lo"
"git.solsynth.dev/hydrogen/passport/pkg/internal/services"
diff --git a/pkg/internal/grpc/notifier.go b/pkg/internal/grpc/notifier.go
index 908cd1f..8231d0f 100644
--- a/pkg/internal/grpc/notifier.go
+++ b/pkg/internal/grpc/notifier.go
@@ -3,13 +3,13 @@ package grpc
import (
"context"
"fmt"
+ "git.solsynth.dev/hydrogen/passport/pkg/authkit/models"
"git.solsynth.dev/hypernet/nexus/pkg/nex"
"github.com/rs/zerolog/log"
"git.solsynth.dev/hydrogen/passport/pkg/internal/database"
"github.com/samber/lo"
- "git.solsynth.dev/hydrogen/passport/pkg/internal/models"
"git.solsynth.dev/hydrogen/passport/pkg/internal/services"
"git.solsynth.dev/hydrogen/passport/pkg/proto"
)
diff --git a/pkg/internal/grpc/realms.go b/pkg/internal/grpc/realms.go
index 53eb106..331bf2d 100644
--- a/pkg/internal/grpc/realms.go
+++ b/pkg/internal/grpc/realms.go
@@ -3,10 +3,10 @@ package grpc
import (
"context"
"fmt"
+ "git.solsynth.dev/hydrogen/passport/pkg/authkit/models"
"git.solsynth.dev/hypernet/nexus/pkg/nex"
"git.solsynth.dev/hydrogen/passport/pkg/internal/database"
- "git.solsynth.dev/hydrogen/passport/pkg/internal/models"
"git.solsynth.dev/hydrogen/passport/pkg/internal/services"
"git.solsynth.dev/hydrogen/passport/pkg/proto"
"github.com/samber/lo"
diff --git a/pkg/internal/http/admin/badges_api.go b/pkg/internal/http/admin/badges_api.go
index f18a0ca..fbe7f59 100644
--- a/pkg/internal/http/admin/badges_api.go
+++ b/pkg/internal/http/admin/badges_api.go
@@ -2,10 +2,10 @@ package admin
import (
"fmt"
+ "git.solsynth.dev/hydrogen/passport/pkg/authkit/models"
"git.solsynth.dev/hydrogen/passport/pkg/internal/http/exts"
"git.solsynth.dev/hydrogen/passport/pkg/internal/database"
- "git.solsynth.dev/hydrogen/passport/pkg/internal/models"
"git.solsynth.dev/hydrogen/passport/pkg/internal/services"
"github.com/gofiber/fiber/v2"
)
diff --git a/pkg/internal/http/admin/factors_api.go b/pkg/internal/http/admin/factors_api.go
index 685086c..5ce9617 100644
--- a/pkg/internal/http/admin/factors_api.go
+++ b/pkg/internal/http/admin/factors_api.go
@@ -1,9 +1,9 @@
package admin
import (
+ "git.solsynth.dev/hydrogen/passport/pkg/authkit/models"
"git.solsynth.dev/hydrogen/passport/pkg/internal/database"
"git.solsynth.dev/hydrogen/passport/pkg/internal/http/exts"
- "git.solsynth.dev/hydrogen/passport/pkg/internal/models"
"github.com/gofiber/fiber/v2"
jsoniter "github.com/json-iterator/go"
"github.com/samber/lo"
diff --git a/pkg/internal/http/admin/notify_api.go b/pkg/internal/http/admin/notify_api.go
index 6165f8b..6232452 100644
--- a/pkg/internal/http/admin/notify_api.go
+++ b/pkg/internal/http/admin/notify_api.go
@@ -1,9 +1,9 @@
package admin
import (
+ "git.solsynth.dev/hydrogen/passport/pkg/authkit/models"
"git.solsynth.dev/hydrogen/passport/pkg/internal/database"
"git.solsynth.dev/hydrogen/passport/pkg/internal/http/exts"
- "git.solsynth.dev/hydrogen/passport/pkg/internal/models"
"git.solsynth.dev/hydrogen/passport/pkg/internal/services"
"git.solsynth.dev/hypernet/nexus/pkg/nex/sec"
"github.com/gofiber/fiber/v2"
diff --git a/pkg/internal/http/admin/permissions_api.go b/pkg/internal/http/admin/permissions_api.go
index a3e9c06..c0db9ab 100644
--- a/pkg/internal/http/admin/permissions_api.go
+++ b/pkg/internal/http/admin/permissions_api.go
@@ -2,11 +2,11 @@ package admin
import (
"fmt"
+ "git.solsynth.dev/hydrogen/passport/pkg/authkit/models"
"git.solsynth.dev/hypernet/nexus/pkg/nex/sec"
"git.solsynth.dev/hydrogen/passport/pkg/internal/database"
"git.solsynth.dev/hydrogen/passport/pkg/internal/http/exts"
- "git.solsynth.dev/hydrogen/passport/pkg/internal/models"
"git.solsynth.dev/hydrogen/passport/pkg/internal/services"
"github.com/gofiber/fiber/v2"
)
diff --git a/pkg/internal/http/admin/users_api.go b/pkg/internal/http/admin/users_api.go
index 7e4811c..70d4807 100644
--- a/pkg/internal/http/admin/users_api.go
+++ b/pkg/internal/http/admin/users_api.go
@@ -2,9 +2,9 @@ package admin
import (
"fmt"
+ "git.solsynth.dev/hydrogen/passport/pkg/authkit/models"
"git.solsynth.dev/hydrogen/passport/pkg/internal/database"
"git.solsynth.dev/hydrogen/passport/pkg/internal/http/exts"
- "git.solsynth.dev/hydrogen/passport/pkg/internal/models"
"git.solsynth.dev/hydrogen/passport/pkg/internal/services"
"git.solsynth.dev/hypernet/nexus/pkg/nex/sec"
"github.com/gofiber/fiber/v2"
diff --git a/pkg/internal/http/api/accounts_api.go b/pkg/internal/http/api/accounts_api.go
index 5c15d37..ca0d54d 100644
--- a/pkg/internal/http/api/accounts_api.go
+++ b/pkg/internal/http/api/accounts_api.go
@@ -2,6 +2,7 @@ package api
import (
"fmt"
+ "git.solsynth.dev/hydrogen/passport/pkg/authkit/models"
"git.solsynth.dev/hypernet/nexus/pkg/nex/sec"
"strconv"
"strings"
@@ -10,7 +11,6 @@ import (
"git.solsynth.dev/hydrogen/passport/pkg/internal/http/exts"
"git.solsynth.dev/hydrogen/passport/pkg/internal/database"
- "git.solsynth.dev/hydrogen/passport/pkg/internal/models"
"git.solsynth.dev/hydrogen/passport/pkg/internal/services"
"github.com/gofiber/fiber/v2"
jsoniter "github.com/json-iterator/go"
diff --git a/pkg/internal/http/api/avatar_api.go b/pkg/internal/http/api/avatar_api.go
index b661945..2aecaff 100644
--- a/pkg/internal/http/api/avatar_api.go
+++ b/pkg/internal/http/api/avatar_api.go
@@ -2,9 +2,9 @@ package api
import (
"fmt"
+ "git.solsynth.dev/hydrogen/passport/pkg/authkit/models"
"git.solsynth.dev/hydrogen/passport/pkg/internal/database"
"git.solsynth.dev/hydrogen/passport/pkg/internal/http/exts"
- "git.solsynth.dev/hydrogen/passport/pkg/internal/models"
"git.solsynth.dev/hydrogen/passport/pkg/internal/services"
"git.solsynth.dev/hypernet/nexus/pkg/nex/sec"
"github.com/gofiber/fiber/v2"
diff --git a/pkg/internal/http/api/bot_token_api.go b/pkg/internal/http/api/bot_token_api.go
index 291720b..3d280aa 100644
--- a/pkg/internal/http/api/bot_token_api.go
+++ b/pkg/internal/http/api/bot_token_api.go
@@ -2,9 +2,9 @@ package api
import (
"fmt"
+ "git.solsynth.dev/hydrogen/passport/pkg/authkit/models"
"git.solsynth.dev/hydrogen/passport/pkg/internal/database"
"git.solsynth.dev/hydrogen/passport/pkg/internal/http/exts"
- "git.solsynth.dev/hydrogen/passport/pkg/internal/models"
"git.solsynth.dev/hydrogen/passport/pkg/internal/services"
"git.solsynth.dev/hypernet/nexus/pkg/nex/sec"
"github.com/gofiber/fiber/v2"
diff --git a/pkg/internal/http/api/bots_api.go b/pkg/internal/http/api/bots_api.go
index 80a916e..a33f7ac 100644
--- a/pkg/internal/http/api/bots_api.go
+++ b/pkg/internal/http/api/bots_api.go
@@ -2,9 +2,9 @@ package api
import (
"fmt"
+ "git.solsynth.dev/hydrogen/passport/pkg/authkit/models"
"git.solsynth.dev/hydrogen/passport/pkg/internal/database"
"git.solsynth.dev/hydrogen/passport/pkg/internal/http/exts"
- "git.solsynth.dev/hydrogen/passport/pkg/internal/models"
"git.solsynth.dev/hydrogen/passport/pkg/internal/services"
"git.solsynth.dev/hypernet/nexus/pkg/nex/sec"
"github.com/gofiber/fiber/v2"
diff --git a/pkg/internal/http/api/notifications_api.go b/pkg/internal/http/api/notifications_api.go
index b0ebd74..1657dac 100644
--- a/pkg/internal/http/api/notifications_api.go
+++ b/pkg/internal/http/api/notifications_api.go
@@ -2,9 +2,9 @@ package api
import (
"fmt"
+ "git.solsynth.dev/hydrogen/passport/pkg/authkit/models"
"git.solsynth.dev/hydrogen/passport/pkg/internal/database"
"git.solsynth.dev/hydrogen/passport/pkg/internal/http/exts"
- "git.solsynth.dev/hydrogen/passport/pkg/internal/models"
"git.solsynth.dev/hydrogen/passport/pkg/internal/services"
"git.solsynth.dev/hypernet/nexus/pkg/nex/sec"
"github.com/gofiber/fiber/v2"
diff --git a/pkg/internal/http/api/notify_api.go b/pkg/internal/http/api/notify_api.go
index 03012d7..49a715f 100644
--- a/pkg/internal/http/api/notify_api.go
+++ b/pkg/internal/http/api/notify_api.go
@@ -2,10 +2,10 @@ package api
import (
"fmt"
+ "git.solsynth.dev/hydrogen/passport/pkg/authkit/models"
"git.solsynth.dev/hypernet/nexus/pkg/nex/sec"
"git.solsynth.dev/hydrogen/passport/pkg/internal/http/exts"
- "git.solsynth.dev/hydrogen/passport/pkg/internal/models"
"git.solsynth.dev/hydrogen/passport/pkg/internal/services"
"github.com/gofiber/fiber/v2"
)
diff --git a/pkg/internal/http/api/oauth_api.go b/pkg/internal/http/api/oauth_api.go
index 9c1e76a..330a0d9 100755
--- a/pkg/internal/http/api/oauth_api.go
+++ b/pkg/internal/http/api/oauth_api.go
@@ -2,6 +2,7 @@ package api
import (
"fmt"
+ "git.solsynth.dev/hydrogen/passport/pkg/authkit/models"
"git.solsynth.dev/hypernet/nexus/pkg/nex/sec"
"strings"
"time"
@@ -9,7 +10,6 @@ import (
"git.solsynth.dev/hydrogen/passport/pkg/internal/http/exts"
"git.solsynth.dev/hydrogen/passport/pkg/internal/database"
- "git.solsynth.dev/hydrogen/passport/pkg/internal/models"
"git.solsynth.dev/hydrogen/passport/pkg/internal/services"
"github.com/gofiber/fiber/v2"
"github.com/samber/lo"
diff --git a/pkg/internal/http/api/preferences_api.go b/pkg/internal/http/api/preferences_api.go
index 3a28b00..5ed62b5 100644
--- a/pkg/internal/http/api/preferences_api.go
+++ b/pkg/internal/http/api/preferences_api.go
@@ -1,8 +1,8 @@
package api
import (
+ "git.solsynth.dev/hydrogen/passport/pkg/authkit/models"
"git.solsynth.dev/hydrogen/passport/pkg/internal/http/exts"
- "git.solsynth.dev/hydrogen/passport/pkg/internal/models"
"git.solsynth.dev/hydrogen/passport/pkg/internal/services"
"git.solsynth.dev/hypernet/nexus/pkg/nex/sec"
"github.com/gofiber/fiber/v2"
diff --git a/pkg/internal/http/api/realm_members_api.go b/pkg/internal/http/api/realm_members_api.go
index 2ef8595..0ebe6c2 100644
--- a/pkg/internal/http/api/realm_members_api.go
+++ b/pkg/internal/http/api/realm_members_api.go
@@ -1,9 +1,9 @@
package api
import (
+ "git.solsynth.dev/hydrogen/passport/pkg/authkit/models"
"git.solsynth.dev/hydrogen/passport/pkg/internal/database"
"git.solsynth.dev/hydrogen/passport/pkg/internal/http/exts"
- "git.solsynth.dev/hydrogen/passport/pkg/internal/models"
"git.solsynth.dev/hydrogen/passport/pkg/internal/services"
"git.solsynth.dev/hypernet/nexus/pkg/nex/sec"
"github.com/gofiber/fiber/v2"
diff --git a/pkg/internal/http/api/realms_api.go b/pkg/internal/http/api/realms_api.go
index 9d514ab..1a3168e 100644
--- a/pkg/internal/http/api/realms_api.go
+++ b/pkg/internal/http/api/realms_api.go
@@ -1,9 +1,9 @@
package api
import (
+ "git.solsynth.dev/hydrogen/passport/pkg/authkit/models"
"git.solsynth.dev/hydrogen/passport/pkg/internal/database"
"git.solsynth.dev/hydrogen/passport/pkg/internal/http/exts"
- "git.solsynth.dev/hydrogen/passport/pkg/internal/models"
"git.solsynth.dev/hydrogen/passport/pkg/internal/services"
"git.solsynth.dev/hypernet/nexus/pkg/nex/sec"
"github.com/gofiber/fiber/v2"
diff --git a/pkg/internal/http/api/relationships_api.go b/pkg/internal/http/api/relationships_api.go
index 69b07dc..9dc873f 100644
--- a/pkg/internal/http/api/relationships_api.go
+++ b/pkg/internal/http/api/relationships_api.go
@@ -1,9 +1,9 @@
package api
import (
+ "git.solsynth.dev/hydrogen/passport/pkg/authkit/models"
"git.solsynth.dev/hydrogen/passport/pkg/internal/database"
"git.solsynth.dev/hydrogen/passport/pkg/internal/http/exts"
- "git.solsynth.dev/hydrogen/passport/pkg/internal/models"
"git.solsynth.dev/hydrogen/passport/pkg/internal/services"
"git.solsynth.dev/hypernet/nexus/pkg/nex/sec"
"github.com/gofiber/fiber/v2"
diff --git a/pkg/internal/http/api/security_api.go b/pkg/internal/http/api/security_api.go
index 9a74a88..fd65746 100644
--- a/pkg/internal/http/api/security_api.go
+++ b/pkg/internal/http/api/security_api.go
@@ -1,9 +1,9 @@
package api
import (
+ "git.solsynth.dev/hydrogen/passport/pkg/authkit/models"
"git.solsynth.dev/hydrogen/passport/pkg/internal/database"
"git.solsynth.dev/hydrogen/passport/pkg/internal/http/exts"
- "git.solsynth.dev/hydrogen/passport/pkg/internal/models"
"git.solsynth.dev/hypernet/nexus/pkg/nex/sec"
"github.com/gofiber/fiber/v2"
)
diff --git a/pkg/internal/http/api/sign_api.go b/pkg/internal/http/api/sign_api.go
index 708d9e2..6197f3e 100644
--- a/pkg/internal/http/api/sign_api.go
+++ b/pkg/internal/http/api/sign_api.go
@@ -1,9 +1,9 @@
package api
import (
+ "git.solsynth.dev/hydrogen/passport/pkg/authkit/models"
"git.solsynth.dev/hydrogen/passport/pkg/internal/database"
"git.solsynth.dev/hydrogen/passport/pkg/internal/http/exts"
- "git.solsynth.dev/hydrogen/passport/pkg/internal/models"
"git.solsynth.dev/hydrogen/passport/pkg/internal/services"
"git.solsynth.dev/hypernet/nexus/pkg/nex/sec"
"github.com/gofiber/fiber/v2"
diff --git a/pkg/internal/http/api/statuses_api.go b/pkg/internal/http/api/statuses_api.go
index 3a0f8ee..1ebd1c8 100644
--- a/pkg/internal/http/api/statuses_api.go
+++ b/pkg/internal/http/api/statuses_api.go
@@ -2,13 +2,13 @@ package api
import (
"fmt"
+ "git.solsynth.dev/hydrogen/passport/pkg/authkit/models"
"git.solsynth.dev/hypernet/nexus/pkg/nex/sec"
"strconv"
"time"
"git.solsynth.dev/hydrogen/passport/pkg/internal/database"
"git.solsynth.dev/hydrogen/passport/pkg/internal/http/exts"
- "git.solsynth.dev/hydrogen/passport/pkg/internal/models"
"git.solsynth.dev/hydrogen/passport/pkg/internal/services"
"github.com/gofiber/fiber/v2"
"github.com/samber/lo"
diff --git a/pkg/internal/http/api/userinfo_api.go b/pkg/internal/http/api/userinfo_api.go
index c43dbf9..5298c27 100644
--- a/pkg/internal/http/api/userinfo_api.go
+++ b/pkg/internal/http/api/userinfo_api.go
@@ -2,12 +2,12 @@ package api
import (
"fmt"
+ "git.solsynth.dev/hydrogen/passport/pkg/authkit/models"
"github.com/spf13/viper"
"gorm.io/gorm"
"strings"
"git.solsynth.dev/hydrogen/passport/pkg/internal/database"
- "git.solsynth.dev/hydrogen/passport/pkg/internal/models"
"git.solsynth.dev/hydrogen/passport/pkg/internal/services"
"github.com/gofiber/fiber/v2"
)
diff --git a/pkg/internal/http/server.go b/pkg/internal/http/server.go
index 09bfc72..37efba1 100644
--- a/pkg/internal/http/server.go
+++ b/pkg/internal/http/server.go
@@ -1,6 +1,7 @@
package http
import (
+ "git.solsynth.dev/hydrogen/passport/pkg/authkit"
"git.solsynth.dev/hypernet/nexus/pkg/nex/sec"
"strings"
@@ -56,12 +57,7 @@ func NewServer() *App {
}))
app.Use(sec.ContextMiddleware(IReader))
- app.Use(func(c *fiber.Ctx) error {
- if user, ok := c.Locals("nex_user").(*sec.UserInfo); ok {
- c.Locals("user", user)
- }
- return c.Next()
- })
+ app.Use(authkit.ParseAccountMiddleware)
admin.MapAdminAPIs(app, "/api/admin")
api.MapAPIs(app, "/api")
diff --git a/pkg/internal/services/account_groups.go b/pkg/internal/services/account_groups.go
index b3ff402..69a6a22 100644
--- a/pkg/internal/services/account_groups.go
+++ b/pkg/internal/services/account_groups.go
@@ -1,8 +1,8 @@
package services
import (
+ "git.solsynth.dev/hydrogen/passport/pkg/authkit/models"
"git.solsynth.dev/hydrogen/passport/pkg/internal/database"
- "git.solsynth.dev/hydrogen/passport/pkg/internal/models"
"github.com/samber/lo"
)
diff --git a/pkg/internal/services/accounts.go b/pkg/internal/services/accounts.go
index 13eff19..208b758 100644
--- a/pkg/internal/services/accounts.go
+++ b/pkg/internal/services/accounts.go
@@ -3,6 +3,7 @@ package services
import (
"context"
"fmt"
+ "git.solsynth.dev/hydrogen/passport/pkg/authkit/models"
"git.solsynth.dev/hypernet/nexus/pkg/nex"
"git.solsynth.dev/hypernet/nexus/pkg/proto"
"time"
@@ -17,7 +18,6 @@ import (
"gorm.io/datatypes"
"git.solsynth.dev/hydrogen/passport/pkg/internal/database"
- "git.solsynth.dev/hydrogen/passport/pkg/internal/models"
"github.com/google/uuid"
"github.com/samber/lo"
)
diff --git a/pkg/internal/services/auth.go b/pkg/internal/services/auth.go
index 7b04d42..91c8b27 100644
--- a/pkg/internal/services/auth.go
+++ b/pkg/internal/services/auth.go
@@ -3,6 +3,7 @@ package services
import (
"context"
"fmt"
+ "git.solsynth.dev/hydrogen/passport/pkg/authkit/models"
"git.solsynth.dev/hydrogen/passport/pkg/internal/database"
"time"
@@ -12,7 +13,6 @@ import (
jsoniter "github.com/json-iterator/go"
localCache "git.solsynth.dev/hydrogen/passport/pkg/internal/cache"
- "git.solsynth.dev/hydrogen/passport/pkg/internal/models"
"github.com/gofiber/fiber/v2"
"github.com/rs/zerolog/log"
)
diff --git a/pkg/internal/services/badges.go b/pkg/internal/services/badges.go
index 9718047..2421f24 100644
--- a/pkg/internal/services/badges.go
+++ b/pkg/internal/services/badges.go
@@ -1,8 +1,8 @@
package services
import (
+ "git.solsynth.dev/hydrogen/passport/pkg/authkit/models"
"git.solsynth.dev/hydrogen/passport/pkg/internal/database"
- "git.solsynth.dev/hydrogen/passport/pkg/internal/models"
)
func GrantBadge(user models.Account, badge models.Badge) error {
diff --git a/pkg/internal/services/bot_token.go b/pkg/internal/services/bot_token.go
index 0ce76e6..3a8ddcf 100644
--- a/pkg/internal/services/bot_token.go
+++ b/pkg/internal/services/bot_token.go
@@ -1,10 +1,10 @@
package services
import (
+ "git.solsynth.dev/hydrogen/passport/pkg/authkit/models"
"time"
"git.solsynth.dev/hydrogen/passport/pkg/internal/database"
- "git.solsynth.dev/hydrogen/passport/pkg/internal/models"
"github.com/google/uuid"
"github.com/samber/lo"
)
diff --git a/pkg/internal/services/bots.go b/pkg/internal/services/bots.go
index 5440f08..972c6fe 100644
--- a/pkg/internal/services/bots.go
+++ b/pkg/internal/services/bots.go
@@ -1,8 +1,8 @@
package services
import (
+ "git.solsynth.dev/hydrogen/passport/pkg/authkit/models"
"git.solsynth.dev/hydrogen/passport/pkg/internal/database"
- "git.solsynth.dev/hydrogen/passport/pkg/internal/models"
)
func GetBotCount(user uint) (int64, error) {
diff --git a/pkg/internal/services/cleaner.go b/pkg/internal/services/cleaner.go
index 4c084f1..3d66059 100644
--- a/pkg/internal/services/cleaner.go
+++ b/pkg/internal/services/cleaner.go
@@ -1,8 +1,8 @@
package services
import (
+ "git.solsynth.dev/hydrogen/passport/pkg/authkit/models"
"git.solsynth.dev/hydrogen/passport/pkg/internal/database"
- "git.solsynth.dev/hydrogen/passport/pkg/internal/models"
"github.com/rs/zerolog/log"
"time"
)
diff --git a/pkg/internal/services/clients.go b/pkg/internal/services/clients.go
index a97282a..dd94c8d 100644
--- a/pkg/internal/services/clients.go
+++ b/pkg/internal/services/clients.go
@@ -2,9 +2,9 @@ package services
import (
"fmt"
+ "git.solsynth.dev/hydrogen/passport/pkg/authkit/models"
"git.solsynth.dev/hydrogen/passport/pkg/internal/database"
- "git.solsynth.dev/hydrogen/passport/pkg/internal/models"
)
func GetThirdClient(id string) (models.ThirdClient, error) {
diff --git a/pkg/internal/services/events.go b/pkg/internal/services/events.go
index b3ba2b7..b3b40bc 100644
--- a/pkg/internal/services/events.go
+++ b/pkg/internal/services/events.go
@@ -1,8 +1,8 @@
package services
import (
+ "git.solsynth.dev/hydrogen/passport/pkg/authkit/models"
"git.solsynth.dev/hydrogen/passport/pkg/internal/database"
- "git.solsynth.dev/hydrogen/passport/pkg/internal/models"
"github.com/rs/zerolog/log"
)
diff --git a/pkg/internal/services/factors.go b/pkg/internal/services/factors.go
index 47faa6e..5221d3e 100644
--- a/pkg/internal/services/factors.go
+++ b/pkg/internal/services/factors.go
@@ -2,9 +2,9 @@ package services
import (
"fmt"
+ "git.solsynth.dev/hydrogen/passport/pkg/authkit/models"
"git.solsynth.dev/hydrogen/passport/pkg/internal/database"
"git.solsynth.dev/hydrogen/passport/pkg/internal/gap"
- "git.solsynth.dev/hydrogen/passport/pkg/internal/models"
"git.solsynth.dev/hypernet/pusher/pkg/pushkit"
"github.com/google/uuid"
"github.com/rs/zerolog/log"
diff --git a/pkg/internal/services/jwt.go b/pkg/internal/services/jwt.go
index 04506f6..cd609c5 100644
--- a/pkg/internal/services/jwt.go
+++ b/pkg/internal/services/jwt.go
@@ -1,10 +1,10 @@
package services
import (
+ "git.solsynth.dev/hydrogen/passport/pkg/authkit/models"
"git.solsynth.dev/hypernet/nexus/pkg/nex/sec"
"time"
- "git.solsynth.dev/hydrogen/passport/pkg/internal/models"
"github.com/golang-jwt/jwt/v5"
"github.com/spf13/viper"
)
diff --git a/pkg/internal/services/notifications.go b/pkg/internal/services/notifications.go
index 5f57a88..fa1f548 100644
--- a/pkg/internal/services/notifications.go
+++ b/pkg/internal/services/notifications.go
@@ -3,6 +3,7 @@ package services
import (
"context"
"fmt"
+ "git.solsynth.dev/hydrogen/passport/pkg/authkit/models"
"git.solsynth.dev/hypernet/nexus/pkg/nex"
"git.solsynth.dev/hypernet/nexus/pkg/proto"
"git.solsynth.dev/hypernet/pusher/pkg/pushkit"
@@ -15,7 +16,6 @@ import (
"git.solsynth.dev/hydrogen/passport/pkg/internal/gap"
"git.solsynth.dev/hydrogen/passport/pkg/internal/database"
- "git.solsynth.dev/hydrogen/passport/pkg/internal/models"
)
func AddNotifySubscriber(user models.Account, provider, id, tk, ua string) (models.NotificationSubscriber, error) {
diff --git a/pkg/internal/services/preferences.go b/pkg/internal/services/preferences.go
index 8242c0d..bf40cee 100644
--- a/pkg/internal/services/preferences.go
+++ b/pkg/internal/services/preferences.go
@@ -3,11 +3,11 @@ package services
import (
"context"
"fmt"
+ "git.solsynth.dev/hydrogen/passport/pkg/authkit/models"
"time"
localCache "git.solsynth.dev/hydrogen/passport/pkg/internal/cache"
"git.solsynth.dev/hydrogen/passport/pkg/internal/database"
- "git.solsynth.dev/hydrogen/passport/pkg/internal/models"
"github.com/eko/gocache/lib/v4/cache"
"github.com/eko/gocache/lib/v4/marshaler"
"github.com/eko/gocache/lib/v4/store"
diff --git a/pkg/internal/services/realms.go b/pkg/internal/services/realms.go
index 8016e1b..e7068a2 100644
--- a/pkg/internal/services/realms.go
+++ b/pkg/internal/services/realms.go
@@ -2,8 +2,8 @@ package services
import (
"fmt"
+ "git.solsynth.dev/hydrogen/passport/pkg/authkit/models"
"git.solsynth.dev/hydrogen/passport/pkg/internal/database"
- "git.solsynth.dev/hydrogen/passport/pkg/internal/models"
"github.com/samber/lo"
)
diff --git a/pkg/internal/services/relationships.go b/pkg/internal/services/relationships.go
index cfd1d13..72d4987 100644
--- a/pkg/internal/services/relationships.go
+++ b/pkg/internal/services/relationships.go
@@ -3,9 +3,9 @@ package services
import (
"errors"
"fmt"
+ "git.solsynth.dev/hydrogen/passport/pkg/authkit/models"
"git.solsynth.dev/hydrogen/passport/pkg/internal/database"
- "git.solsynth.dev/hydrogen/passport/pkg/internal/models"
"gorm.io/gorm"
)
diff --git a/pkg/internal/services/reports.go b/pkg/internal/services/reports.go
index 32f18ac..8cda01b 100644
--- a/pkg/internal/services/reports.go
+++ b/pkg/internal/services/reports.go
@@ -2,9 +2,7 @@ package services
import (
"fmt"
-
"git.solsynth.dev/hydrogen/passport/pkg/internal/database"
- "git.solsynth.dev/hydrogen/passport/pkg/internal/models"
)
func ListAbuseReport(account uint) ([]models.AbuseReport, error) {
diff --git a/pkg/internal/services/sign.go b/pkg/internal/services/sign.go
index b0fffac..3572b91 100644
--- a/pkg/internal/services/sign.go
+++ b/pkg/internal/services/sign.go
@@ -3,8 +3,8 @@ package services
import (
"errors"
"fmt"
+ "git.solsynth.dev/hydrogen/passport/pkg/authkit/models"
"git.solsynth.dev/hydrogen/passport/pkg/internal/database"
- "git.solsynth.dev/hydrogen/passport/pkg/internal/models"
"gorm.io/gorm"
"math"
"math/rand"
diff --git a/pkg/internal/services/statuses.go b/pkg/internal/services/statuses.go
index 2cd8bfe..7bdf2b4 100644
--- a/pkg/internal/services/statuses.go
+++ b/pkg/internal/services/statuses.go
@@ -3,6 +3,7 @@ package services
import (
"context"
"fmt"
+ "git.solsynth.dev/hydrogen/passport/pkg/authkit/models"
"git.solsynth.dev/hypernet/nexus/pkg/proto"
"time"
@@ -10,7 +11,6 @@ import (
"git.solsynth.dev/hydrogen/passport/pkg/internal/gap"
"git.solsynth.dev/hydrogen/passport/pkg/internal/database"
- "git.solsynth.dev/hydrogen/passport/pkg/internal/models"
"github.com/eko/gocache/lib/v4/cache"
"github.com/eko/gocache/lib/v4/marshaler"
"github.com/eko/gocache/lib/v4/store"
diff --git a/pkg/internal/services/ticket.go b/pkg/internal/services/ticket.go
index 64bd981..a62ea0c 100644
--- a/pkg/internal/services/ticket.go
+++ b/pkg/internal/services/ticket.go
@@ -2,6 +2,7 @@ package services
import (
"fmt"
+ "git.solsynth.dev/hydrogen/passport/pkg/authkit/models"
"gorm.io/datatypes"
"time"
@@ -10,7 +11,6 @@ import (
"github.com/google/uuid"
"git.solsynth.dev/hydrogen/passport/pkg/internal/database"
- "git.solsynth.dev/hydrogen/passport/pkg/internal/models"
"github.com/samber/lo"
)
diff --git a/pkg/internal/services/ticket_queries.go b/pkg/internal/services/ticket_queries.go
index 3c9d643..f0d822b 100644
--- a/pkg/internal/services/ticket_queries.go
+++ b/pkg/internal/services/ticket_queries.go
@@ -1,8 +1,8 @@
package services
import (
+ "git.solsynth.dev/hydrogen/passport/pkg/authkit/models"
"git.solsynth.dev/hydrogen/passport/pkg/internal/database"
- "git.solsynth.dev/hydrogen/passport/pkg/internal/models"
)
func GetTicket(id uint) (models.AuthTicket, error) {
diff --git a/pkg/internal/services/ticket_token.go b/pkg/internal/services/ticket_token.go
index 55a4e54..7f62106 100644
--- a/pkg/internal/services/ticket_token.go
+++ b/pkg/internal/services/ticket_token.go
@@ -2,12 +2,12 @@ package services
import (
"fmt"
+ "git.solsynth.dev/hydrogen/passport/pkg/authkit/models"
"git.solsynth.dev/hypernet/nexus/pkg/nex/sec"
"strconv"
"time"
"git.solsynth.dev/hydrogen/passport/pkg/internal/database"
- "git.solsynth.dev/hydrogen/passport/pkg/internal/models"
"github.com/samber/lo"
"github.com/spf13/viper"
)
diff --git a/pkg/internal/services/tokens.go b/pkg/internal/services/tokens.go
index 5aa4008..e7848a8 100644
--- a/pkg/internal/services/tokens.go
+++ b/pkg/internal/services/tokens.go
@@ -2,13 +2,13 @@ package services
import (
"fmt"
+ "git.solsynth.dev/hydrogen/passport/pkg/authkit/models"
"git.solsynth.dev/hydrogen/passport/pkg/internal/gap"
"git.solsynth.dev/hypernet/pusher/pkg/pushkit"
"strings"
"time"
"git.solsynth.dev/hydrogen/passport/pkg/internal/database"
- "git.solsynth.dev/hydrogen/passport/pkg/internal/models"
"github.com/google/uuid"
"github.com/spf13/viper"
)