CCF
Loading...
Searching...
No Matches
authentication_types.h
Go to the documentation of this file.
1// Copyright (c) Microsoft Corporation. All rights reserved.
2// Licensed under the Apache 2.0 License.
3#pragma once
4
5#include "ccf/tx.h"
6
7#include <memory>
8#include <nlohmann/json.hpp>
9#include <string>
10
11namespace ccf
12{
13 class RpcContext;
14}
15
16namespace ccf
17{
19 {
20 virtual ~AuthnIdentity() = default;
21 };
22
23 using OpenAPISecuritySchema = std::pair<std::string, nlohmann::json>;
24 static const OpenAPISecuritySchema unauthenticated_schema =
25 std::make_pair("", nlohmann::json());
26
28 {
29 public:
30 virtual ~AuthnPolicy() = default;
31
32 virtual std::unique_ptr<AuthnIdentity> authenticate(
34 const std::shared_ptr<ccf::RpcContext>& ctx,
35 std::string& error_reason) = 0;
36
38 std::shared_ptr<ccf::RpcContext> ctx, std::string&& error_reason)
39 {}
40
41 virtual std::optional<OpenAPISecuritySchema> get_openapi_security_schema()
42 const = 0;
43
44 virtual std::string get_security_scheme_name() = 0;
45 };
46
47 using AuthnPolicies = std::vector<std::shared_ptr<AuthnPolicy>>;
48}
Definition authentication_types.h:28
virtual void set_unauthenticated_error(std::shared_ptr< ccf::RpcContext > ctx, std::string &&error_reason)
Definition authentication_types.h:37
virtual std::optional< OpenAPISecuritySchema > get_openapi_security_schema() const =0
virtual ~AuthnPolicy()=default
virtual std::unique_ptr< AuthnIdentity > authenticate(ccf::kv::ReadOnlyTx &tx, const std::shared_ptr< ccf::RpcContext > &ctx, std::string &error_reason)=0
virtual std::string get_security_scheme_name()=0
Definition tx.h:160
Definition app_interface.h:14
std::pair< std::string, nlohmann::json > OpenAPISecuritySchema
Definition authentication_types.h:23
std::vector< std::shared_ptr< AuthnPolicy > > AuthnPolicies
Definition authentication_types.h:47
Definition authentication_types.h:19
virtual ~AuthnIdentity()=default