taler-merchant-httpd_auth.h (3233B)
1 /* 2 This file is part of TALER 3 Copyright (C) 2021-2025 Taler Systems SA 4 5 TALER is free software; you can redistribute it and/or modify it under the 6 terms of the GNU Affero General Public License as published by the Free Software 7 Foundation; either version 3, or (at your option) any later version. 8 9 TALER is distributed in the hope that it will be useful, but WITHOUT ANY 10 WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR 11 A PARTICULAR PURPOSE. See the GNU Affero General Public License for more details. 12 13 You should have received a copy of the GNU Affero General Public License along with 14 TALER; see the file COPYING. If not, see <http://www.gnu.org/licenses/> 15 */ 16 /** 17 * @file taler-merchant-httpd_auth.h 18 * @brief request authentication logic 19 * @author Florian Dold 20 * @author Martin Schanzenbach 21 * @author Christian Grothoff 22 */ 23 #ifndef TALER_MERCHANT_HTTPD_AUTH_H 24 #define TALER_MERCHANT_HTTPD_AUTH_H 25 26 #include "taler-merchant-httpd.h" 27 28 /** 29 * Check that @a token hashes to @a hash under @a salt for 30 * merchant instance authentication. 31 * 32 * @param token the token to check 33 * @param salt the salt to use when hashing 34 * @param hash the hash to check against 35 * @return #GNUNET_OK if the @a token matches 36 */ 37 enum GNUNET_GenericReturnValue 38 TMH_check_auth (const char *token, 39 struct TALER_MerchantAuthenticationSaltP *salt, 40 struct TALER_MerchantAuthenticationHashP *hash); 41 42 43 /** 44 * Compute a @a hash from @a token hashes for 45 * merchant instance authentication. 46 * 47 * @param password the password to check 48 * @param[out] salt set to a fresh random salt 49 * @param[out] hash set to the hash of @a token under @a salt 50 */ 51 void 52 TMH_compute_auth (const char *password, 53 struct TALER_MerchantAuthenticationSaltP *salt, 54 struct TALER_MerchantAuthenticationHashP *hash); 55 56 57 /** 58 * Check if @a candidate permissions are a subset of @a as permissions 59 * 60 * @param as scope to check against 61 * @param candidate scope to check if its permissions are a subset of @a as permissions. 62 * @return true if it was a subset, false otherwise. 63 */ 64 bool 65 TMH_scope_is_subset (enum TMH_AuthScope as, 66 enum TMH_AuthScope candidate); 67 68 69 /** 70 * Return the TMH_AuthScope corresponding to @a name. 71 * 72 * @param name the name to look for 73 * @return the scope corresponding to the name, or TMH_AS_NONE. 74 */ 75 enum TMH_AuthScope 76 TMH_get_scope_by_name (const char *name); 77 78 79 /** 80 * Return the name corresponding to @a scop. 81 * 82 * @param scope the scope to look for 83 * @param[out] refreshable outputs if scope value was refreshable 84 * @return the name corresponding to the scope, or NULL. 85 */ 86 const char * 87 TMH_get_name_by_scope (enum TMH_AuthScope scope, 88 bool *refreshable); 89 90 91 /** 92 * Check if the client has provided the necessary credentials 93 * to access the selected endpoint of the selected instance. 94 * 95 * @param[in,out] hc handler context 96 * @return #GNUNET_OK on success, 97 * #GNUNET_NO if an error was queued (return #MHD_YES) 98 * #GNUNET_SYSERR to close the connection (return #MHD_NO) 99 */ 100 enum GNUNET_GenericReturnValue 101 TMH_perform_access_control (struct TMH_HandlerContext *hc); 102 103 #endif