mirror of
https://github.com/Telecominfraproject/wlan-cloud-ucentralsec.git
synced 2025-10-29 18:02:29 +00:00
Fixing token revocatiopn/
This commit is contained in:
@@ -68,16 +68,21 @@ namespace OpenWifi {
|
||||
}
|
||||
|
||||
if(!CallToken.empty()) {
|
||||
if(StorageService()->IsTokenRevoked(CallToken))
|
||||
return false;
|
||||
auto Client = UserCache_.get(CallToken);
|
||||
if( Client.isNull() ) {
|
||||
std::cout << "Fetching token from disk and updating cache: " << CallToken << " >" <<__LINE__<< std::endl;
|
||||
if(StorageService()->GetToken(CallToken,UInfo)) {
|
||||
SecurityObjects::UserInfoAndPolicy UInfo2;
|
||||
uint64_t RevocationDate=0;
|
||||
if(StorageService()->GetToken(CallToken,UInfo2,RevocationDate)) {
|
||||
std::cout << "Fetching token from disk and updating cache: " << CallToken << " >" <<__LINE__<< std::endl;
|
||||
if(RevocationDate!=0)
|
||||
return false;
|
||||
Expired = (Client->webtoken.created_ + Client->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)) {
|
||||
std::cout << "Fetching token from disk and updating cache: " << CallToken << " >" <<__LINE__<< std::endl;
|
||||
UserCache_.update(UInfo.webtoken.access_token_, UInfo);
|
||||
UInfo.webtoken = UInfo2.webtoken;
|
||||
UserCache_.update(CallToken, UInfo);
|
||||
SessionToken = CallToken;
|
||||
return true;
|
||||
}
|
||||
@@ -376,7 +381,10 @@ namespace OpenWifi {
|
||||
|
||||
// get the token from disk...
|
||||
SecurityObjects::UserInfoAndPolicy UInfo;
|
||||
if(StorageService()->GetToken(TToken, UInfo)) {
|
||||
uint64_t RevocationDate=0;
|
||||
if(StorageService()->GetToken(TToken, UInfo, RevocationDate)) {
|
||||
if(RevocationDate!=0)
|
||||
return false;
|
||||
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)) {
|
||||
|
||||
@@ -117,7 +117,7 @@ namespace OpenWifi {
|
||||
bool IsTokenRevoked( std::string & Token );
|
||||
bool CleanExpiredTokens();
|
||||
bool RevokeAllTokens( std::string & UserName );
|
||||
bool GetToken(std::string &Token, SecurityObjects::UserInfoAndPolicy &UInfo);
|
||||
bool GetToken(std::string &Token, SecurityObjects::UserInfoAndPolicy &UInfo, uint64_t &RevocationDate);
|
||||
|
||||
/*
|
||||
* All ActionLinks functions
|
||||
|
||||
@@ -42,14 +42,13 @@ namespace OpenWifi {
|
||||
return false;
|
||||
}
|
||||
|
||||
bool Storage::GetToken(std::string &Token, SecurityObjects::UserInfoAndPolicy &UInfo) {
|
||||
bool Storage::GetToken(std::string &Token, SecurityObjects::UserInfoAndPolicy &UInfo, uint64_t &RevocationDate) {
|
||||
try {
|
||||
|
||||
Poco::Data::Session Sess = Pool_->get();
|
||||
Poco::Data::Statement Select(Sess);
|
||||
|
||||
uint32_t RevocationDate = 0 ;
|
||||
|
||||
RevocationDate = 0 ;
|
||||
std::string St2{"SELECT " + AllTokensValuesForSelect + " From Tokens WHERE Token=?"};
|
||||
Select << ConvertParams(St2),
|
||||
Poco::Data::Keywords::into(UInfo.webtoken.access_token_),
|
||||
|
||||
Reference in New Issue
Block a user