mirror of
https://github.com/Telecominfraproject/wlan-cloud-ucentralsec.git
synced 2025-11-01 19:27:59 +00:00
Final token cache/revocation fix.
This commit is contained in:
@@ -70,17 +70,13 @@ namespace OpenWifi {
|
|||||||
if(!CallToken.empty()) {
|
if(!CallToken.empty()) {
|
||||||
auto Client = UserCache_.get(CallToken);
|
auto Client = UserCache_.get(CallToken);
|
||||||
if( Client.isNull() ) {
|
if( Client.isNull() ) {
|
||||||
std::cout << "Fetching token from disk and updating cache: " << CallToken << " >" <<__LINE__<< std::endl;
|
|
||||||
SecurityObjects::UserInfoAndPolicy UInfo2;
|
SecurityObjects::UserInfoAndPolicy UInfo2;
|
||||||
uint64_t RevocationDate=0;
|
uint64_t RevocationDate=0;
|
||||||
if(StorageService()->GetToken(CallToken,UInfo2,RevocationDate)) {
|
if(StorageService()->GetToken(CallToken,UInfo2,RevocationDate)) {
|
||||||
std::cout << "Fetching token from disk and updating cache: " << CallToken << " >" <<__LINE__<< std::endl;
|
|
||||||
if(RevocationDate!=0)
|
if(RevocationDate!=0)
|
||||||
return false;
|
return false;
|
||||||
Expired = (UInfo2.webtoken.created_ + UInfo2.webtoken.expires_in_) < time(nullptr);
|
Expired = (UInfo2.webtoken.created_ + UInfo2.webtoken.expires_in_) < time(nullptr);
|
||||||
std::cout << "Fetching token from disk and updating cache: " << CallToken << " >" <<__LINE__<< std::endl;
|
|
||||||
if(StorageService()->GetUserById(UInfo.userinfo.Id,UInfo.userinfo)) {
|
if(StorageService()->GetUserById(UInfo.userinfo.Id,UInfo.userinfo)) {
|
||||||
std::cout << "Fetching token from disk and updating cache: " << CallToken << " >" <<__LINE__<< std::endl;
|
|
||||||
UInfo.webtoken = UInfo2.webtoken;
|
UInfo.webtoken = UInfo2.webtoken;
|
||||||
UserCache_.update(CallToken, UInfo);
|
UserCache_.update(CallToken, UInfo);
|
||||||
SessionToken = CallToken;
|
SessionToken = CallToken;
|
||||||
@@ -89,15 +85,12 @@ namespace OpenWifi {
|
|||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
if(!Expired) {
|
if(!Expired) {
|
||||||
SessionToken = CallToken;
|
SessionToken = CallToken;
|
||||||
UInfo = *Client ;
|
UInfo = *Client ;
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
RevokeToken(CallToken);
|
RevokeToken(CallToken);
|
||||||
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
} catch(const Poco::Exception &E) {
|
} catch(const Poco::Exception &E) {
|
||||||
@@ -386,11 +379,9 @@ namespace OpenWifi {
|
|||||||
if(RevocationDate!=0)
|
if(RevocationDate!=0)
|
||||||
return false;
|
return false;
|
||||||
Expired = (UInfo.webtoken.created_ + UInfo.webtoken.expires_in_) < std::time(nullptr);
|
Expired = (UInfo.webtoken.created_ + UInfo.webtoken.expires_in_) < std::time(nullptr);
|
||||||
std::cout << "Fetching token from disk and updating cache: " << __LINE__<< std::endl;
|
|
||||||
if(StorageService()->GetUserById(UInfo.userinfo.Id,UInfo.userinfo)) {
|
if(StorageService()->GetUserById(UInfo.userinfo.Id,UInfo.userinfo)) {
|
||||||
WebToken = UInfo.webtoken;
|
WebToken = UInfo.webtoken;
|
||||||
UserCache_.update(UInfo.webtoken.access_token_, UInfo);
|
UserCache_.update(UInfo.webtoken.access_token_, UInfo);
|
||||||
std::cout << "Fetching token from disk and updating cache: " << __LINE__<< std::endl;
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -20,7 +20,7 @@ namespace OpenWifi {
|
|||||||
Server,
|
Server,
|
||||||
Internal,
|
Internal,
|
||||||
false,
|
false,
|
||||||
true, RateLimit{.Interval=1000,.MaxCalls=5}) {}
|
true, RateLimit{.Interval=1000,.MaxCalls=10}) {}
|
||||||
static const std::list<const char *> PathName() { return std::list<const char *>{"/api/v1/actionLink"}; };
|
static const std::list<const char *> PathName() { return std::list<const char *>{"/api/v1/actionLink"}; };
|
||||||
void RequestResetPassword(SecurityObjects::ActionLink &Link);
|
void RequestResetPassword(SecurityObjects::ActionLink &Link);
|
||||||
void CompleteResetPassword();
|
void CompleteResetPassword();
|
||||||
|
|||||||
@@ -21,7 +21,7 @@ namespace OpenWifi {
|
|||||||
Poco::Net::HTTPRequest::HTTP_GET,
|
Poco::Net::HTTPRequest::HTTP_GET,
|
||||||
Poco::Net::HTTPRequest::HTTP_OPTIONS},
|
Poco::Net::HTTPRequest::HTTP_OPTIONS},
|
||||||
Server,
|
Server,
|
||||||
Internal, false, true , RateLimit{.Interval=2000,.MaxCalls=5}) {}
|
Internal, false, true , RateLimit{.Interval=2000,.MaxCalls=10}) {}
|
||||||
static const std::list<const char *> PathName() { return std::list<const char *>{"/api/v1/oauth2/{token}","/api/v1/oauth2"}; };
|
static const std::list<const char *> PathName() { return std::list<const char *>{"/api/v1/oauth2/{token}","/api/v1/oauth2"}; };
|
||||||
void DoGet() final;
|
void DoGet() final;
|
||||||
void DoPost() final;
|
void DoPost() final;
|
||||||
|
|||||||
Reference in New Issue
Block a user