Commit Graph

36 Commits

Author SHA1 Message Date
Junhyun Shim ce652fa284 Replace AuthZ's use of tenant names in token with tenant ID
Also, to minimize audit log loss, handle token usage audit logging at each usage.
This has a side-effect of making the token use log less bursty.
This also subtly changes the dedup cache policy.
Dedup time window used to be 5 seconds (default) since the start of batch-logging.
Now it's 5 seconds from the first usage since the closing of the previous dedup window
2023-02-03 21:46:31 +01:00
sfc-gh-tclinkenbeard b2222a5249 Remove rare annotations from Token code 2023-01-18 11:39:02 -08:00
Junhyun Shim 48f387d4bf Merge remote-tracking branch 'origin/main' into mako-authz-token-generation 2022-12-07 09:06:39 +01:00
Daniel Luan 4be05e5a5d Upgrade C++ Standard to 20 2022-12-06 14:19:06 -08:00
Junhyun Shim 03f0696a4b Isolate TokenSpec such that it doesn't depend on flow headers 2022-11-24 15:08:07 +01:00
Junhyun Shim a4157e0c51 Expose TokenSign as a public library to be used by Mako 2022-11-21 14:33:45 +01:00
Junhyun Shim 16e6ad6afc Add decorator to new code probes 2022-11-15 23:05:12 +01:00
Junhyun Shim 50f4021cf7 Make token's 'tenants' field base64-encoded (cf. base64url)
- Remove redundant operation from TokenSign
- Let the sign/verify API directly report errors
  instead of tracing at failing subroutine, which lacks context
2022-11-04 20:17:08 +01:00
Markus Pilman 59ce49913a
Merge pull request #8146 from sfc-gh-tclinkenbeard/improve-code-coverage
Increase the number of unit tests run in `RandomUnitTests.toml`
2022-09-12 15:10:47 -06:00
sfc-gh-tclinkenbeard 39c6989673 Remove some simulation unit tests.
These tests should not be run in simulation, because they either run too
long or break determinism.
2022-09-11 00:36:18 -07:00
Junhyun Shim 727e000b2a Apply clang format 2022-09-09 15:31:29 +02:00
Junhyun Shim 89800dbb03 Cover TokenCache code probes unhit by unit test
* Token with invalid signature
* Valid token doesn't reference tenant
2022-09-09 15:30:07 +02:00
Junhyun Shim b4e428fa33 Address review comments
- Revert JWT timestamp from double back to uint64_t
- Describe in comment the need for wait loop at the beginning of watchPublicKeyJwksFile()
- Revert CLI args definition in fdbserver.actor.cpp that was
  incorrectly tabbed with a bad clang-format run
2022-08-29 12:49:03 +02:00
Junhyun Shim c2f577dac8 Add key type and DS algorithm dimension to TokenSign benchmark
Also
- Measure performance with RSA keys
- Make RSA key 2048 > 4096 bits
2022-08-26 22:58:36 +02:00
Junhyun Shim 9a13f6d2cf Include signing performance in TokenSign benchmark 2022-08-26 15:32:35 +02:00
Junhyun Shim 1f5e7d7817 Do float-aware equality comparison with token timestamps 2022-08-24 00:47:05 +02:00
Junhyun Shim 37ff1c2eb6 Add DER-P1363 sig conversion to EC token sign/verify
OpenSSL generates ASN1.DER, JWS generates P1363
2022-08-18 14:26:38 +02:00
Junhyun Shim 62f8f01ed8 Fix token parser only allowing uint64 2022-08-17 20:23:51 +02:00
Markus Pilman b600966cf9 fix token cache unit test 2022-07-29 12:47:55 -06:00
Junhyun Shim da16c59059 Fix Windows build error 2022-07-27 21:13:17 +02:00
Junhyun Shim 11a9fe9aff Move JWT "kid" field from claims to header 2022-07-13 20:21:27 +02:00
Junhyun Shim 24317aa6be Fix incorrect signature extraction function 2022-07-13 19:28:00 +02:00
Markus Pilman 2edbcf2c65
Merge pull request #44 from apple/main
Merge main
2022-07-12 07:51:22 -06:00
Junhyun Shim 545a9a8043 Fix bugs and add token timeout-in-cache test 2022-07-11 16:58:04 +02:00
Junhyun Shim 61f3d14ec6 Add TokenCache test
Add function authz::jwt::TokenRef::toStringRef() for token tracing
Add StringRef::toStringView()
2022-07-11 13:42:41 +02:00
Junhyun Shim db449b80f7
Authz JWKS (#7519)
* Add JsonWebKeySet parser/stringifier

* Update header directory

* Make JWKS parser correctness clean for OpenSSL 1.x

Add RSA keygen support

* Make JWKS parser correctness clean for OpenSSL 3.x

+extend unique_ptr for scoped destruction of OpenSSL objects

* Use PKey::{sign|verify}() in TokenSign

* Apply AutoCPointer to MkCert

* Apply Clang format

* JWKS::toStringRef() returns StringRef > Optional<StringRef>

* Fix Mac/Windows build error

* Fix incorrect fix of Mac build

* Fix filename in license comment for AutoCPointer.h

* Refactor complex C macros into function templates
2022-07-05 10:13:09 +02:00
Markus Pilman 13d8b13722 Migrated Authz code to use JWT 2022-06-13 18:20:27 -06:00
Junhyun Shim 3e79735b2f
Authz JWT support (#7279)
* Add JWT support to TokenSign

* Encapsulate OpenSSL public/private key type

Type-safe passing around of keys without having to DER/PEM-serialize
(OpenSSL doesn't have distinct types for public and private key)

* Apply Clang format

* Add verify benchmark for JWT and FlatBuffers token

* Unit test base64url::{encode, decode}

* Make all payload fields optional

Let user code validate non-signature fields

* Make all payload fields optional

Completely defer field check to user code

* Move rapidjson from fdbclient to contrib

* Make fdbrpc's rapidjson linkage private

Currently only sources include them.

* Modify rapidjson path in apiversioner.py

* Algorithm::Unknown > Algorithm::UNKNOWN
2022-06-02 13:22:50 +02:00
Junhyun Shim 6459e840dc Merge remote-tracking branch 'remotes/origin/main' into mtls-test-helpers 2022-05-11 16:00:17 +02:00
Junhyun Shim 8789232df4 Add ScopeExit to flow and remove scattered impls 2022-05-11 11:51:11 +02:00
Sam Gwydir b1ce3fc15a WolfSSL fix for TokenSign 2022-05-09 13:57:03 -07:00
Junhyun Shim 41d1c73b9c Fix TokenSign copying and using uninitialized arena
TokenSign was copying unused Arena held by Standalone instead of refering to it.
An Arena has to be used at least once before it holds a valid, copyable reference.
Otherwise the lifecycle of the copied Arena would be its own and not be shared with the original.
Thus, when the copied arena went out of scope,
the memory supposed to be held by returned Standalone also got released.

Fix: instead of copying, refer to Standalone's arena.
2022-05-02 09:48:43 +02:00
Junhyun Shim edc659d339 Use camelCase & move error code to 6xxx 2022-04-13 21:11:52 +02:00
Junhyun Shim 410a422bd7 Use Standalone instead of embedded Arenas
- Repeat TokenSign test 100 times per run instead of 1
- Test for verify fail case
2022-03-25 14:03:37 +01:00
Junhyun Shim 9f3fa5ba9b Fix clang format 2022-03-24 19:12:34 +01:00
Junhyun Shim 99fe104f98 Sign and verify auth tokens for multi-tenant FDB 2022-03-24 19:04:00 +01:00