comparison Plugin/CachedAuthorizationService.cpp @ 113:43154740ea2e

wip: checking labels
author Alain Mazy <am@osimis.io>
date Tue, 05 Sep 2023 12:48:20 +0200
parents 7381a7674b36
children 0eed78c1e177
comparison
equal deleted inserted replaced
112:572955904411 113:43154740ea2e
121 return decorated_->GetUserProfileInternal(validity, profile, token, tokenValue); 121 return decorated_->GetUserProfileInternal(validity, profile, token, tokenValue);
122 } 122 }
123 123
124 bool CachedAuthorizationService::HasUserPermissionInternal(unsigned int& validity, 124 bool CachedAuthorizationService::HasUserPermissionInternal(unsigned int& validity,
125 const std::string& permission, 125 const std::string& permission,
126 const Token* token, 126 const UserProfile& profile)
127 const std::string& tokenValue)
128 { 127 {
129 assert(decorated_.get() != NULL); 128 assert(decorated_.get() != NULL);
130 129
131 std::string key = ComputeKey(permission, token, tokenValue); 130 Token token(profile.tokenType, profile.tokenKey);
131 std::string key = ComputeKey(permission, &token, profile.tokenValue);
132 std::string value; 132 std::string value;
133 133
134 if (cache_->Retrieve(value, key)) 134 if (cache_->Retrieve(value, key))
135 { 135 {
136 // Return the previously cached value 136 // Return the previously cached value
137 return (value == "1"); 137 return (value == "1");
138 } 138 }
139 139
140 bool granted = decorated_->HasUserPermissionInternal(validity, permission, token, tokenValue); 140 bool granted = decorated_->HasUserPermissionInternal(validity, permission, profile);
141 141
142 if (granted) 142 if (granted)
143 { 143 {
144 if (validity > 0) 144 if (validity > 0)
145 { 145 {