-
Notifications
You must be signed in to change notification settings - Fork 376
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Resolve ChannelSpec into a Channel (#2899)
* Change URL custom_channel matcher * Cannot change location at once * Simpler channel_alias_location * Change URL channel_alias matcher * Refactor ChannelContext::from_url * Add Windows URL path encoding test * Simplify URL::set_path * Fix URL encoding parsing * Refactor platforms urls * Fix missing forward declaration * Fix Win file URL encoding * Split Channel url functions * Remove no-URL ctor from ChannelContext::from_name * Remove no-URL ctor from ChannelContext::make_simple_channel * Remove old Channel ctor * Remove channel_alias_location * Refactor Channel::base_url * Try not to use location mamba.py * Remove Channel comparison * Try Channel::platform_url * Refactor Channel::platform_urls to use platform_url * Remove build_url * Remove concat_scheme_url * Use spec in from_name * Tuple equality for URL * Add tuple_hash * Add std::hash<mamba::util::URL> * Make CondaURL hashable * Refactor make_channel * New algorithm for authetification map * Add specs::AutheticationDataBase * Fix typo authentification > authentication * Use AuthenticationDataBase * Fix AuthenticationDataBase * use AuthenticationDataBase::find_compatible * Use canonical_name * Add Credential check to URL * Simplify crendential check in channel * Refactor AuthDB credential setters * No Channel::location in tests * Remove Channel user scheme password * Document AuthenticationInfo * Remove Channel token * Remove Channel::auth * Remove Channel::package_name * More replacement name > canonical_name * Remove unused function * No credential from URLs * Remove unneeded header * Disable Channel::repo_checker This is disbled as TUF implementation is not well defined and this function is not used except in experimental conditions. * Apply auth info as needed * Simplify custom_channels instanciation * Simplify custom_multi_channels instanciation * Review improvements
- Loading branch information
1 parent
f23e078
commit c7aba97
Showing
37 changed files
with
913 additions
and
808 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,106 @@ | ||
// Copyright (c) 2023, QuantStack and Mamba Contributors | ||
// | ||
// Distributed under the terms of the BSD 3-Clause License. | ||
// | ||
// The full license is in the file LICENSE, distributed with this software. | ||
|
||
#ifndef MAMBA_SPECS_AUTHENTICATION_INFO_HPP | ||
#define MAMBA_SPECS_AUTHENTICATION_INFO_HPP | ||
|
||
#include <string> | ||
#include <unordered_map> | ||
#include <variant> | ||
|
||
namespace mamba::specs | ||
{ | ||
class CondaURL; | ||
|
||
/** User and password authetification set in the URL. */ | ||
struct BasicHTTPAuthentication | ||
{ | ||
std::string user; | ||
std::string password; | ||
}; | ||
|
||
/** HTTP Bearer token set in the request headers. */ | ||
struct BearerToken | ||
{ | ||
std::string token; | ||
}; | ||
|
||
/** A Conda token set in the URL path. */ | ||
struct CondaToken | ||
{ | ||
std::string token; | ||
}; | ||
|
||
using AuthenticationInfo = std::variant<BasicHTTPAuthentication, BearerToken, CondaToken>; | ||
|
||
/** | ||
* A class that holds the authentication info stored by users. | ||
* | ||
* Essentially a map, except that some keys can match mutliple queries. | ||
* For instance "mamba.org/private" should be matched by queries "mamba.org/private", | ||
* "mamba.org/private/channel", but not "mamba.org/public". | ||
* | ||
* A best effort is made to satifiy this with `xxx_compatible`. | ||
* | ||
* Future development of this class should aim to replace the map and keys with a | ||
* `AuthenticationSpec`, that can decide whether or not a URL should benefit from such | ||
* its authentication. | ||
* Possibly, a string reprensentation such as "*.mamba.org/private/channel*" could be added | ||
* to parse users intentions, rather than relying on the assumptions made here. | ||
*/ | ||
class AuthenticationDataBase : private std::unordered_map<std::string, AuthenticationInfo> | ||
{ | ||
public: | ||
|
||
using Base = std::unordered_map<std::string, AuthenticationInfo>; | ||
|
||
using typename Base::key_type; | ||
using typename Base::mapped_type; | ||
using typename Base::value_type; | ||
using typename Base::size_type; | ||
using typename Base::iterator; | ||
using typename Base::const_iterator; | ||
|
||
using Base::Base; | ||
|
||
using Base::begin; | ||
using Base::end; | ||
using Base::cbegin; | ||
using Base::cend; | ||
|
||
using Base::empty; | ||
using Base::size; | ||
using Base::max_size; | ||
|
||
using Base::clear; | ||
using Base::insert; | ||
using Base::insert_or_assign; | ||
using Base::emplace; | ||
using Base::emplace_hint; | ||
using Base::try_emplace; | ||
using Base::erase; | ||
using Base::swap; | ||
using Base::extract; | ||
using Base::merge; | ||
|
||
using Base::reserve; | ||
|
||
using Base::at; | ||
|
||
[[nodiscard]] auto at_compatible(const key_type& key) -> mapped_type&; | ||
[[nodiscard]] auto at_compatible(const key_type& key) const -> const mapped_type&; | ||
|
||
using Base::find; | ||
|
||
auto find_compatible(const key_type& key) -> iterator; | ||
auto find_compatible(const key_type& key) const -> const_iterator; | ||
|
||
[[nodiscard]] auto contains(const key_type& key) const -> bool; | ||
|
||
[[nodiscard]] auto contains_compatible(const key_type& key) const -> bool; | ||
}; | ||
} | ||
#endif |
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.