🚚 Auth kit and parser of nexus userinfo token

This commit is contained in:
LittleSheep 2024-10-31 00:15:25 +08:00
parent 2d322f070a
commit 69c6ac6581
67 changed files with 143 additions and 70 deletions

86
.idea/workspace.xml generated
View File

@ -4,11 +4,74 @@
<option name="autoReloadType" value="ALL" />
</component>
<component name="ChangeListManager">
<list default="true" id="3fefb2c4-b6f9-466b-a523-53352e8d6f95" name="更改" comment=":bug: Fix check perm panic">
<list default="true" id="3fefb2c4-b6f9-466b-a523-53352e8d6f95" name="更改" comment=":bug: Refresh token bug">
<change afterPath="$PROJECT_DIR$/pkg/authkit/parser.go" afterDir="false" />
<change beforePath="$PROJECT_DIR$/.idea/workspace.xml" beforeDir="false" afterPath="$PROJECT_DIR$/.idea/workspace.xml" afterDir="false" />
<change beforePath="$PROJECT_DIR$/go.mod" beforeDir="false" afterPath="$PROJECT_DIR$/go.mod" afterDir="false" />
<change beforePath="$PROJECT_DIR$/go.sum" beforeDir="false" afterPath="$PROJECT_DIR$/go.sum" afterDir="false" />
<change beforePath="$PROJECT_DIR$/pkg/internal/database/migrator.go" beforeDir="false" afterPath="$PROJECT_DIR$/pkg/internal/database/migrator.go" afterDir="false" />
<change beforePath="$PROJECT_DIR$/pkg/internal/grpc/auth.go" beforeDir="false" afterPath="$PROJECT_DIR$/pkg/internal/grpc/auth.go" afterDir="false" />
<change beforePath="$PROJECT_DIR$/pkg/internal/grpc/notifier.go" beforeDir="false" afterPath="$PROJECT_DIR$/pkg/internal/grpc/notifier.go" afterDir="false" />
<change beforePath="$PROJECT_DIR$/pkg/internal/grpc/realms.go" beforeDir="false" afterPath="$PROJECT_DIR$/pkg/internal/grpc/realms.go" afterDir="false" />
<change beforePath="$PROJECT_DIR$/pkg/internal/http/admin/badges_api.go" beforeDir="false" afterPath="$PROJECT_DIR$/pkg/internal/http/admin/badges_api.go" afterDir="false" />
<change beforePath="$PROJECT_DIR$/pkg/internal/http/admin/factors_api.go" beforeDir="false" afterPath="$PROJECT_DIR$/pkg/internal/http/admin/factors_api.go" afterDir="false" />
<change beforePath="$PROJECT_DIR$/pkg/internal/http/admin/notify_api.go" beforeDir="false" afterPath="$PROJECT_DIR$/pkg/internal/http/admin/notify_api.go" afterDir="false" />
<change beforePath="$PROJECT_DIR$/pkg/internal/http/admin/permissions_api.go" beforeDir="false" afterPath="$PROJECT_DIR$/pkg/internal/http/admin/permissions_api.go" afterDir="false" />
<change beforePath="$PROJECT_DIR$/pkg/internal/http/admin/users_api.go" beforeDir="false" afterPath="$PROJECT_DIR$/pkg/internal/http/admin/users_api.go" afterDir="false" />
<change beforePath="$PROJECT_DIR$/pkg/internal/http/api/accounts_api.go" beforeDir="false" afterPath="$PROJECT_DIR$/pkg/internal/http/api/accounts_api.go" afterDir="false" />
<change beforePath="$PROJECT_DIR$/pkg/internal/http/api/avatar_api.go" beforeDir="false" afterPath="$PROJECT_DIR$/pkg/internal/http/api/avatar_api.go" afterDir="false" />
<change beforePath="$PROJECT_DIR$/pkg/internal/http/api/bot_token_api.go" beforeDir="false" afterPath="$PROJECT_DIR$/pkg/internal/http/api/bot_token_api.go" afterDir="false" />
<change beforePath="$PROJECT_DIR$/pkg/internal/http/api/bots_api.go" beforeDir="false" afterPath="$PROJECT_DIR$/pkg/internal/http/api/bots_api.go" afterDir="false" />
<change beforePath="$PROJECT_DIR$/pkg/internal/http/api/notifications_api.go" beforeDir="false" afterPath="$PROJECT_DIR$/pkg/internal/http/api/notifications_api.go" afterDir="false" />
<change beforePath="$PROJECT_DIR$/pkg/internal/http/api/notify_api.go" beforeDir="false" afterPath="$PROJECT_DIR$/pkg/internal/http/api/notify_api.go" afterDir="false" />
<change beforePath="$PROJECT_DIR$/pkg/internal/http/api/oauth_api.go" beforeDir="false" afterPath="$PROJECT_DIR$/pkg/internal/http/api/oauth_api.go" afterDir="false" />
<change beforePath="$PROJECT_DIR$/pkg/internal/http/api/preferences_api.go" beforeDir="false" afterPath="$PROJECT_DIR$/pkg/internal/http/api/preferences_api.go" afterDir="false" />
<change beforePath="$PROJECT_DIR$/pkg/internal/http/api/realm_members_api.go" beforeDir="false" afterPath="$PROJECT_DIR$/pkg/internal/http/api/realm_members_api.go" afterDir="false" />
<change beforePath="$PROJECT_DIR$/pkg/internal/http/api/realms_api.go" beforeDir="false" afterPath="$PROJECT_DIR$/pkg/internal/http/api/realms_api.go" afterDir="false" />
<change beforePath="$PROJECT_DIR$/pkg/internal/http/api/relationships_api.go" beforeDir="false" afterPath="$PROJECT_DIR$/pkg/internal/http/api/relationships_api.go" afterDir="false" />
<change beforePath="$PROJECT_DIR$/pkg/internal/http/api/security_api.go" beforeDir="false" afterPath="$PROJECT_DIR$/pkg/internal/http/api/security_api.go" afterDir="false" />
<change beforePath="$PROJECT_DIR$/pkg/internal/http/api/sign_api.go" beforeDir="false" afterPath="$PROJECT_DIR$/pkg/internal/http/api/sign_api.go" afterDir="false" />
<change beforePath="$PROJECT_DIR$/pkg/internal/http/api/statuses_api.go" beforeDir="false" afterPath="$PROJECT_DIR$/pkg/internal/http/api/statuses_api.go" afterDir="false" />
<change beforePath="$PROJECT_DIR$/pkg/internal/http/api/userinfo_api.go" beforeDir="false" afterPath="$PROJECT_DIR$/pkg/internal/http/api/userinfo_api.go" afterDir="false" />
<change beforePath="$PROJECT_DIR$/pkg/internal/http/server.go" beforeDir="false" afterPath="$PROJECT_DIR$/pkg/internal/http/server.go" afterDir="false" />
<change beforePath="$PROJECT_DIR$/pkg/internal/models/account_groups.go" beforeDir="false" afterPath="$PROJECT_DIR$/pkg/authkit/models/account_groups.go" afterDir="false" />
<change beforePath="$PROJECT_DIR$/pkg/internal/models/accounts.go" beforeDir="false" afterPath="$PROJECT_DIR$/pkg/authkit/models/accounts.go" afterDir="false" />
<change beforePath="$PROJECT_DIR$/pkg/internal/models/audit.go" beforeDir="false" afterPath="$PROJECT_DIR$/pkg/authkit/models/audit.go" afterDir="false" />
<change beforePath="$PROJECT_DIR$/pkg/internal/models/auth.go" beforeDir="false" afterPath="$PROJECT_DIR$/pkg/authkit/models/auth.go" afterDir="false" />
<change beforePath="$PROJECT_DIR$/pkg/internal/models/badges.go" beforeDir="false" afterPath="$PROJECT_DIR$/pkg/authkit/models/badges.go" afterDir="false" />
<change beforePath="$PROJECT_DIR$/pkg/internal/models/base.go" beforeDir="false" afterPath="$PROJECT_DIR$/pkg/authkit/models/base.go" afterDir="false" />
<change beforePath="$PROJECT_DIR$/pkg/internal/models/bot.go" beforeDir="false" afterPath="$PROJECT_DIR$/pkg/authkit/models/bot.go" afterDir="false" />
<change beforePath="$PROJECT_DIR$/pkg/internal/models/clients.go" beforeDir="false" afterPath="$PROJECT_DIR$/pkg/authkit/models/clients.go" afterDir="false" />
<change beforePath="$PROJECT_DIR$/pkg/internal/models/events.go" beforeDir="false" afterPath="$PROJECT_DIR$/pkg/authkit/models/events.go" afterDir="false" />
<change beforePath="$PROJECT_DIR$/pkg/internal/models/notifications.go" beforeDir="false" afterPath="$PROJECT_DIR$/pkg/authkit/models/notifications.go" afterDir="false" />
<change beforePath="$PROJECT_DIR$/pkg/internal/models/preferences.go" beforeDir="false" afterPath="$PROJECT_DIR$/pkg/authkit/models/preferences.go" afterDir="false" />
<change beforePath="$PROJECT_DIR$/pkg/internal/models/profiles.go" beforeDir="false" afterPath="$PROJECT_DIR$/pkg/authkit/models/profiles.go" afterDir="false" />
<change beforePath="$PROJECT_DIR$/pkg/internal/models/realms.go" beforeDir="false" afterPath="$PROJECT_DIR$/pkg/authkit/models/realms.go" afterDir="false" />
<change beforePath="$PROJECT_DIR$/pkg/internal/models/relationships.go" beforeDir="false" afterPath="$PROJECT_DIR$/pkg/authkit/models/relationships.go" afterDir="false" />
<change beforePath="$PROJECT_DIR$/pkg/internal/models/reports.go" beforeDir="false" afterPath="$PROJECT_DIR$/pkg/authkit/models/reports.go" afterDir="false" />
<change beforePath="$PROJECT_DIR$/pkg/internal/models/sign_record.go" beforeDir="false" afterPath="$PROJECT_DIR$/pkg/authkit/models/sign_record.go" afterDir="false" />
<change beforePath="$PROJECT_DIR$/pkg/internal/models/statuses.go" beforeDir="false" afterPath="$PROJECT_DIR$/pkg/authkit/models/statuses.go" afterDir="false" />
<change beforePath="$PROJECT_DIR$/pkg/internal/models/tokens.go" beforeDir="false" afterPath="$PROJECT_DIR$/pkg/authkit/models/tokens.go" afterDir="false" />
<change beforePath="$PROJECT_DIR$/pkg/internal/services/account_groups.go" beforeDir="false" afterPath="$PROJECT_DIR$/pkg/internal/services/account_groups.go" afterDir="false" />
<change beforePath="$PROJECT_DIR$/pkg/internal/services/accounts.go" beforeDir="false" afterPath="$PROJECT_DIR$/pkg/internal/services/accounts.go" afterDir="false" />
<change beforePath="$PROJECT_DIR$/pkg/internal/services/auth.go" beforeDir="false" afterPath="$PROJECT_DIR$/pkg/internal/services/auth.go" afterDir="false" />
<change beforePath="$PROJECT_DIR$/pkg/internal/services/badges.go" beforeDir="false" afterPath="$PROJECT_DIR$/pkg/internal/services/badges.go" afterDir="false" />
<change beforePath="$PROJECT_DIR$/pkg/internal/services/bot_token.go" beforeDir="false" afterPath="$PROJECT_DIR$/pkg/internal/services/bot_token.go" afterDir="false" />
<change beforePath="$PROJECT_DIR$/pkg/internal/services/bots.go" beforeDir="false" afterPath="$PROJECT_DIR$/pkg/internal/services/bots.go" afterDir="false" />
<change beforePath="$PROJECT_DIR$/pkg/internal/services/cleaner.go" beforeDir="false" afterPath="$PROJECT_DIR$/pkg/internal/services/cleaner.go" afterDir="false" />
<change beforePath="$PROJECT_DIR$/pkg/internal/services/clients.go" beforeDir="false" afterPath="$PROJECT_DIR$/pkg/internal/services/clients.go" afterDir="false" />
<change beforePath="$PROJECT_DIR$/pkg/internal/services/events.go" beforeDir="false" afterPath="$PROJECT_DIR$/pkg/internal/services/events.go" afterDir="false" />
<change beforePath="$PROJECT_DIR$/pkg/internal/services/factors.go" beforeDir="false" afterPath="$PROJECT_DIR$/pkg/internal/services/factors.go" afterDir="false" />
<change beforePath="$PROJECT_DIR$/pkg/internal/services/jwt.go" beforeDir="false" afterPath="$PROJECT_DIR$/pkg/internal/services/jwt.go" afterDir="false" />
<change beforePath="$PROJECT_DIR$/pkg/internal/services/notifications.go" beforeDir="false" afterPath="$PROJECT_DIR$/pkg/internal/services/notifications.go" afterDir="false" />
<change beforePath="$PROJECT_DIR$/pkg/internal/services/preferences.go" beforeDir="false" afterPath="$PROJECT_DIR$/pkg/internal/services/preferences.go" afterDir="false" />
<change beforePath="$PROJECT_DIR$/pkg/internal/services/realms.go" beforeDir="false" afterPath="$PROJECT_DIR$/pkg/internal/services/realms.go" afterDir="false" />
<change beforePath="$PROJECT_DIR$/pkg/internal/services/relationships.go" beforeDir="false" afterPath="$PROJECT_DIR$/pkg/internal/services/relationships.go" afterDir="false" />
<change beforePath="$PROJECT_DIR$/pkg/internal/services/reports.go" beforeDir="false" afterPath="$PROJECT_DIR$/pkg/internal/services/reports.go" afterDir="false" />
<change beforePath="$PROJECT_DIR$/pkg/internal/services/sign.go" beforeDir="false" afterPath="$PROJECT_DIR$/pkg/internal/services/sign.go" afterDir="false" />
<change beforePath="$PROJECT_DIR$/pkg/internal/services/statuses.go" beforeDir="false" afterPath="$PROJECT_DIR$/pkg/internal/services/statuses.go" afterDir="false" />
<change beforePath="$PROJECT_DIR$/pkg/internal/services/ticket.go" beforeDir="false" afterPath="$PROJECT_DIR$/pkg/internal/services/ticket.go" afterDir="false" />
<change beforePath="$PROJECT_DIR$/pkg/internal/services/ticket_queries.go" beforeDir="false" afterPath="$PROJECT_DIR$/pkg/internal/services/ticket_queries.go" afterDir="false" />
<change beforePath="$PROJECT_DIR$/pkg/internal/services/ticket_token.go" beforeDir="false" afterPath="$PROJECT_DIR$/pkg/internal/services/ticket_token.go" afterDir="false" />
<change beforePath="$PROJECT_DIR$/pkg/internal/services/tokens.go" beforeDir="false" afterPath="$PROJECT_DIR$/pkg/internal/services/tokens.go" afterDir="false" />
</list>
<option name="SHOW_DIALOG" value="false" />
<option name="HIGHLIGHT_CONFLICTS" value="true" />
@ -80,11 +143,11 @@
<recent name="$PROJECT_DIR$/pkg/internal/server/api" />
</key>
<key name="MoveFile.RECENT_KEYS">
<recent name="$PROJECT_DIR$/pkg/authkit" />
<recent name="$PROJECT_DIR$/web/src/views/flow" />
<recent name="$PROJECT_DIR$/pkg/internal/server/exts" />
<recent name="$PROJECT_DIR$/pkg/internal/server/api" />
<recent name="$PROJECT_DIR$/pkg/internal" />
<recent name="$PROJECT_DIR$/pkg" />
</key>
</component>
<component name="RunAnythingCache">
@ -155,7 +218,6 @@
</option>
</component>
<component name="VcsManagerConfiguration">
<MESSAGE value=":bug: Fix daily sign random panic" />
<MESSAGE value=":sparkles: Realm avatar, banner and access policy" />
<MESSAGE value=":sparkles: Account deletion" />
<MESSAGE value=":sparkles: Auth config to limit auth steps" />
@ -180,20 +242,10 @@
<MESSAGE value=":truck: Move http server package" />
<MESSAGE value=":recycle: Move models.Account to sec.UserInfo" />
<MESSAGE value=":bug: Fix check perm panic" />
<option name="LAST_COMMIT_MESSAGE" value=":bug: Fix check perm panic" />
<MESSAGE value=":bug: Refresh token bug" />
<option name="LAST_COMMIT_MESSAGE" value=":bug: Refresh token bug" />
</component>
<component name="VgoProject">
<settings-migrated>true</settings-migrated>
</component>
<component name="XDebuggerManager">
<breakpoint-manager>
<breakpoints>
<line-breakpoint enabled="true" type="DlvLineBreakpoint">
<url>file://$PROJECT_DIR$/pkg/internal/services/ticket_token.go</url>
<line>105</line>
<option name="timeStamp" value="4" />
</line-breakpoint>
</breakpoints>
</breakpoint-manager>
</component>
</project>

27
pkg/authkit/parser.go Normal file
View File

@ -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()
}

View File

@ -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"
)

View File

@ -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"

View File

@ -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"
)

View File

@ -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"

View File

@ -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"
)

View File

@ -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"

View File

@ -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"

View File

@ -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"
)

View File

@ -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"

View File

@ -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"

View File

@ -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"

View File

@ -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"

View File

@ -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"

View File

@ -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"

View File

@ -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"
)

View File

@ -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"

View File

@ -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"

View File

@ -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"

View File

@ -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"

View File

@ -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"

View File

@ -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"
)

View File

@ -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"

View File

@ -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"

View File

@ -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"
)

View File

@ -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")

View File

@ -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"
)

View File

@ -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"
)

View File

@ -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"
)

View File

@ -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 {

View File

@ -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"
)

View File

@ -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) {

View File

@ -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"
)

View File

@ -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) {

View File

@ -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"
)

View File

@ -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"

View File

@ -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"
)

View File

@ -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) {

View File

@ -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"

View File

@ -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"
)

View File

@ -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"
)

View File

@ -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) {

View File

@ -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"

View File

@ -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"

View File

@ -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"
)

View File

@ -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) {

View File

@ -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"
)

View File

@ -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"
)