comparison Plugin/AuthorizationWebService.h @ 194:85859ec3aa7e

added support for roles/permissions edition
author Alain Mazy <am@orthanc.team>
date Fri, 14 Jun 2024 16:26:53 +0200
parents c4b908970ae4
children 2f1e872e8eaa
comparison
equal deleted inserted replaced
188:c4b908970ae4 194:85859ec3aa7e
33 std::string identifier_; 33 std::string identifier_;
34 std::string userProfileUrl_; 34 std::string userProfileUrl_;
35 std::string tokenValidationUrl_; 35 std::string tokenValidationUrl_;
36 std::string tokenDecoderUrl_; 36 std::string tokenDecoderUrl_;
37 std::string tokenCreationBaseUrl_; 37 std::string tokenCreationBaseUrl_;
38 std::string settingsRolesUrl_;
38 39
39 protected: 40 protected:
40 virtual bool IsGrantedInternal(unsigned int& validity, 41 virtual bool IsGrantedInternal(unsigned int& validity,
41 OrthancPluginHttpMethod method, 42 OrthancPluginHttpMethod method,
42 const AccessedResource& access, 43 const AccessedResource& access,
54 55
55 public: 56 public:
56 AuthorizationWebService(const std::string& tokenValidationUrl, 57 AuthorizationWebService(const std::string& tokenValidationUrl,
57 const std::string& tokenCreationBaseUrl, 58 const std::string& tokenCreationBaseUrl,
58 const std::string& userProfileUrl, 59 const std::string& userProfileUrl,
59 const std::string& tokenDecoderUrl) : 60 const std::string& tokenDecoderUrl,
61 const std::string& settingsRolesUrl) :
60 userProfileUrl_(userProfileUrl), 62 userProfileUrl_(userProfileUrl),
61 tokenValidationUrl_(tokenValidationUrl), 63 tokenValidationUrl_(tokenValidationUrl),
62 tokenDecoderUrl_(tokenDecoderUrl), 64 tokenDecoderUrl_(tokenDecoderUrl),
63 tokenCreationBaseUrl_(tokenCreationBaseUrl) 65 tokenCreationBaseUrl_(tokenCreationBaseUrl),
66 settingsRolesUrl_(settingsRolesUrl)
64 { 67 {
65 } 68 }
66 69
67 void SetCredentials(const std::string& username, 70 void SetCredentials(const std::string& username,
68 const std::string& password); 71 const std::string& password);
82 virtual bool HasTokenValidation() const 85 virtual bool HasTokenValidation() const
83 { 86 {
84 return !tokenValidationUrl_.empty(); 87 return !tokenValidationUrl_.empty();
85 } 88 }
86 89
90 virtual bool HasSettingsRoles() const
91 {
92 return !settingsRolesUrl_.empty();
93 }
94
87 virtual bool CreateToken(IAuthorizationService::CreatedToken& response, 95 virtual bool CreateToken(IAuthorizationService::CreatedToken& response,
88 const std::string& tokenType, 96 const std::string& tokenType,
89 const std::string& id, 97 const std::string& id,
90 const std::vector<IAuthorizationService::OrthancResource>& resources, 98 const std::vector<IAuthorizationService::OrthancResource>& resources,
91 const std::string& expirationDateString, 99 const std::string& expirationDateString,
93 101
94 virtual bool DecodeToken(DecodedToken& response, 102 virtual bool DecodeToken(DecodedToken& response,
95 const std::string& tokenKey, 103 const std::string& tokenKey,
96 const std::string& tokenValue); 104 const std::string& tokenValue);
97 105
106 virtual bool GetSettingsRoles(Json::Value& roles);
107 virtual bool UpdateSettingsRoles(Json::Value& response,
108 const Json::Value& roles);
109
98 static void ToJson(Json::Value& output, const UserProfile& profile); 110 static void ToJson(Json::Value& output, const UserProfile& profile);
99 111
100 static void FromJson(UserProfile& profile, const Json::Value& input); 112 static void FromJson(UserProfile& profile, const Json::Value& input);
101 113
102 }; 114 };