Mercurial > hg > orthanc-authorization
comparison Plugin/AuthorizationWebService.h @ 71:30fb3ce960d9
configurable user permissions
author | Alain Mazy <am@osimis.io> |
---|---|
date | Wed, 22 Feb 2023 13:13:38 +0100 |
parents | af44dce56328 |
children | e381ba725669 |
comparison
equal
deleted
inserted
replaced
70:786b202ef24e | 71:30fb3ce960d9 |
---|---|
16 * along with this program. If not, see <http://www.gnu.org/licenses/>. | 16 * along with this program. If not, see <http://www.gnu.org/licenses/>. |
17 **/ | 17 **/ |
18 | 18 |
19 #pragma once | 19 #pragma once |
20 | 20 |
21 #include "IAuthorizationService.h" | 21 #include "BaseAuthorizationService.h" |
22 #include <Compatibility.h> | |
22 | 23 |
23 namespace OrthancPlugins | 24 namespace OrthancPlugins |
24 { | 25 { |
25 class AuthorizationWebService : public IAuthorizationService | 26 class AuthorizationWebService : public BaseAuthorizationService |
26 { | 27 { |
27 private: | 28 private: |
28 std::string url_; | 29 std::string url_; |
29 std::string username_; | 30 std::string username_; |
30 std::string password_; | 31 std::string password_; |
31 std::string identifier_; | 32 std::string identifier_; |
32 std::string userProfileUrl_; | 33 std::string userProfileUrl_; |
33 | 34 |
34 bool IsGrantedInternal(unsigned int& validity, | 35 protected: |
36 virtual bool IsGrantedInternal(unsigned int& validity, | |
35 OrthancPluginHttpMethod method, | 37 OrthancPluginHttpMethod method, |
36 const AccessedResource& access, | 38 const AccessedResource& access, |
37 const Token* token, | 39 const Token* token, |
38 const std::string& tokenValue); | 40 const std::string& tokenValue) ORTHANC_OVERRIDE; |
39 | 41 |
42 virtual bool GetUserProfileInternal(unsigned int& validity, | |
43 Json::Value& profile /* out */, | |
44 const Token* token, | |
45 const std::string& tokenValue) ORTHANC_OVERRIDE; | |
46 | |
47 virtual bool HasUserPermissionInternal(unsigned int& validity, | |
48 const std::string& permission, | |
49 const Token* token, | |
50 const std::string& tokenValue) ORTHANC_OVERRIDE; | |
51 | |
40 public: | 52 public: |
41 AuthorizationWebService(const std::string& url) : | 53 AuthorizationWebService(const std::string& url) : |
42 url_(url) | 54 url_(url) |
43 { | 55 { |
44 } | 56 } |
47 const std::string& password); | 59 const std::string& password); |
48 | 60 |
49 void SetIdentifier(const std::string& webServiceIdentifier); | 61 void SetIdentifier(const std::string& webServiceIdentifier); |
50 | 62 |
51 void SetUserProfileUrl(const std::string& url); | 63 void SetUserProfileUrl(const std::string& url); |
52 | |
53 virtual bool IsGranted(unsigned int& validity, | |
54 OrthancPluginHttpMethod method, | |
55 const AccessedResource& access, | |
56 const Token& token, | |
57 const std::string& tokenValue) | |
58 { | |
59 return IsGrantedInternal(validity, method, access, &token, tokenValue); | |
60 } | |
61 | |
62 virtual bool IsGranted(unsigned int& validity, | |
63 OrthancPluginHttpMethod method, | |
64 const AccessedResource& access) | |
65 { | |
66 return IsGrantedInternal(validity, method, access, NULL, ""); | |
67 } | |
68 | |
69 virtual bool GetUserProfile(Json::Value& profile /* out */, | |
70 const Token& token, | |
71 const std::string& tokenValue); | |
72 | |
73 }; | 64 }; |
74 } | 65 } |