Skip to content

Commit 20af1f5

Browse files
authored
add config option to specify TTL for user logins (#7083) (#7485)
1 parent c68c520 commit 20af1f5

File tree

4 files changed

+14
-3
lines changed

4 files changed

+14
-3
lines changed

ydb/core/protos/auth.proto

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,7 @@ message TAuthConfig {
3232
optional string UserAccountDomain = 43 [default = "passport"];
3333
optional string ServiceDomain = 44 [default = "service"];
3434
optional bool DomainLoginOnly = 45 [default = true];
35+
optional string LoginTokenExpireTime = 46 [default = "12h"];
3536
optional string RefreshPeriod = 50 [default = "1s"]; // how often we check for tickets freshness/expiration
3637
optional string RefreshTime = 51 [default = "1h"]; // we will try to refresh valid ticket within RefreshTime/2 and RefreshTime randomly
3738
optional string LifeTime = 52 [default = "1h"]; // for how long ticket will remain in the cache after last access

ydb/core/protos/flat_tx_scheme.proto

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -146,6 +146,7 @@ message TEvLogin {
146146
optional string User = 1;
147147
optional string Password = 2;
148148
optional string ExternalAuth = 3;
149+
optional uint64 ExpiresAfterMs = 4;
149150
}
150151

151152
message TEvLoginResult {

ydb/core/security/login_shared_func.cpp

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,9 @@ NKikimrScheme::TEvLogin CreateLoginRequest(const TAuthCredentials& credentials,
3838
}
3939
default: {}
4040
}
41+
if (config.HasLoginTokenExpireTime()) {
42+
record.SetExpiresAfterMs(TDuration::Parse(config.GetLoginTokenExpireTime()).MilliSeconds());
43+
}
4144
return record;
4245
}
4346

ydb/core/tx/schemeshard/schemeshard__login.cpp

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -20,10 +20,16 @@ struct TSchemeShard::TTxLogin : TSchemeShard::TRwTxBase {
2020
TTxType GetTxType() const override { return TXTYPE_LOGIN; }
2121

2222
NLogin::TLoginProvider::TLoginUserRequest GetLoginRequest() const {
23+
const auto& record(Request->Get()->Record);
2324
return {
24-
.User = Request->Get()->Record.GetUser(),
25-
.Password = Request->Get()->Record.GetPassword(),
26-
.ExternalAuth = Request->Get()->Record.GetExternalAuth()
25+
.User = record.GetUser(),
26+
.Password = record.GetPassword(),
27+
.Options = {
28+
.ExpiresAfter = record.HasExpiresAfterMs()
29+
? std::chrono::milliseconds(record.GetExpiresAfterMs())
30+
: std::chrono::system_clock::duration::zero()
31+
},
32+
.ExternalAuth = record.GetExternalAuth(),
2733
};
2834
}
2935

0 commit comments

Comments
 (0)