Webdar
1.0.2
Web user interface to libdar
Loading...
Searching...
No Matches
home
denis
Telechargements
WEBDAR
webdar-1.0.2
src
authentication.hpp
1
/*********************************************************************/
2
// webdar - a web server and interface program to libdar
3
// Copyright (C) 2013-2026 Denis Corbin
4
//
5
// This file is part of Webdar
6
//
7
// Webdar is free software: you can redistribute it and/or modify
8
// it under the terms of the GNU General Public License as published by
9
// the Free Software Foundation, either version 3 of the License, or
10
// (at your option) any later version.
11
//
12
// Webdar is distributed in the hope that it will be useful,
13
// but WITHOUT ANY WARRANTY; without even the implied warranty of
14
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15
// GNU General Public License for more details.
16
//
17
// You should have received a copy of the GNU General Public License
18
// along with Webdar. If not, see <http://www.gnu.org/licenses/>
19
//
20
//----
21
// to contact the author: dar.linux@free.fr
22
/*********************************************************************/
23
24
#ifndef AUTHENTICATION_HPP
25
#define AUTHENTICATION_HPP
26
27
// C system header files
28
#include "my_config.h"
29
extern
"C"
30
{
31
32
}
33
34
// C++ system header files
35
#include <string>
36
37
// webdar headers
38
40
41
class
authentication
42
{
43
public
:
44
authentication
() =
default
;
45
authentication
(
const
authentication
& ref) =
default
;
46
authentication
(
authentication
&& ref)
noexcept
=
default
;
47
authentication
& operator = (
const
authentication
& ref) =
default
;
48
authentication
& operator = (
authentication
&& ref)
noexcept
=
default
;
49
virtual
~authentication
() {};
50
51
virtual
bool
valid_credentials(
const
std::string & username,
const
std::string & credential)
const
= 0;
52
};
53
55
56
class
authentication_unix
:
public
authentication
57
{
59
60
};
61
63
64
class
authentication_cli
:
public
authentication
65
{
66
public
:
67
authentication_cli
(
const
std::string & username,
const
std::string & password) { user = username; pass = password; };
68
authentication_cli
(
const
authentication_cli
& ref) =
default
;
69
authentication_cli
(
authentication_cli
&& ref)
noexcept
=
default
;
70
authentication_cli
& operator = (
const
authentication_cli
& ref) =
default
;
71
authentication_cli
& operator = (
authentication_cli
&& ref)
noexcept
=
default
;
72
~authentication_cli
() =
default
;
73
74
virtual
bool
valid_credentials(
const
std::string & username,
const
std::string & credential)
const override
75
{
76
// due to different charset and encoding between CLI and web interface we compare
77
// strings downgrading then to C strings:
78
return
(strcmp(username.c_str(),user.c_str()) == 0) && strcmp(credential.c_str(), pass.c_str()) == 0;
79
};
// no need of mutex for this class
80
81
private
:
82
std::string user;
83
std::string pass;
84
85
};
86
87
88
#endif
authentication_cli
authentication_cli implements an authentication method based on a fixed login and password
Definition
authentication.hpp:65
authentication_unix
place holder class for Unix PAM authentication (not implemented for now)
Definition
authentication.hpp:57
authentication
pure virtual class defining the interface for current and future authentication methods
Definition
authentication.hpp:42
Generated by
1.9.8