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 config option to specify TTL for user logins #7083

Merged
merged 1 commit into from
Jul 25, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions ydb/core/protos/auth.proto
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ message TAuthConfig {
optional string UserAccountDomain = 43 [default = "passport"];
optional string ServiceDomain = 44 [default = "service"];
optional bool DomainLoginOnly = 45 [default = true];
optional string LoginTokenExpireTime = 46 [default = "12h"];
optional string RefreshPeriod = 50 [default = "1s"]; // how often we check for tickets freshness/expiration
optional string RefreshTime = 51 [default = "1h"]; // we will try to refresh valid ticket within RefreshTime/2 and RefreshTime randomly
optional string LifeTime = 52 [default = "1h"]; // for how long ticket will remain in the cache after last access
Expand Down
1 change: 1 addition & 0 deletions ydb/core/protos/flat_tx_scheme.proto
Original file line number Diff line number Diff line change
Expand Up @@ -146,6 +146,7 @@ message TEvLogin {
optional string User = 1;
optional string Password = 2;
optional string ExternalAuth = 3;
optional uint64 ExpiresAfterMs = 4;
}

message TEvLoginResult {
Expand Down
3 changes: 3 additions & 0 deletions ydb/core/security/login_shared_func.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,9 @@ NKikimrScheme::TEvLogin CreateLoginRequest(const TAuthCredentials& credentials,
}
default: {}
}
if (config.HasLoginTokenExpireTime()) {
record.SetExpiresAfterMs(TDuration::Parse(config.GetLoginTokenExpireTime()).MilliSeconds());
}
return record;
}

Expand Down
12 changes: 9 additions & 3 deletions ydb/core/tx/schemeshard/schemeshard__login.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -19,10 +19,16 @@ struct TSchemeShard::TTxLogin : TSchemeShard::TRwTxBase {
TTxType GetTxType() const override { return TXTYPE_LOGIN; }

NLogin::TLoginProvider::TLoginUserRequest GetLoginRequest() const {
const auto& record(Request->Get()->Record);
return {
.User = Request->Get()->Record.GetUser(),
.Password = Request->Get()->Record.GetPassword(),
.ExternalAuth = Request->Get()->Record.GetExternalAuth()
.User = record.GetUser(),
.Password = record.GetPassword(),
.Options = {
.ExpiresAfter = record.HasExpiresAfterMs()
? std::chrono::milliseconds(record.GetExpiresAfterMs())
: std::chrono::system_clock::duration::zero()
},
.ExternalAuth = record.GetExternalAuth(),
};
}

Expand Down
Loading