2019-04-26 18:27:27 +03:00
|
|
|
// Copyright (c) Microsoft Corporation. All rights reserved.
|
|
|
|
// Licensed under the Apache 2.0 License.
|
|
|
|
#pragma once
|
|
|
|
|
2022-02-23 16:43:50 +03:00
|
|
|
#include <cstdint>
|
2022-08-23 18:43:35 +03:00
|
|
|
#include <string>
|
2019-04-26 18:27:27 +03:00
|
|
|
|
|
|
|
namespace ccf
|
|
|
|
{
|
2020-01-20 21:27:11 +03:00
|
|
|
enum class ActorsType : uint64_t
|
2019-05-24 12:05:32 +03:00
|
|
|
{
|
|
|
|
members = 0,
|
|
|
|
users,
|
|
|
|
nodes,
|
2023-02-03 15:17:31 +03:00
|
|
|
acme_challenge,
|
2019-05-24 12:05:32 +03:00
|
|
|
// not to be used
|
|
|
|
unknown
|
|
|
|
};
|
|
|
|
|
2022-08-23 18:43:35 +03:00
|
|
|
inline bool is_valid_actor(const std::string& actor)
|
|
|
|
{
|
|
|
|
if (
|
|
|
|
actor != "gov" && actor != "app" && actor != "node" &&
|
2023-02-03 15:17:31 +03:00
|
|
|
actor != ".well-known/acme-challenge")
|
2022-08-23 18:43:35 +03:00
|
|
|
{
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
2020-06-23 13:42:13 +03:00
|
|
|
constexpr auto get_actor_prefix(ActorsType at)
|
|
|
|
{
|
|
|
|
switch (at)
|
|
|
|
{
|
|
|
|
case ActorsType::members:
|
|
|
|
{
|
|
|
|
return "gov";
|
|
|
|
}
|
|
|
|
case ActorsType::users:
|
|
|
|
{
|
|
|
|
return "app";
|
|
|
|
}
|
|
|
|
case ActorsType::nodes:
|
|
|
|
{
|
|
|
|
return "node";
|
|
|
|
}
|
2023-02-03 15:17:31 +03:00
|
|
|
case ActorsType::acme_challenge:
|
2022-06-21 21:03:29 +03:00
|
|
|
{
|
2023-02-03 15:17:31 +03:00
|
|
|
return ".well-known/acme-challenge";
|
2022-06-21 21:03:29 +03:00
|
|
|
}
|
2020-06-23 13:42:13 +03:00
|
|
|
default:
|
|
|
|
{
|
|
|
|
return "";
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2019-04-26 18:27:27 +03:00
|
|
|
}
|