Mercurial > hg > orthanc-authorization
comparison Plugin/AuthorizationWebService.h @ 72:e381ba725669
new PUT auth/tokens/{token-type} API route + updated interface with WebService
author | Alain Mazy <am@osimis.io> |
---|---|
date | Fri, 24 Feb 2023 18:13:36 +0100 |
parents | 30fb3ce960d9 |
children | 512247750f0a |
comparison
equal
deleted
inserted
replaced
71:30fb3ce960d9 | 72:e381ba725669 |
---|---|
24 namespace OrthancPlugins | 24 namespace OrthancPlugins |
25 { | 25 { |
26 class AuthorizationWebService : public BaseAuthorizationService | 26 class AuthorizationWebService : public BaseAuthorizationService |
27 { | 27 { |
28 private: | 28 private: |
29 std::string url_; | |
30 std::string username_; | 29 std::string username_; |
31 std::string password_; | 30 std::string password_; |
32 std::string identifier_; | 31 std::string identifier_; |
33 std::string userProfileUrl_; | 32 std::string userProfileUrl_; |
33 std::string tokenValidationUrl_; | |
34 std::string tokenCreationBaseUrl_; | |
34 | 35 |
35 protected: | 36 protected: |
36 virtual bool IsGrantedInternal(unsigned int& validity, | 37 virtual bool IsGrantedInternal(unsigned int& validity, |
37 OrthancPluginHttpMethod method, | 38 OrthancPluginHttpMethod method, |
38 const AccessedResource& access, | 39 const AccessedResource& access, |
48 const std::string& permission, | 49 const std::string& permission, |
49 const Token* token, | 50 const Token* token, |
50 const std::string& tokenValue) ORTHANC_OVERRIDE; | 51 const std::string& tokenValue) ORTHANC_OVERRIDE; |
51 | 52 |
52 public: | 53 public: |
53 AuthorizationWebService(const std::string& url) : | 54 AuthorizationWebService(const std::string& tokenValidationUrl, |
54 url_(url) | 55 const std::string& tokenCreationBaseUrl, |
56 const std::string& userProfileUrl) : | |
57 userProfileUrl_(userProfileUrl), | |
58 tokenValidationUrl_(tokenValidationUrl), | |
59 tokenCreationBaseUrl_(tokenCreationBaseUrl) | |
55 { | 60 { |
56 } | 61 } |
57 | 62 |
58 void SetCredentials(const std::string& username, | 63 void SetCredentials(const std::string& username, |
59 const std::string& password); | 64 const std::string& password); |
60 | 65 |
61 void SetIdentifier(const std::string& webServiceIdentifier); | 66 void SetIdentifier(const std::string& webServiceIdentifier); |
62 | 67 |
63 void SetUserProfileUrl(const std::string& url); | 68 virtual bool HasUserProfile() const |
69 { | |
70 return !userProfileUrl_.empty(); | |
71 } | |
72 | |
73 virtual bool HasCreateToken() const | |
74 { | |
75 return !tokenCreationBaseUrl_.empty(); | |
76 } | |
77 | |
78 virtual bool HasTokenValidation() const | |
79 { | |
80 return !tokenValidationUrl_.empty(); | |
81 } | |
82 | |
83 virtual bool CreateToken(IAuthorizationService::CreatedToken& response, | |
84 const std::string& tokenType, | |
85 const std::string& id, | |
86 const std::vector<IAuthorizationService::OrthancResource>& resources, | |
87 const std::string& expirationDateString) ORTHANC_OVERRIDE; | |
88 | |
64 }; | 89 }; |
65 } | 90 } |