Skip to content

sn: cache session tokens authentication results in REPLICATE#4082

Draft
carpawell wants to merge 1 commit into
masterfrom
fix/session-token-caching
Draft

sn: cache session tokens authentication results in REPLICATE#4082
carpawell wants to merge 1 commit into
masterfrom
fix/session-token-caching

Conversation

@carpawell

Copy link
Copy Markdown
Member

No description provided.

Signed-off-by: Pavel Karpy <carpawell@nspcc.io>
@carpawell carpawell self-assigned this Jul 9, 2026
Comment thread pkg/core/time/time.go
@@ -0,0 +1,10 @@
package timecore

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

internal/time to me

Comment thread pkg/core/time/time.go

import "time"

// TimeProvider supplies current FS chain time without calling the chain.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

interface may have wider applications than just FS chain (even the name hints at it), so I'd give him a more general description

Comment thread internal/crypto/object.go
cache *lru.Cache[[sha256.Size]byte, error]
}

func (ch sessionV2Checker) authenticateV2Token(s *sessionv2.Token, fsChain HistoricN3ScriptRunner, tp timecore.TimeProvider) error {

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

implementation is close to already existing session cache. I expect single component for all cases

Comment thread internal/crypto/object.go
resErr, ok := ch.cache.Get(k)
if !ok {
resErr = AuthenticateTokenV2(s, fsChain)
defer func() {

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

further panic is possible or why defer?

Comment thread internal/crypto/object.go
}

currentTime := tp.Now().Round(time.Second)
if s.Exp().Before(currentTime) {

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

have these checks been done before?

@cthulhu-rider

Copy link
Copy Markdown
Contributor

missed that PR is still in draft

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants