auth.h 1.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748
  1. #pragma once
  2. #include "mon_service_http_request.h"
  3. namespace NMonitoring {
  4. enum class EAuthType {
  5. None = 0,
  6. Tvm = 1,
  7. };
  8. struct TAuthResult {
  9. enum class EStatus {
  10. NoCredentials = 0,
  11. Denied,
  12. Ok,
  13. };
  14. TAuthResult(EStatus status)
  15. : Status{status}
  16. {
  17. }
  18. static TAuthResult Denied() {
  19. return TAuthResult(EStatus::Denied);
  20. }
  21. static TAuthResult NoCredentials() {
  22. return TAuthResult(EStatus::NoCredentials);
  23. }
  24. static TAuthResult Ok() {
  25. return TAuthResult(EStatus::Ok);
  26. }
  27. explicit operator bool() const {
  28. return Status == EStatus::Ok;
  29. }
  30. EStatus Status{EStatus::NoCredentials};
  31. };
  32. struct IAuthProvider {
  33. virtual ~IAuthProvider() = default;
  34. virtual TAuthResult Check(const IHttpRequest& req) = 0;
  35. };
  36. THolder<IAuthProvider> CreateFakeAuth();
  37. } // namespace NMonitoring