mirror of
				https://github.com/PabloMK7/citra.git
				synced 2025-10-31 13:50:03 +00:00 
			
		
		
		
	web_backend: added GetExternalJWT function
To support requesting external JWTs to use them as verification tokens.
This commit is contained in:
		
							parent
							
								
									ab335ccf1b
								
							
						
					
					
						commit
						e04f75e1bf
					
				
					 2 changed files with 14 additions and 1 deletions
				
			
		|  | @ -7,6 +7,7 @@ | ||||||
| #include <mutex> | #include <mutex> | ||||||
| #include <string> | #include <string> | ||||||
| #include <LUrlParser.h> | #include <LUrlParser.h> | ||||||
|  | #include <fmt/format.h> | ||||||
| #include <httplib.h> | #include <httplib.h> | ||||||
| #include "common/common_types.h" | #include "common/common_types.h" | ||||||
| #include "common/logging/log.h" | #include "common/logging/log.h" | ||||||
|  | @ -134,7 +135,8 @@ struct Client::Impl { | ||||||
|         } |         } | ||||||
| 
 | 
 | ||||||
|         if (content_type->second.find("application/json") == std::string::npos && |         if (content_type->second.find("application/json") == std::string::npos && | ||||||
|             content_type->second.find("text/html; charset=utf-8") == std::string::npos) { |             content_type->second.find("text/html; charset=utf-8") == std::string::npos && | ||||||
|  |             content_type->second.find("text/plain; charset=utf-8") == std::string::npos) { | ||||||
|             LOG_ERROR(WebService, "{} to {} returned wrong content: {}", method, host + path, |             LOG_ERROR(WebService, "{} to {} returned wrong content: {}", method, host + path, | ||||||
|                       content_type->second); |                       content_type->second); | ||||||
|             return Common::WebResult{Common::WebResult::Code::WrongContent, "Wrong content"}; |             return Common::WebResult{Common::WebResult::Code::WrongContent, "Wrong content"}; | ||||||
|  | @ -193,4 +195,8 @@ Common::WebResult Client::DeleteJson(const std::string& path, const std::string& | ||||||
|     return impl->GenericJson("DELETE", path, data, allow_anonymous); |     return impl->GenericJson("DELETE", path, data, allow_anonymous); | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
|  | Common::WebResult Client::GetExternalJWT(const std::string& audience) { | ||||||
|  |     return PostJson(fmt::format("/jwt/external/{}", audience), "", false); | ||||||
|  | } | ||||||
|  | 
 | ||||||
| } // namespace WebService
 | } // namespace WebService
 | ||||||
|  |  | ||||||
|  | @ -46,6 +46,13 @@ public: | ||||||
|     Common::WebResult DeleteJson(const std::string& path, const std::string& data, |     Common::WebResult DeleteJson(const std::string& path, const std::string& data, | ||||||
|                                  bool allow_anonymous); |                                  bool allow_anonymous); | ||||||
| 
 | 
 | ||||||
|  |     /**
 | ||||||
|  |      * Requests an external JWT for the specific audience provided. | ||||||
|  |      * @param audience the audience of the JWT requested. | ||||||
|  |      * @return the result of the request. | ||||||
|  |      */ | ||||||
|  |     Common::WebResult GetExternalJWT(const std::string& audience); | ||||||
|  | 
 | ||||||
| private: | private: | ||||||
|     struct Impl; |     struct Impl; | ||||||
|     std::unique_ptr<Impl> impl; |     std::unique_ptr<Impl> impl; | ||||||
|  |  | ||||||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue