aboutsummaryrefslogtreecommitdiffstats
path: root/library/cpp/monlib/service/auth.h
blob: ae53b8bd8eb3c260c5e2271aa11dba36a7c9433a (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
#pragma once

#include "mon_service_http_request.h"

namespace NMonitoring {
    enum class EAuthType {
        None = 0,
        Tvm = 1,
    };

    struct TAuthResult {
        enum class EStatus {
            NoCredentials = 0,
            Denied,
            Ok,
        };

        TAuthResult(EStatus status)
            : Status{status}
        {
        }

        static TAuthResult Denied() {
            return TAuthResult(EStatus::Denied);
        }

        static TAuthResult NoCredentials() {
            return TAuthResult(EStatus::NoCredentials);
        }

        static TAuthResult Ok() {
            return TAuthResult(EStatus::Ok);
        }

        explicit operator bool() const {
            return Status == EStatus::Ok;
        }

        EStatus Status{EStatus::NoCredentials};
    };

    struct IAuthProvider {
        virtual ~IAuthProvider() = default;
        virtual TAuthResult Check(const IHttpRequest& req) = 0;
    };

    THolder<IAuthProvider> CreateFakeAuth();
} // namespace NMonitoring