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

chore(auth): Rework auth cache solutions #401

Open
wants to merge 6 commits into
base: main
Choose a base branch
from

Conversation

javorszky
Copy link
Contributor

@javorszky javorszky commented Mar 20, 2023

Fixes #395

This PR reworks the authentication. Previously it was

request -> API authentication -> cache check?

Now it's

request -> Auth Cache? -> API auth check if cache didn't have it

This way the cache layer only needs to know that there is an embedded, or a deeper authorizer implementation, but it doesn't need to know, or care, what that is. Technically we could have 3847 layers of caching before we do an API call. It's interfaces all the way down.

Cache implementations

There are two of them:

They are well tested, concurrently usable, and fast. We also can then remove the custom cache implementation, which is also part of this PR.

Why?

More maintainability, composability, decoupling the cache from the live version, and removing homegrown code and relying on well tested community codebases. In go-cache's case, slight performance improvement too!

Bench test results

On my computer, it is as follows:

goos: darwin
goarch: arm64
pkg: github.com/suborbital/e2core/e2core/auth
Benchmark
Benchmark/using_Go_cache
Benchmark/using_Go_cache-10          2328092       506.5 ns/op
Benchmark/using_Big_cache
Benchmark/using_Big_cache-10          121790      9769   ns/op

// this is the current implementation. Does not exist in this codebase
BenchmarkCachedAuthorizer
BenchmarkCachedAuthorizer-10         2102755       576.6 ns/op
// end of current implementation

PASS

For benchmark code for current implementation, see #402

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.

e2core execution needs environment in the ident, and authentication is broken
2 participants