🐛 Refresh token bug

This commit is contained in:
LittleSheep 2024-10-30 23:59:16 +08:00
parent d7b1913bc3
commit 2d322f070a
4 changed files with 29 additions and 9 deletions

22
.idea/workspace.xml generated
View File

@ -4,10 +4,11 @@
<option name="autoReloadType" value="ALL" />
</component>
<component name="ChangeListManager">
<list default="true" id="3fefb2c4-b6f9-466b-a523-53352e8d6f95" name="更改" comment=":recycle: Move models.Account to sec.UserInfo">
<list default="true" id="3fefb2c4-b6f9-466b-a523-53352e8d6f95" name="更改" comment=":bug: Fix check perm panic">
<change beforePath="$PROJECT_DIR$/.idea/workspace.xml" beforeDir="false" afterPath="$PROJECT_DIR$/.idea/workspace.xml" 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/exts/auth.go" beforeDir="false" afterPath="$PROJECT_DIR$/pkg/internal/http/exts/auth.go" 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/services/ticket_token.go" beforeDir="false" afterPath="$PROJECT_DIR$/pkg/internal/services/ticket_token.go" afterDir="false" />
</list>
<option name="SHOW_DIALOG" value="false" />
<option name="HIGHLIGHT_CONFLICTS" value="true" />
@ -154,7 +155,6 @@
</option>
</component>
<component name="VcsManagerConfiguration">
<MESSAGE value=":bug: Fix daily sign batch list query issue" />
<MESSAGE value=":bug: Fix daily sign random panic" />
<MESSAGE value=":sparkles: Realm avatar, banner and access policy" />
<MESSAGE value=":sparkles: Account deletion" />
@ -179,9 +179,21 @@
<MESSAGE value=":recycle: All parts into nexus" />
<MESSAGE value=":truck: Move http server package" />
<MESSAGE value=":recycle: Move models.Account to sec.UserInfo" />
<option name="LAST_COMMIT_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" />
</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>

2
go.mod
View File

@ -3,7 +3,7 @@ module git.solsynth.dev/hydrogen/passport
go 1.23.2
require (
git.solsynth.dev/hypernet/nexus v0.0.0-20241026162044-3d487fa48baf
git.solsynth.dev/hypernet/nexus v0.0.0-20241030154425-f9b6cd2e2027
git.solsynth.dev/hypernet/pusher v0.0.0-20241026153052-cd2c326efa4e
github.com/dgraph-io/ristretto v0.1.1
github.com/eko/gocache/lib/v4 v4.1.6

6
go.sum
View File

@ -35,6 +35,12 @@ filippo.io/edwards25519 v1.1.0 h1:FNf4tywRC1HmFuKW5xopWpigGjJKiJSV0Cqo0cJWDaA=
filippo.io/edwards25519 v1.1.0/go.mod h1:BxyFTGdWcka3PhytdK4V28tE5sGfRvvvRV7EaN4VDT4=
git.solsynth.dev/hypernet/nexus v0.0.0-20241026162044-3d487fa48baf h1:Fil1ASTvxmqFySD3OoptC7uRXEYpWLwLfjlkWZNNwVQ=
git.solsynth.dev/hypernet/nexus v0.0.0-20241026162044-3d487fa48baf/go.mod h1:fXQsHXGio+7/0U95IitKF07wS4yTdCMp5ms8wpFBwVI=
git.solsynth.dev/hypernet/nexus v0.0.0-20241030153633-427c83e38fe4 h1:UTptbxd2b6RFKu0tr2RmQjNnqde/M0JVO4nZk7ntUYo=
git.solsynth.dev/hypernet/nexus v0.0.0-20241030153633-427c83e38fe4/go.mod h1:fXQsHXGio+7/0U95IitKF07wS4yTdCMp5ms8wpFBwVI=
git.solsynth.dev/hypernet/nexus v0.0.0-20241030153909-06c5fadb42c7 h1:fftdwNCLtrFGd3r0drgqrbzJphWh5Oo4A1RHRf1tu5w=
git.solsynth.dev/hypernet/nexus v0.0.0-20241030153909-06c5fadb42c7/go.mod h1:fXQsHXGio+7/0U95IitKF07wS4yTdCMp5ms8wpFBwVI=
git.solsynth.dev/hypernet/nexus v0.0.0-20241030154425-f9b6cd2e2027 h1:F0mKuUpoRm+Nj0M4xNa2CkrXSmeONpIHwrvzwSKeux4=
git.solsynth.dev/hypernet/nexus v0.0.0-20241030154425-f9b6cd2e2027/go.mod h1:fXQsHXGio+7/0U95IitKF07wS4yTdCMp5ms8wpFBwVI=
git.solsynth.dev/hypernet/pusher v0.0.0-20241026153052-cd2c326efa4e h1:DtHhMjgxS/spUt/KEdbRFtaVnepI6Vx8pbHdJaNH1hs=
git.solsynth.dev/hypernet/pusher v0.0.0-20241026153052-cd2c326efa4e/go.mod h1:XHTqFU/vBe4JiuAjl87GUcL8+w/IizSNoqH6n3WkQFc=
github.com/BurntSushi/toml v0.3.1/go.mod h1:xHWCNGjB5oqiDr8zfno3MHue2Ht5sIBksp03qcyfWMU=

View File

@ -102,10 +102,12 @@ func RefreshToken(token string) (atk, rtk string, err error) {
}
var ticket models.AuthTicket
var claims PayloadClaims
if claims, err = sec.ReadJwt[PayloadClaims](EReader, token); err != nil {
var claims *PayloadClaims
if claims, err = sec.ReadJwt(EReader, token, &PayloadClaims{}); err != nil {
return
} else if claims.Type != JwtRefreshType {
}
if claims.Type != JwtRefreshType {
err = fmt.Errorf("invalid token type, expected refresh token")
return
} else if err = database.C.Where(models.AuthTicket{