🚚 Rename package

This commit is contained in:
LittleSheep 2024-02-18 11:20:22 +08:00
parent 3437d32273
commit 55a20e18bb
32 changed files with 1747 additions and 65 deletions

View File

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

View File

@ -2,7 +2,7 @@
<project version="4"> <project version="4">
<component name="ProjectModuleManager"> <component name="ProjectModuleManager">
<modules> <modules>
<module fileurl="file://$PROJECT_DIR$/.idea/Passport.iml" filepath="$PROJECT_DIR$/.idea/Passport.iml" /> <module fileurl="file://$PROJECT_DIR$/.idea/Identity.iml" filepath="$PROJECT_DIR$/.idea/Identity.iml" />
</modules> </modules>
</component> </component>
</project> </project>

View File

@ -1,5 +1,5 @@
# Building Backend # Building Backend
FROM golang:alpine as passport-server FROM golang:alpine as identity-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=passport-server /dist /passport/server COPY --from=identity-server /dist /identity/server
EXPOSE 8444 EXPOSE 8444
CMD ["/passport/server"] CMD ["/identity/server"]

2
go.mod
View File

@ -1,4 +1,4 @@
module code.smartsheep.studio/hydrogen/passport module code.smartsheep.studio/hydrogen/identity
go 1.21.5 go 1.21.5

View File

@ -1,14 +1,14 @@
package main package main
import ( import (
"code.smartsheep.studio/hydrogen/passport/pkg/external" "code.smartsheep.studio/hydrogen/identity/pkg/external"
"code.smartsheep.studio/hydrogen/passport/pkg/server" "code.smartsheep.studio/hydrogen/identity/pkg/server"
"os" "os"
"os/signal" "os/signal"
"syscall" "syscall"
passport "code.smartsheep.studio/hydrogen/passport/pkg" identity "code.smartsheep.studio/hydrogen/identity/pkg"
"code.smartsheep.studio/hydrogen/passport/pkg/database" "code.smartsheep.studio/hydrogen/identity/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"
@ -51,11 +51,11 @@ func main() {
go server.Listen() go server.Listen()
// Messages // Messages
log.Info().Msgf("Passport v%s is started...", passport.AppVersion) log.Info().Msgf("Passport v%s is started...", identity.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("Passport v%s is quitting...", passport.AppVersion) log.Info().Msgf("Passport v%s is quitting...", identity.AppVersion)
} }

View File

@ -1,7 +1,7 @@
package database package database
import ( import (
"code.smartsheep.studio/hydrogen/passport/pkg/models" "code.smartsheep.studio/hydrogen/identity/pkg/models"
"gorm.io/gorm" "gorm.io/gorm"
) )

View File

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

View File

@ -4,8 +4,8 @@ import (
"fmt" "fmt"
"time" "time"
"code.smartsheep.studio/hydrogen/passport/pkg/database" "code.smartsheep.studio/hydrogen/identity/pkg/database"
"code.smartsheep.studio/hydrogen/passport/pkg/models" "code.smartsheep.studio/hydrogen/identity/pkg/models"
"github.com/samber/lo" "github.com/samber/lo"
"gorm.io/datatypes" "gorm.io/datatypes"
) )

View File

@ -1,7 +1,7 @@
package security package security
import ( import (
"code.smartsheep.studio/hydrogen/passport/pkg/models" "code.smartsheep.studio/hydrogen/identity/pkg/models"
"fmt" "fmt"
"github.com/samber/lo" "github.com/samber/lo"
) )

View File

@ -5,8 +5,8 @@ import (
"strconv" "strconv"
"time" "time"
"code.smartsheep.studio/hydrogen/passport/pkg/database" "code.smartsheep.studio/hydrogen/identity/pkg/database"
"code.smartsheep.studio/hydrogen/passport/pkg/models" "code.smartsheep.studio/hydrogen/identity/pkg/models"
"github.com/google/uuid" "github.com/google/uuid"
"github.com/samber/lo" "github.com/samber/lo"
) )

View File

@ -1,9 +1,9 @@
package server package server
import ( import (
"code.smartsheep.studio/hydrogen/passport/pkg/database" "code.smartsheep.studio/hydrogen/identity/pkg/database"
"code.smartsheep.studio/hydrogen/passport/pkg/models" "code.smartsheep.studio/hydrogen/identity/pkg/models"
"code.smartsheep.studio/hydrogen/passport/pkg/services" "code.smartsheep.studio/hydrogen/identity/pkg/services"
"fmt" "fmt"
"github.com/gofiber/fiber/v2" "github.com/gofiber/fiber/v2"
jsoniter "github.com/json-iterator/go" jsoniter "github.com/json-iterator/go"

View File

@ -1,8 +1,8 @@
package server package server
import ( import (
"code.smartsheep.studio/hydrogen/passport/pkg/security" "code.smartsheep.studio/hydrogen/identity/pkg/security"
"code.smartsheep.studio/hydrogen/passport/pkg/services" "code.smartsheep.studio/hydrogen/identity/pkg/services"
"github.com/gofiber/fiber/v2" "github.com/gofiber/fiber/v2"
"github.com/gofiber/fiber/v2/middleware/keyauth" "github.com/gofiber/fiber/v2/middleware/keyauth"
) )

View File

@ -1,8 +1,8 @@
package server package server
import ( import (
"code.smartsheep.studio/hydrogen/passport/pkg/database" "code.smartsheep.studio/hydrogen/identity/pkg/database"
"code.smartsheep.studio/hydrogen/passport/pkg/models" "code.smartsheep.studio/hydrogen/identity/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

@ -4,8 +4,8 @@ import (
"github.com/gofiber/fiber/v2" "github.com/gofiber/fiber/v2"
"time" "time"
"code.smartsheep.studio/hydrogen/passport/pkg/security" "code.smartsheep.studio/hydrogen/identity/pkg/security"
"code.smartsheep.studio/hydrogen/passport/pkg/services" "code.smartsheep.studio/hydrogen/identity/pkg/services"
"github.com/samber/lo" "github.com/samber/lo"
) )
@ -69,7 +69,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{"passport"}, nil, lo.ToPtr(time.Now())) session, err := security.GrantSession(challenge, []string{"*"}, []string{"identity"}, 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 (
"code.smartsheep.studio/hydrogen/passport/pkg/services" "code.smartsheep.studio/hydrogen/identity/pkg/services"
"github.com/gofiber/fiber/v2" "github.com/gofiber/fiber/v2"
) )

View File

@ -1,9 +1,9 @@
package server package server
import ( import (
"code.smartsheep.studio/hydrogen/passport/pkg/database" "code.smartsheep.studio/hydrogen/identity/pkg/database"
"code.smartsheep.studio/hydrogen/passport/pkg/models" "code.smartsheep.studio/hydrogen/identity/pkg/models"
"code.smartsheep.studio/hydrogen/passport/pkg/services" "code.smartsheep.studio/hydrogen/identity/pkg/services"
"github.com/gofiber/fiber/v2" "github.com/gofiber/fiber/v2"
"github.com/samber/lo" "github.com/samber/lo"
"time" "time"

View File

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

View File

@ -1,10 +1,10 @@
package server package server
import ( import (
"code.smartsheep.studio/hydrogen/passport/pkg/database" "code.smartsheep.studio/hydrogen/identity/pkg/database"
"code.smartsheep.studio/hydrogen/passport/pkg/models" "code.smartsheep.studio/hydrogen/identity/pkg/models"
"code.smartsheep.studio/hydrogen/passport/pkg/security" "code.smartsheep.studio/hydrogen/identity/pkg/security"
"code.smartsheep.studio/hydrogen/passport/pkg/services" "code.smartsheep.studio/hydrogen/identity/pkg/services"
"github.com/gofiber/fiber/v2" "github.com/gofiber/fiber/v2"
"github.com/samber/lo" "github.com/samber/lo"
"strings" "strings"
@ -76,7 +76,7 @@ func doConnect(c *fiber.Ctx) error {
user, user,
client, client,
strings.Split(scope, " "), strings.Split(scope, " "),
[]string{"passport", client.Alias}, []string{"identity", client.Alias},
nil, nil,
lo.ToPtr(time.Now()), lo.ToPtr(time.Now()),
c.IP(), c.IP(),
@ -98,7 +98,7 @@ func doConnect(c *fiber.Ctx) error {
user, user,
client, client,
strings.Split(scope, " "), strings.Split(scope, " "),
[]string{"passport", client.Alias}, []string{"identity", 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 (
"code.smartsheep.studio/hydrogen/passport/pkg/database" "code.smartsheep.studio/hydrogen/identity/pkg/database"
"code.smartsheep.studio/hydrogen/passport/pkg/models" "code.smartsheep.studio/hydrogen/identity/pkg/models"
"github.com/gofiber/fiber/v2" "github.com/gofiber/fiber/v2"
) )

View File

@ -1,7 +1,7 @@
package server package server
import ( import (
"code.smartsheep.studio/hydrogen/passport/pkg/view" "code.smartsheep.studio/hydrogen/identity/pkg/view"
"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,9 +1,9 @@
package services package services
import ( import (
"code.smartsheep.studio/hydrogen/passport/pkg/database" "code.smartsheep.studio/hydrogen/identity/pkg/database"
"code.smartsheep.studio/hydrogen/passport/pkg/models" "code.smartsheep.studio/hydrogen/identity/pkg/models"
"code.smartsheep.studio/hydrogen/passport/pkg/security" "code.smartsheep.studio/hydrogen/identity/pkg/security"
"fmt" "fmt"
"github.com/google/uuid" "github.com/google/uuid"
"github.com/samber/lo" "github.com/samber/lo"

View File

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

View File

@ -1,8 +1,8 @@
package services package services
import ( import (
"code.smartsheep.studio/hydrogen/passport/pkg/database" "code.smartsheep.studio/hydrogen/identity/pkg/database"
"code.smartsheep.studio/hydrogen/passport/pkg/models" "code.smartsheep.studio/hydrogen/identity/pkg/models"
"fmt" "fmt"
) )

View File

@ -1,8 +1,8 @@
package services package services
import ( import (
"code.smartsheep.studio/hydrogen/passport/pkg/database" "code.smartsheep.studio/hydrogen/identity/pkg/database"
"code.smartsheep.studio/hydrogen/passport/pkg/models" "code.smartsheep.studio/hydrogen/identity/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

@ -1,8 +1,8 @@
package services package services
import ( import (
"code.smartsheep.studio/hydrogen/passport/pkg/database" "code.smartsheep.studio/hydrogen/identity/pkg/database"
"code.smartsheep.studio/hydrogen/passport/pkg/models" "code.smartsheep.studio/hydrogen/identity/pkg/models"
"fmt" "fmt"
"github.com/google/uuid" "github.com/google/uuid"
"github.com/spf13/viper" "github.com/spf13/viper"

View File

@ -1,9 +1,9 @@
package services package services
import ( import (
"code.smartsheep.studio/hydrogen/passport/pkg/database" "code.smartsheep.studio/hydrogen/identity/pkg/database"
"code.smartsheep.studio/hydrogen/passport/pkg/external" "code.smartsheep.studio/hydrogen/identity/pkg/external"
"code.smartsheep.studio/hydrogen/passport/pkg/models" "code.smartsheep.studio/hydrogen/identity/pkg/models"
"context" "context"
"firebase.google.com/go/messaging" "firebase.google.com/go/messaging"
"github.com/rs/zerolog/log" "github.com/rs/zerolog/log"

View File

@ -1,8 +1,8 @@
package services package services
import ( import (
"code.smartsheep.studio/hydrogen/passport/pkg/database" "code.smartsheep.studio/hydrogen/identity/pkg/database"
"code.smartsheep.studio/hydrogen/passport/pkg/models" "code.smartsheep.studio/hydrogen/identity/pkg/models"
) )
func LookupSessionWithToken(tokenId string) (models.AuthSession, error) { func LookupSessionWithToken(tokenId string) (models.AuthSession, error) {

View File

@ -1,8 +1,8 @@
package services package services
import ( import (
"code.smartsheep.studio/hydrogen/passport/pkg/database" "code.smartsheep.studio/hydrogen/identity/pkg/database"
"code.smartsheep.studio/hydrogen/passport/pkg/models" "code.smartsheep.studio/hydrogen/identity/pkg/models"
"fmt" "fmt"
"github.com/google/uuid" "github.com/google/uuid"
"github.com/spf13/viper" "github.com/spf13/viper"

View File

@ -1,5 +1,5 @@
{ {
"name": "@hydrogen/passport-web", "name": "@hydrogen/identity-web",
"private": true, "private": true,
"version": "0.0.0", "version": "0.0.0",
"type": "module", "type": "module",

1682
pkg/view/yarn.lock Normal file

File diff suppressed because it is too large Load Diff

View File

@ -22,8 +22,8 @@ username = "alphabot@smartsheep.studio"
password = "gz937Zxxzfcd9SeH" password = "gz937Zxxzfcd9SeH"
[database] [database]
dsn = "host=localhost dbname=hy_passport port=5432 sslmode=disable" dsn = "host=localhost dbname=hy_identity port=5432 sslmode=disable"
prefix = "passport_" prefix = "identity_"
[[directory]] [[directory]]
name = "Goatpass" name = "Goatpass"