• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 // Copyright 2023 gRPC authors.
2 //
3 // Licensed under the Apache License, Version 2.0 (the "License");
4 // you may not use this file except in compliance with the License.
5 // You may obtain a copy of the License at
6 //
7 //     http://www.apache.org/licenses/LICENSE-2.0
8 //
9 // Unless required by applicable law or agreed to in writing, software
10 // distributed under the License is distributed on an "AS IS" BASIS,
11 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12 // See the License for the specific language governing permissions and
13 // limitations under the License.
14 
15 #ifndef GRPC_SRC_CORE_LIB_SECURITY_AUTHORIZATION_STDOUT_LOGGER_H
16 #define GRPC_SRC_CORE_LIB_SECURITY_AUTHORIZATION_STDOUT_LOGGER_H
17 
18 #include <grpc/grpc_audit_logging.h>
19 #include <grpc/support/json.h>
20 #include <grpc/support/port_platform.h>
21 
22 #include <memory>
23 #include <string>
24 
25 #include "absl/status/statusor.h"
26 #include "absl/strings/string_view.h"
27 
28 namespace grpc_core {
29 namespace experimental {
30 
31 class StdoutAuditLogger : public AuditLogger {
32  public:
33   StdoutAuditLogger() = default;
name()34   absl::string_view name() const override { return "stdout_logger"; }
35   void Log(const AuditContext&) override;
36 };
37 
38 class StdoutAuditLoggerFactory : public AuditLoggerFactory {
39  public:
40   class Config : public AuditLoggerFactory::Config {
41    public:
42     Config() = default;
43     absl::string_view name() const override;
44     std::string ToString() const override;
45   };
46   StdoutAuditLoggerFactory() = default;
47 
48   absl::string_view name() const override;
49 
50   absl::StatusOr<std::unique_ptr<AuditLoggerFactory::Config>>
51   ParseAuditLoggerConfig(const Json& json) override;
52 
53   std::unique_ptr<AuditLogger> CreateAuditLogger(
54       std::unique_ptr<AuditLoggerFactory::Config>) override;
55 };
56 
57 }  // namespace experimental
58 }  // namespace grpc_core
59 
60 #endif  // GRPC_SRC_CORE_LIB_SECURITY_AUTHORIZATION_STDOUT_LOGGER_H
61