Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add last use of api key on webui #4124

Merged
merged 25 commits into from
Feb 16, 2023
Merged

Conversation

kevin-namba
Copy link
Contributor

What this PR does / why we need it:
Enabling us to know when api keys are created and used at last time.

Which issue(s) this PR fixes:

Fixes #4118

Does this PR introduce a user-facing change?:

add created-time and last-used-time of api keys on web-ui

@kevin-namba kevin-namba changed the title [WIP] Add last use of api key on webui Add last use of api key on webui Jan 12, 2023
@knanao
Copy link
Member

knanao commented Jan 16, 2023

@kevin55156
Great, it's better to be able to check what gRPC was called too by a API key next.

Anyway, Thank you for your nice work. 🚀

@kevin-namba kevin-namba force-pushed the add-last-use-of-api-key-on-webui branch from 092df88 to 233eeda Compare January 18, 2023 09:21
@kevin-namba
Copy link
Contributor Author

kevin-namba commented Jan 19, 2023

@kevin55156 Great, it's better to be able to check what gRPC was called too by a API key next.

Thank you, I think so, too.
I will create the new issue about this feature.
#4136

pkg/datastore/apikey.go Outdated Show resolved Hide resolved
@kevin-namba kevin-namba force-pushed the add-last-use-of-api-key-on-webui branch from 75568e6 to 78392e4 Compare February 6, 2023 09:41
}

func NewVerifier(ctx context.Context, getter apiKeyGetter, logger *zap.Logger) *Verifier {
const apiKeyLastUsedCacheHashKey = "HASHKEY:PIPED:API_KEYS" //nolint:gosec
Copy link
Member

Choose a reason for hiding this comment

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

[nits] I feel it's better to make it sharding per project.
Because it's supposed to be called per a project.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Server must decide hash key name before NewVerifier is called, but which project is not decided at that time.
Piped client is associated with one project, but defaultPipedStatHashKey does not include project id because of the same reason.

pkg/app/server/apikeyverifier/verifier.go Outdated Show resolved Hide resolved
@kevin-namba kevin-namba force-pushed the add-last-use-of-api-key-on-webui branch from 806de36 to b8b523b Compare February 9, 2023 04:13
@kevin-namba kevin-namba force-pushed the add-last-use-of-api-key-on-webui branch from 6d59e7f to ba18ca9 Compare February 9, 2023 04:36
@@ -69,7 +69,8 @@ var (
)

const (
defaultPipedStatHashKey = "HASHKEY:PIPED:STATS"
defaultPipedStatHashKey = "HASHKEY:PIPED:STATS"
apiKeyLastUsedCacheHashKey = "HASHKEY:PIPED:API_KEYS" //nolint:gosec
Copy link
Member

Choose a reason for hiding this comment

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

Just want to confirm, do we still need this nolint annotation?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yes, CI golang-cli fails without this nolint

@kevin-namba kevin-namba force-pushed the add-last-use-of-api-key-on-webui branch from ce4aa88 to c242dce Compare February 13, 2023 06:20
Copy link
Member

@khanhtc1202 khanhtc1202 left a comment

Choose a reason for hiding this comment

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

Nice work 🙌

@khanhtc1202 khanhtc1202 enabled auto-merge (squash) February 16, 2023 10:47
@khanhtc1202 khanhtc1202 merged commit 4d2a89c into master Feb 16, 2023
@khanhtc1202 khanhtc1202 deleted the add-last-use-of-api-key-on-webui branch February 16, 2023 10:50
@github-actions github-actions bot mentioned this pull request Feb 27, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Show last use of API key on API key setting page
3 participants