🚚 Rename package

This commit is contained in:
LittleSheep 2024-04-13 13:48:19 +08:00
parent d1f54099c4
commit e5d53ab77b
43 changed files with 94 additions and 94 deletions

View File

@ -25,4 +25,4 @@ jobs:
context: . context: .
file: ./Dockerfile file: ./Dockerfile
push: true push: true
tags: xsheep2010/identity:nightly tags: xsheep2010/passport:nightly

View File

@ -1,5 +1,5 @@
# Building Backend # Building Backend
FROM golang:alpine as identity-server FROM golang:alpine as passport-server
RUN apk add nodejs npm RUN apk add nodejs npm
@ -14,8 +14,8 @@ RUN CGO_ENABLED=0 GOOS=linux GOARCH=amd64 go build -buildvcs -o /dist ./pkg/cmd/
# Runtime # Runtime
FROM golang:alpine FROM golang:alpine
COPY --from=identity-server /dist /identity/server COPY --from=passport-server /dist /passport/server
EXPOSE 8444 EXPOSE 8444
CMD ["/identity/server"] CMD ["/passport/server"]

2
go.mod
View File

@ -1,4 +1,4 @@
module git.solsynth.dev/hydrogen/identity module git.solsynth.dev/hydrogen/passport
go 1.21.5 go 1.21.5

View File

@ -5,14 +5,14 @@ import (
"os/signal" "os/signal"
"syscall" "syscall"
"git.solsynth.dev/hydrogen/identity/pkg/external" "git.solsynth.dev/hydrogen/passport/pkg/external"
"git.solsynth.dev/hydrogen/identity/pkg/grpc" "git.solsynth.dev/hydrogen/passport/pkg/grpc"
"git.solsynth.dev/hydrogen/identity/pkg/server" "git.solsynth.dev/hydrogen/passport/pkg/server"
"git.solsynth.dev/hydrogen/identity/pkg/services" "git.solsynth.dev/hydrogen/passport/pkg/services"
"github.com/robfig/cron/v3" "github.com/robfig/cron/v3"
identity "git.solsynth.dev/hydrogen/identity/pkg" passport "git.solsynth.dev/hydrogen/passport/pkg"
"git.solsynth.dev/hydrogen/identity/pkg/database" "git.solsynth.dev/hydrogen/passport/pkg/database"
"github.com/rs/zerolog" "github.com/rs/zerolog"
"github.com/rs/zerolog/log" "github.com/rs/zerolog/log"
"github.com/spf13/viper" "github.com/spf13/viper"
@ -72,13 +72,13 @@ func main() {
quartz.Start() quartz.Start()
// Messages // Messages
log.Info().Msgf("Identity v%s is started...", identity.AppVersion) log.Info().Msgf("Identity v%s is started...", passport.AppVersion)
quit := make(chan os.Signal, 1) quit := make(chan os.Signal, 1)
signal.Notify(quit, syscall.SIGINT, syscall.SIGTERM) signal.Notify(quit, syscall.SIGINT, syscall.SIGTERM)
<-quit <-quit
log.Info().Msgf("Identity v%s is quitting...", identity.AppVersion) log.Info().Msgf("Identity v%s is quitting...", passport.AppVersion)
quartz.Stop() quartz.Stop()

View File

@ -1,7 +1,7 @@
package database package database
import ( import (
"git.solsynth.dev/hydrogen/identity/pkg/models" "git.solsynth.dev/hydrogen/passport/pkg/models"
"gorm.io/gorm" "gorm.io/gorm"
) )

View File

@ -4,8 +4,8 @@ import (
"context" "context"
"fmt" "fmt"
"git.solsynth.dev/hydrogen/identity/pkg/grpc/proto" "git.solsynth.dev/hydrogen/passport/pkg/grpc/proto"
"git.solsynth.dev/hydrogen/identity/pkg/services" "git.solsynth.dev/hydrogen/passport/pkg/services"
"github.com/spf13/viper" "github.com/spf13/viper"
) )

View File

@ -3,9 +3,9 @@ package grpc
import ( import (
"context" "context"
"fmt" "fmt"
"git.solsynth.dev/hydrogen/identity/pkg/grpc/proto" "git.solsynth.dev/hydrogen/passport/pkg/grpc/proto"
"git.solsynth.dev/hydrogen/identity/pkg/models" "git.solsynth.dev/hydrogen/passport/pkg/models"
"git.solsynth.dev/hydrogen/identity/pkg/services" "git.solsynth.dev/hydrogen/passport/pkg/services"
"github.com/samber/lo" "github.com/samber/lo"
) )

View File

@ -3,9 +3,9 @@ package grpc
import ( import (
"context" "context"
"git.solsynth.dev/hydrogen/identity/pkg/grpc/proto" "git.solsynth.dev/hydrogen/passport/pkg/grpc/proto"
"git.solsynth.dev/hydrogen/identity/pkg/models" "git.solsynth.dev/hydrogen/passport/pkg/models"
"git.solsynth.dev/hydrogen/identity/pkg/services" "git.solsynth.dev/hydrogen/passport/pkg/services"
"github.com/samber/lo" "github.com/samber/lo"
) )

View File

@ -3,7 +3,7 @@ package grpc
import ( import (
"net" "net"
"git.solsynth.dev/hydrogen/identity/pkg/grpc/proto" "git.solsynth.dev/hydrogen/passport/pkg/grpc/proto"
"github.com/spf13/viper" "github.com/spf13/viper"
"google.golang.org/grpc" "google.golang.org/grpc"
"google.golang.org/grpc/reflection" "google.golang.org/grpc/reflection"

View File

@ -1,4 +1,4 @@
package identity package passport
const ( const (
AppVersion = "1.0.0" AppVersion = "1.0.0"

View File

@ -7,8 +7,8 @@ import (
"github.com/google/uuid" "github.com/google/uuid"
"git.solsynth.dev/hydrogen/identity/pkg/database" "git.solsynth.dev/hydrogen/passport/pkg/database"
"git.solsynth.dev/hydrogen/identity/pkg/models" "git.solsynth.dev/hydrogen/passport/pkg/models"
"github.com/samber/lo" "github.com/samber/lo"
"gorm.io/datatypes" "gorm.io/datatypes"
) )

View File

@ -3,7 +3,7 @@ package security
import ( import (
"fmt" "fmt"
"git.solsynth.dev/hydrogen/identity/pkg/models" "git.solsynth.dev/hydrogen/passport/pkg/models"
"github.com/samber/lo" "github.com/samber/lo"
) )

View File

@ -9,8 +9,8 @@ import (
"github.com/spf13/viper" "github.com/spf13/viper"
) )
var CookieAccessKey = "identity_auth_key" var CookieAccessKey = "passport_auth_key"
var CookieRefreshKey = "identity_refresh_key" var CookieRefreshKey = "passport_refresh_key"
type PayloadClaims struct { type PayloadClaims struct {
jwt.RegisteredClaims jwt.RegisteredClaims

View File

@ -7,8 +7,8 @@ import (
"github.com/spf13/viper" "github.com/spf13/viper"
"git.solsynth.dev/hydrogen/identity/pkg/database" "git.solsynth.dev/hydrogen/passport/pkg/database"
"git.solsynth.dev/hydrogen/identity/pkg/models" "git.solsynth.dev/hydrogen/passport/pkg/models"
"github.com/google/uuid" "github.com/google/uuid"
"github.com/samber/lo" "github.com/samber/lo"
) )

View File

@ -5,9 +5,9 @@ import (
"strconv" "strconv"
"time" "time"
"git.solsynth.dev/hydrogen/identity/pkg/database" "git.solsynth.dev/hydrogen/passport/pkg/database"
"git.solsynth.dev/hydrogen/identity/pkg/models" "git.solsynth.dev/hydrogen/passport/pkg/models"
"git.solsynth.dev/hydrogen/identity/pkg/services" "git.solsynth.dev/hydrogen/passport/pkg/services"
"github.com/gofiber/fiber/v2" "github.com/gofiber/fiber/v2"
jsoniter "github.com/json-iterator/go" jsoniter "github.com/json-iterator/go"
"github.com/spf13/viper" "github.com/spf13/viper"

View File

@ -3,8 +3,8 @@ package server
import ( import (
"strings" "strings"
"git.solsynth.dev/hydrogen/identity/pkg/security" "git.solsynth.dev/hydrogen/passport/pkg/security"
"git.solsynth.dev/hydrogen/identity/pkg/services" "git.solsynth.dev/hydrogen/passport/pkg/services"
"github.com/gofiber/fiber/v2" "github.com/gofiber/fiber/v2"
) )

View File

@ -4,8 +4,8 @@ import (
"os" "os"
"path/filepath" "path/filepath"
"git.solsynth.dev/hydrogen/identity/pkg/database" "git.solsynth.dev/hydrogen/passport/pkg/database"
"git.solsynth.dev/hydrogen/identity/pkg/models" "git.solsynth.dev/hydrogen/passport/pkg/models"
"github.com/gofiber/fiber/v2" "github.com/gofiber/fiber/v2"
"github.com/google/uuid" "github.com/google/uuid"
"github.com/spf13/viper" "github.com/spf13/viper"

View File

@ -5,8 +5,8 @@ import (
"github.com/gofiber/fiber/v2" "github.com/gofiber/fiber/v2"
"git.solsynth.dev/hydrogen/identity/pkg/security" "git.solsynth.dev/hydrogen/passport/pkg/security"
"git.solsynth.dev/hydrogen/identity/pkg/services" "git.solsynth.dev/hydrogen/passport/pkg/services"
"github.com/samber/lo" "github.com/samber/lo"
) )
@ -70,7 +70,7 @@ func doChallenge(c *fiber.Ctx) error {
if err != nil { if err != nil {
return fiber.NewError(fiber.StatusBadRequest, err.Error()) return fiber.NewError(fiber.StatusBadRequest, err.Error())
} else if challenge.Progress >= challenge.Requirements { } else if challenge.Progress >= challenge.Requirements {
session, err := security.GrantSession(challenge, []string{"*"}, []string{"identity"}, nil, lo.ToPtr(time.Now())) session, err := security.GrantSession(challenge, []string{"*"}, []string{"passport"}, nil, lo.ToPtr(time.Now()))
if err != nil { if err != nil {
return fiber.NewError(fiber.StatusBadRequest, err.Error()) return fiber.NewError(fiber.StatusBadRequest, err.Error())
} }

View File

@ -1,7 +1,7 @@
package server package server
import ( import (
"git.solsynth.dev/hydrogen/identity/pkg/services" "git.solsynth.dev/hydrogen/passport/pkg/services"
"github.com/gofiber/fiber/v2" "github.com/gofiber/fiber/v2"
) )

View File

@ -1,8 +1,8 @@
package server package server
import ( import (
"git.solsynth.dev/hydrogen/identity/pkg/models" "git.solsynth.dev/hydrogen/passport/pkg/models"
"git.solsynth.dev/hydrogen/identity/pkg/services" "git.solsynth.dev/hydrogen/passport/pkg/services"
"github.com/gofiber/fiber/v2" "github.com/gofiber/fiber/v2"
) )

View File

@ -3,9 +3,9 @@ package server
import ( import (
"time" "time"
"git.solsynth.dev/hydrogen/identity/pkg/database" "git.solsynth.dev/hydrogen/passport/pkg/database"
"git.solsynth.dev/hydrogen/identity/pkg/models" "git.solsynth.dev/hydrogen/passport/pkg/models"
"git.solsynth.dev/hydrogen/identity/pkg/services" "git.solsynth.dev/hydrogen/passport/pkg/services"
"github.com/gofiber/fiber/v2" "github.com/gofiber/fiber/v2"
"github.com/samber/lo" "github.com/samber/lo"
) )

View File

@ -1,8 +1,8 @@
package server package server
import ( import (
"git.solsynth.dev/hydrogen/identity/pkg/models" "git.solsynth.dev/hydrogen/passport/pkg/models"
"git.solsynth.dev/hydrogen/identity/pkg/services" "git.solsynth.dev/hydrogen/passport/pkg/services"
"github.com/gofiber/fiber/v2" "github.com/gofiber/fiber/v2"
) )

View File

@ -1,8 +1,8 @@
package server package server
import ( import (
"git.solsynth.dev/hydrogen/identity/pkg/models" "git.solsynth.dev/hydrogen/passport/pkg/models"
"git.solsynth.dev/hydrogen/identity/pkg/services" "git.solsynth.dev/hydrogen/passport/pkg/services"
"github.com/gofiber/contrib/websocket" "github.com/gofiber/contrib/websocket"
"github.com/samber/lo" "github.com/samber/lo"
) )

View File

@ -4,10 +4,10 @@ import (
"strings" "strings"
"time" "time"
"git.solsynth.dev/hydrogen/identity/pkg/database" "git.solsynth.dev/hydrogen/passport/pkg/database"
"git.solsynth.dev/hydrogen/identity/pkg/models" "git.solsynth.dev/hydrogen/passport/pkg/models"
"git.solsynth.dev/hydrogen/identity/pkg/security" "git.solsynth.dev/hydrogen/passport/pkg/security"
"git.solsynth.dev/hydrogen/identity/pkg/services" "git.solsynth.dev/hydrogen/passport/pkg/services"
"github.com/gofiber/fiber/v2" "github.com/gofiber/fiber/v2"
"github.com/samber/lo" "github.com/samber/lo"
) )
@ -77,7 +77,7 @@ func doConnect(c *fiber.Ctx) error {
user, user,
client, client,
strings.Split(scope, " "), strings.Split(scope, " "),
[]string{"identity", client.Alias}, []string{"passport", client.Alias},
nil, nil,
lo.ToPtr(time.Now()), lo.ToPtr(time.Now()),
c.IP(), c.IP(),
@ -99,7 +99,7 @@ func doConnect(c *fiber.Ctx) error {
user, user,
client, client,
strings.Split(scope, " "), strings.Split(scope, " "),
[]string{"identity", client.Alias}, []string{"passport", client.Alias},
nil, nil,
lo.ToPtr(time.Now()), lo.ToPtr(time.Now()),
c.IP(), c.IP(),

View File

@ -1,8 +1,8 @@
package server package server
import ( import (
"git.solsynth.dev/hydrogen/identity/pkg/database" "git.solsynth.dev/hydrogen/passport/pkg/database"
"git.solsynth.dev/hydrogen/identity/pkg/models" "git.solsynth.dev/hydrogen/passport/pkg/models"
"github.com/gofiber/fiber/v2" "github.com/gofiber/fiber/v2"
) )

View File

@ -1,8 +1,8 @@
package server package server
import ( import (
"git.solsynth.dev/hydrogen/identity/pkg/database" "git.solsynth.dev/hydrogen/passport/pkg/database"
"git.solsynth.dev/hydrogen/identity/pkg/models" "git.solsynth.dev/hydrogen/passport/pkg/models"
"github.com/gofiber/fiber/v2" "github.com/gofiber/fiber/v2"
) )

View File

@ -6,7 +6,7 @@ import (
"strings" "strings"
"time" "time"
"git.solsynth.dev/hydrogen/identity/pkg/views" "git.solsynth.dev/hydrogen/passport/pkg/views"
"github.com/gofiber/fiber/v2" "github.com/gofiber/fiber/v2"
"github.com/gofiber/fiber/v2/middleware/cache" "github.com/gofiber/fiber/v2/middleware/cache"
"github.com/gofiber/fiber/v2/middleware/cors" "github.com/gofiber/fiber/v2/middleware/cors"

View File

@ -1,8 +1,8 @@
package server package server
import ( import (
"git.solsynth.dev/hydrogen/identity/pkg/database" "git.solsynth.dev/hydrogen/passport/pkg/database"
"git.solsynth.dev/hydrogen/identity/pkg/models" "git.solsynth.dev/hydrogen/passport/pkg/models"
"github.com/gofiber/fiber/v2" "github.com/gofiber/fiber/v2"
) )

View File

@ -4,9 +4,9 @@ import (
"fmt" "fmt"
"time" "time"
"git.solsynth.dev/hydrogen/identity/pkg/database" "git.solsynth.dev/hydrogen/passport/pkg/database"
"git.solsynth.dev/hydrogen/identity/pkg/models" "git.solsynth.dev/hydrogen/passport/pkg/models"
"git.solsynth.dev/hydrogen/identity/pkg/security" "git.solsynth.dev/hydrogen/passport/pkg/security"
"github.com/google/uuid" "github.com/google/uuid"
"github.com/samber/lo" "github.com/samber/lo"
"gorm.io/gorm" "gorm.io/gorm"

View File

@ -4,9 +4,9 @@ import (
"fmt" "fmt"
"time" "time"
"git.solsynth.dev/hydrogen/identity/pkg/database" "git.solsynth.dev/hydrogen/passport/pkg/database"
"git.solsynth.dev/hydrogen/identity/pkg/models" "git.solsynth.dev/hydrogen/passport/pkg/models"
"git.solsynth.dev/hydrogen/identity/pkg/security" "git.solsynth.dev/hydrogen/passport/pkg/security"
"github.com/gofiber/fiber/v2" "github.com/gofiber/fiber/v2"
jsoniter "github.com/json-iterator/go" jsoniter "github.com/json-iterator/go"
"github.com/rs/zerolog/log" "github.com/rs/zerolog/log"

View File

@ -1,8 +1,8 @@
package services package services
import ( import (
"git.solsynth.dev/hydrogen/identity/pkg/database" "git.solsynth.dev/hydrogen/passport/pkg/database"
"git.solsynth.dev/hydrogen/identity/pkg/models" "git.solsynth.dev/hydrogen/passport/pkg/models"
) )
func LookupChallenge(id uint) (models.AuthChallenge, error) { func LookupChallenge(id uint) (models.AuthChallenge, error) {

View File

@ -1,7 +1,7 @@
package services package services
import ( import (
"git.solsynth.dev/hydrogen/identity/pkg/database" "git.solsynth.dev/hydrogen/passport/pkg/database"
"github.com/rs/zerolog/log" "github.com/rs/zerolog/log"
"time" "time"
) )

View File

@ -3,8 +3,8 @@ package services
import ( import (
"fmt" "fmt"
"git.solsynth.dev/hydrogen/identity/pkg/database" "git.solsynth.dev/hydrogen/passport/pkg/database"
"git.solsynth.dev/hydrogen/identity/pkg/models" "git.solsynth.dev/hydrogen/passport/pkg/models"
) )
func GetThirdClient(id string) (models.ThirdClient, error) { func GetThirdClient(id string) (models.ThirdClient, error) {

View File

@ -1,7 +1,7 @@
package services package services
import ( import (
"git.solsynth.dev/hydrogen/identity/pkg/models" "git.solsynth.dev/hydrogen/passport/pkg/models"
"github.com/gofiber/contrib/websocket" "github.com/gofiber/contrib/websocket"
) )

View File

@ -1,8 +1,8 @@
package services package services
import ( import (
"git.solsynth.dev/hydrogen/identity/pkg/database" "git.solsynth.dev/hydrogen/passport/pkg/database"
"git.solsynth.dev/hydrogen/identity/pkg/models" "git.solsynth.dev/hydrogen/passport/pkg/models"
) )
func AddEvent(user models.Account, event, target, ip, ua string) models.ActionEvent { func AddEvent(user models.Account, event, target, ip, ua string) models.ActionEvent {

View File

@ -3,8 +3,8 @@ package services
import ( import (
"fmt" "fmt"
"git.solsynth.dev/hydrogen/identity/pkg/database" "git.solsynth.dev/hydrogen/passport/pkg/database"
"git.solsynth.dev/hydrogen/identity/pkg/models" "git.solsynth.dev/hydrogen/passport/pkg/models"
"github.com/google/uuid" "github.com/google/uuid"
"github.com/spf13/viper" "github.com/spf13/viper"
) )

View File

@ -3,8 +3,8 @@ package services
import ( import (
"errors" "errors"
"fmt" "fmt"
"git.solsynth.dev/hydrogen/identity/pkg/database" "git.solsynth.dev/hydrogen/passport/pkg/database"
"git.solsynth.dev/hydrogen/identity/pkg/models" "git.solsynth.dev/hydrogen/passport/pkg/models"
"gorm.io/gorm" "gorm.io/gorm"
) )

View File

@ -5,9 +5,9 @@ import (
jsoniter "github.com/json-iterator/go" jsoniter "github.com/json-iterator/go"
"firebase.google.com/go/messaging" "firebase.google.com/go/messaging"
"git.solsynth.dev/hydrogen/identity/pkg/database" "git.solsynth.dev/hydrogen/passport/pkg/database"
"git.solsynth.dev/hydrogen/identity/pkg/external" "git.solsynth.dev/hydrogen/passport/pkg/external"
"git.solsynth.dev/hydrogen/identity/pkg/models" "git.solsynth.dev/hydrogen/passport/pkg/models"
"github.com/rs/zerolog/log" "github.com/rs/zerolog/log"
) )

View File

@ -3,8 +3,8 @@ package services
import ( import (
"time" "time"
"git.solsynth.dev/hydrogen/identity/pkg/database" "git.solsynth.dev/hydrogen/passport/pkg/database"
"git.solsynth.dev/hydrogen/identity/pkg/models" "git.solsynth.dev/hydrogen/passport/pkg/models"
jsoniter "github.com/json-iterator/go" jsoniter "github.com/json-iterator/go"
"github.com/rs/zerolog/log" "github.com/rs/zerolog/log"
"github.com/spf13/viper" "github.com/spf13/viper"

View File

@ -5,8 +5,8 @@ import (
"strings" "strings"
"time" "time"
"git.solsynth.dev/hydrogen/identity/pkg/database" "git.solsynth.dev/hydrogen/passport/pkg/database"
"git.solsynth.dev/hydrogen/identity/pkg/models" "git.solsynth.dev/hydrogen/passport/pkg/models"
"github.com/google/uuid" "github.com/google/uuid"
"github.com/spf13/viper" "github.com/spf13/viper"
) )

View File

@ -1,5 +1,5 @@
{ {
"name": "@hydrogen/identity", "name": "@hydrogen/passport",
"version": "1.0.0", "version": "1.0.0",
"type": "module", "type": "module",
"scripts": { "scripts": {

View File

@ -16,11 +16,11 @@ const defaultUserinfo: Userinfo = {
} }
export function getAtk(): string { export function getAtk(): string {
return new Cookie().get("identity_auth_key") return new Cookie().get("passport_auth_key")
} }
export function checkLoggedIn(): boolean { export function checkLoggedIn(): boolean {
return new Cookie().get("identity_auth_key") return new Cookie().get("passport_auth_key")
} }
export const useUserinfo = defineStore("userinfo", () => { export const useUserinfo = defineStore("userinfo", () => {

View File

@ -32,6 +32,6 @@ access_token_duration = 300
refresh_token_duration = 2592000 refresh_token_duration = 2592000
[database] [database]
dsn = "host=localhost dbname=hy_identity port=5432 sslmode=disable" dsn = "host=localhost dbname=hy_passport port=5432 sslmode=disable"
prefix = "identity_" prefix = "passport_"
bolt = "uploads/bolt.db" bolt = "uploads/bolt.db"