]>
Commit | Line | Data |
---|---|---|
1 | /* | |
2 | * Copyright (C) 1996-2025 The Squid Software Foundation and contributors | |
3 | * | |
4 | * Squid software is distributed under GPLv2+ license and includes | |
5 | * contributions from numerous individuals and organizations. | |
6 | * Please see the COPYING and CONTRIBUTORS files for details. | |
7 | */ | |
8 | ||
9 | #ifndef SQUID_SRC_AUTH_SCHEME_H | |
10 | #define SQUID_SRC_AUTH_SCHEME_H | |
11 | ||
12 | #if USE_AUTH | |
13 | ||
14 | #include "auth/forward.h" | |
15 | #include "base/RefCount.h" | |
16 | ||
17 | namespace Auth | |
18 | { | |
19 | ||
20 | /** | |
21 | * I represent an authentication scheme. For now my children | |
22 | * store the scheme metadata. | |
23 | * | |
24 | * Should we need multiple configs of a single scheme, | |
25 | * a new class should be made, and the config specific calls on Auth::Scheme moved to it. | |
26 | */ | |
27 | class Scheme : public RefCountable | |
28 | { | |
29 | public: | |
30 | typedef RefCount<Scheme> Pointer; | |
31 | typedef std::vector<Scheme::Pointer>::iterator iterator; | |
32 | typedef std::vector<Scheme::Pointer>::const_iterator const_iterator; | |
33 | ||
34 | public: | |
35 | Scheme() : initialised (false) {}; | |
36 | ~Scheme() override {}; | |
37 | ||
38 | static void AddScheme(Scheme::Pointer); | |
39 | ||
40 | /** | |
41 | * Final termination of all authentication components. | |
42 | * To be used only on shutdown. All global pointers are released. | |
43 | * After this all schemes will appear completely unsupported | |
44 | * until a call to InitAuthModules(). | |
45 | * Release the Auth::TheConfig handles instead to disable authentication | |
46 | * without terminiating all support. | |
47 | */ | |
48 | static void FreeAll(); | |
49 | ||
50 | /** | |
51 | * Locate an authentication scheme component by Name. | |
52 | */ | |
53 | static Scheme::Pointer Find(const char *); | |
54 | ||
55 | /* per scheme methods */ | |
56 | virtual char const *type() const = 0; | |
57 | virtual void shutdownCleanup() = 0; | |
58 | virtual Auth::SchemeConfig *createConfig() = 0; | |
59 | ||
60 | // Not implemented | |
61 | Scheme(Scheme const &); | |
62 | Scheme &operator=(Scheme const&); | |
63 | ||
64 | static std::vector<Scheme::Pointer> &GetSchemes(); | |
65 | ||
66 | protected: | |
67 | bool initialised; | |
68 | ||
69 | private: | |
70 | static std::vector<Scheme::Pointer> *_Schemes; | |
71 | }; | |
72 | ||
73 | } // namespace Auth | |
74 | ||
75 | #endif /* USE_AUTH */ | |
76 | #endif /* SQUID_SRC_AUTH_SCHEME_H */ | |
77 |