Skip to content

Commit 28dbe3f

Browse files
committed
update docs + remove unneeded code
1 parent 1217dcc commit 28dbe3f

File tree

3 files changed

+10
-14
lines changed

3 files changed

+10
-14
lines changed

docs/en/operations/external-authenticators/tokens.md

+7
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@ To define an access token processor, add `access_token_processors` section to `c
2424
<gogoogle>
2525
<provider>Google</provider>
2626
<email_filter>^[A-Za-z0-9._%+-]+@example\.com$</email_filter>
27+
<cache_lifetime>600</cache_lifetime>
2728
</gogoogle>
2829
<azuure>
2930
<provider>azure</provider>
@@ -41,10 +42,16 @@ Different providers have different sets of parameters.
4142
**Parameters**
4243

4344
- `provider` -- name of identity provider. Mandatory, case-insensitive. Supported options: "Google", "Azure".
45+
- `cache_lifetime` -- maximum lifetime of cached token (in seconds). Optional, default: 3600.
4446
- `email_filter` -- Regex for validation of user emails. Optional parameter, only for Google IdP.
4547
- `client_id` -- Azure AD (Entra ID) client ID. Optional parameter, only for Azure IdP.
4648
- `tenant_id` -- Azure AD (Entra ID) tenant ID. Optional parameter, only for Azure IdP.
4749

50+
### Tokens cache
51+
To reduce number of requests to IdP, tokens are cached internally for no longer then `cache_lifetime` seconds.
52+
If token expires sooner than `cache_lifetime`, then cache entry for this token will only be valid while token is valid.
53+
If token lifetime is longer than `cache_lifetime`, cache entry for this token will be valid for `cache_lifetime`.
54+
4855
## IdP as External Authenticator {#idp-external-authenticator}
4956

5057
Locally defined users can be authenticated with an access token. To allow this, `jwt` must be specified as user's authentication method. Example:

src/Access/AccessTokenProcessor.cpp

+1-3
Original file line numberDiff line numberDiff line change
@@ -115,11 +115,9 @@ std::unique_ptr<IAccessTokenProcessor> IAccessTokenProcessor::parseTokenProcesso
115115
throw Exception(ErrorCodes::INVALID_CONFIG_PARAMETER,
116116
"Could not parse access token processor {}: tenant_id must be specified", name);
117117

118-
String client_id_str = config.getString(prefix + ".client_id");
119118
String tenant_id_str = config.getString(prefix + ".tenant_id");
120-
String client_secret_str = config.hasProperty(prefix + ".client_secret") ? config.getString(prefix + ".client_secret") : "";
121119

122-
return std::make_unique<AzureAccessTokenProcessor>(name, cache_lifetime, email_regex_str, client_id_str, tenant_id_str, client_secret_str);
120+
return std::make_unique<AzureAccessTokenProcessor>(name, cache_lifetime, email_regex_str, tenant_id_str);
123121
}
124122
else
125123
throw Exception(ErrorCodes::INVALID_CONFIG_PARAMETER,

src/Access/AccessTokenProcessor.h

+2-11
Original file line numberDiff line numberDiff line change
@@ -84,23 +84,14 @@ class AzureAccessTokenProcessor : public IAccessTokenProcessor
8484
AzureAccessTokenProcessor(const String & name_,
8585
const UInt64 cache_invalidation_interval_,
8686
const String & email_regex_str,
87-
const String & client_id_,
88-
const String & tenant_id_,
89-
const String & client_secret_)
87+
const String & tenant_id_)
9088
: IAccessTokenProcessor(name_, cache_invalidation_interval_, email_regex_str),
91-
client_id(client_id_),
92-
tenant_id(tenant_id_),
93-
client_secret(client_secret_),
94-
jwks_uri_str("https://login.microsoftonline.com/" + tenant_id + "/discovery/v2.0/keys") {}
89+
jwks_uri_str("https://login.microsoftonline.com/" + tenant_id_ + "/discovery/v2.0/keys") {}
9590

9691
bool resolveAndValidate(const TokenCredentials & credentials) override;
9792
private:
9893
static const Poco::URI user_info_uri;
9994

100-
const String client_id;
101-
const String tenant_id;
102-
const String client_secret;
103-
10495
const String jwks_uri_str;
10596

10697
String validateTokenAndGetUsername(const String & token) const;

0 commit comments

Comments
 (0)