Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
P
Postgres FD Implementation
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Abuhujair Javed
Postgres FD Implementation
Commits
b3daac5a
Commit
b3daac5a
authored
Jan 27, 2010
by
Magnus Hagander
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add support for RADIUS authentication.
parent
000416ac
Changes
7
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
7 changed files
with
532 additions
and
11 deletions
+532
-11
doc/src/sgml/client-auth.sgml
doc/src/sgml/client-auth.sgml
+100
-1
src/backend/libpq/auth.c
src/backend/libpq/auth.c
+365
-2
src/backend/libpq/hba.c
src/backend/libpq/hba.c
+48
-1
src/backend/libpq/md5.c
src/backend/libpq/md5.c
+7
-1
src/backend/libpq/pg_hba.conf.sample
src/backend/libpq/pg_hba.conf.sample
+3
-3
src/include/libpq/hba.h
src/include/libpq/hba.h
+7
-2
src/include/libpq/md5.h
src/include/libpq/md5.h
+2
-1
No files found.
doc/src/sgml/client-auth.sgml
View file @
b3daac5a
<!-- $PostgreSQL: pgsql/doc/src/sgml/client-auth.sgml,v 1.12
7 2010/01/26 06:45:31 petere
Exp $ -->
<!-- $PostgreSQL: pgsql/doc/src/sgml/client-auth.sgml,v 1.12
8 2010/01/27 12:11:59 mha
Exp $ -->
<chapter id="client-authentication">
<chapter id="client-authentication">
<title>Client Authentication</title>
<title>Client Authentication</title>
...
@@ -394,6 +394,16 @@ hostnossl <replaceable>database</replaceable> <replaceable>user</replaceable>
...
@@ -394,6 +394,16 @@ hostnossl <replaceable>database</replaceable> <replaceable>user</replaceable>
</listitem>
</listitem>
</varlistentry>
</varlistentry>
<varlistentry>
<term><literal>radius</></term>
<listitem>
<para>
Authenticate using a RADIUS server. See <xref
linkend="auth-radius"> for detauls.
</para>
</listitem>
</varlistentry>
<varlistentry>
<varlistentry>
<term><literal>cert</></term>
<term><literal>cert</></term>
<listitem>
<listitem>
...
@@ -1331,6 +1341,95 @@ ldapserver=ldap.example.net ldapprefix="cn=" ldapsuffix=", dc=example, dc=net"
...
@@ -1331,6 +1341,95 @@ ldapserver=ldap.example.net ldapprefix="cn=" ldapsuffix=", dc=example, dc=net"
</sect2>
</sect2>
<sect2 id="auth-radius">
<title>RADIUS authentication</title>
<indexterm zone="auth-radius">
<primary>RADIUS</primary>
</indexterm>
<para>
This authentication method operates similarly to
<literal>password</literal> except that it uses RADIUS
as the password verification method. RADIUS is used only to validate
the user name/password pairs. Therefore the user must already
exist in the database before RADIUS can be used for
authentication.
</para>
<para>
When using RADIUS authentication, an Access Request message will be sent
to the configured RADIUS server. This request will be of type
<literal>Authenticate Only</literal>, and include parameters for
<literal>user name</>, <literal>password</> (encrypted) and
<literal>NAS Identifier</>. The request will be encrypted using
a secret shared with the server. The RADIUS server will respond to
this server with either <literal>Access Accept</> or
<literal>Access Reject</>. There is no support for RADIUS accounting.
</para>
<para>
The following configuration options are supported for RADIUS:
<variablelist>
<varlistentry>
<term><literal>radiusserver</literal></term>
<listitem>
<para>
The IP address of the RADIUS server to connect to. This must
be an IPV4 address and not a hostname. This parameter is required.
</para>
</listitem>
</varlistentry>
<varlistentry>
<term><literal>radiussecret</literal></term>
<listitem>
<para>
The shared secret used when talking securely to the RADIUS
server. This must have exactly the same value on the PostgreSQL
and RADIUS servers. It is recommended that this is a string of
at least 16 characters. This parameter is required.
<note>
<para>
The encryption vector used will only be cryptographically
strong if <productname>PostgreSQL</> is built with support for
<productname>OpenSSL</>. In other cases, the transmission to the
RADIUS server should only be considered obfuscated, not secured, and
external security measures should be applied if necessary.
</para>
</note>
</para>
</listitem>
</varlistentry>
<varlistentry>
<term><literal>radiusport</literal></term>
<listitem>
<para>
The port number on the RADIUS server to connect to. If no port
is specified, the default port <literal>1812</> will be used.
</para>
</listitem>
</varlistentry>
<varlistentry>
<term><literal>radiusidentifier</literal></term>
<listitem>
<para>
The string used as <literal>NAS Identifier</> in the RADIUS
requests. This parameter can be used as a second parameter
identifying for example which database the user is attempting
to authenticate as, which can be used for policy matching on
the RADIUS server. If no identifier is specified, the default
<literal>postgresql</> will be used.
</para>
</listitem>
</varlistentry>
</variablelist>
</para>
</sect2>
<sect2 id="auth-cert">
<sect2 id="auth-cert">
<title>Certificate authentication</title>
<title>Certificate authentication</title>
...
...
src/backend/libpq/auth.c
View file @
b3daac5a
This diff is collapsed.
Click to expand it.
src/backend/libpq/hba.c
View file @
b3daac5a
...
@@ -10,7 +10,7 @@
...
@@ -10,7 +10,7 @@
*
*
*
*
* IDENTIFICATION
* IDENTIFICATION
* $PostgreSQL: pgsql/src/backend/libpq/hba.c,v 1.19
5 2010/01/15 09:19:02 heikki
Exp $
* $PostgreSQL: pgsql/src/backend/libpq/hba.c,v 1.19
6 2010/01/27 12:11:59 mha
Exp $
*
*
*-------------------------------------------------------------------------
*-------------------------------------------------------------------------
*/
*/
...
@@ -952,6 +952,8 @@ parse_hba_line(List *line, int line_num, HbaLine *parsedline)
...
@@ -952,6 +952,8 @@ parse_hba_line(List *line, int line_num, HbaLine *parsedline)
#else
#else
unsupauth
=
"cert"
;
unsupauth
=
"cert"
;
#endif
#endif
else
if
(
strcmp
(
token
,
"radius"
)
==
0
)
parsedline
->
auth_method
=
uaRADIUS
;
else
else
{
{
ereport
(
LOG
,
ereport
(
LOG
,
...
@@ -1162,6 +1164,45 @@ parse_hba_line(List *line, int line_num, HbaLine *parsedline)
...
@@ -1162,6 +1164,45 @@ parse_hba_line(List *line, int line_num, HbaLine *parsedline)
else
else
parsedline
->
include_realm
=
false
;
parsedline
->
include_realm
=
false
;
}
}
else
if
(
strcmp
(
token
,
"radiusserver"
)
==
0
)
{
REQUIRE_AUTH_OPTION
(
uaRADIUS
,
"radiusserver"
,
"radius"
);
if
(
inet_addr
(
c
)
==
INADDR_NONE
)
{
ereport
(
LOG
,
(
errcode
(
ERRCODE_CONFIG_FILE_ERROR
),
errmsg
(
"invalid RADIUS server IP address:
\"
%s
\"
"
,
c
),
errcontext
(
"line %d of configuration file
\"
%s
\"
"
,
line_num
,
HbaFileName
)));
return
false
;
}
parsedline
->
radiusserver
=
pstrdup
(
c
);
}
else
if
(
strcmp
(
token
,
"radiusport"
)
==
0
)
{
REQUIRE_AUTH_OPTION
(
uaRADIUS
,
"radiusport"
,
"radius"
);
parsedline
->
radiusport
=
atoi
(
c
);
if
(
parsedline
->
radiusport
==
0
)
{
ereport
(
LOG
,
(
errcode
(
ERRCODE_CONFIG_FILE_ERROR
),
errmsg
(
"invalid RADIUS port number:
\"
%s
\"
"
,
c
),
errcontext
(
"line %d of configuration file
\"
%s
\"
"
,
line_num
,
HbaFileName
)));
return
false
;
}
}
else
if
(
strcmp
(
token
,
"radiussecret"
)
==
0
)
{
REQUIRE_AUTH_OPTION
(
uaRADIUS
,
"radiussecret"
,
"radius"
);
parsedline
->
radiussecret
=
pstrdup
(
c
);
}
else
if
(
strcmp
(
token
,
"radiusidentifier"
)
==
0
)
{
REQUIRE_AUTH_OPTION
(
uaRADIUS
,
"radiusidentifier"
,
"radius"
);
parsedline
->
radiusidentifier
=
pstrdup
(
c
);
}
else
else
{
{
ereport
(
LOG
,
ereport
(
LOG
,
...
@@ -1214,6 +1255,12 @@ parse_hba_line(List *line, int line_num, HbaLine *parsedline)
...
@@ -1214,6 +1255,12 @@ parse_hba_line(List *line, int line_num, HbaLine *parsedline)
}
}
}
}
if
(
parsedline
->
auth_method
==
uaRADIUS
)
{
MANDATORY_AUTH_ARG
(
parsedline
->
radiusserver
,
"radiusserver"
,
"radius"
);
MANDATORY_AUTH_ARG
(
parsedline
->
radiussecret
,
"radiussecret"
,
"radius"
);
}
/*
/*
* Enforce any parameters implied by other settings.
* Enforce any parameters implied by other settings.
*/
*/
...
...
src/backend/libpq/md5.c
View file @
b3daac5a
...
@@ -14,7 +14,7 @@
...
@@ -14,7 +14,7 @@
* Portions Copyright (c) 1994, Regents of the University of California
* Portions Copyright (c) 1994, Regents of the University of California
*
*
* IDENTIFICATION
* IDENTIFICATION
* $PostgreSQL: pgsql/src/backend/libpq/md5.c,v 1.3
8 2010/01/02 16:57:45 momjian
Exp $
* $PostgreSQL: pgsql/src/backend/libpq/md5.c,v 1.3
9 2010/01/27 12:11:59 mha
Exp $
*/
*/
/* This is intended to be used in both frontend and backend, so use c.h */
/* This is intended to be used in both frontend and backend, so use c.h */
...
@@ -298,6 +298,12 @@ pg_md5_hash(const void *buff, size_t len, char *hexsum)
...
@@ -298,6 +298,12 @@ pg_md5_hash(const void *buff, size_t len, char *hexsum)
return
true
;
return
true
;
}
}
bool
pg_md5_binary
(
const
void
*
buff
,
size_t
len
,
void
*
outbuf
)
{
if
(
!
calculateDigestFromBuffer
((
uint8
*
)
buff
,
len
,
outbuf
))
return
false
;
return
true
;
}
/*
/*
...
...
src/backend/libpq/pg_hba.conf.sample
View file @
b3daac5a
...
@@ -39,9 +39,9 @@
...
@@ -39,9 +39,9 @@
# any subnet that the server is directly connected to.
# any subnet that the server is directly connected to.
#
#
# METHOD can be "trust", "reject", "md5", "password", "gss", "sspi",
# METHOD can be "trust", "reject", "md5", "password", "gss", "sspi",
# "krb5", "ident", "pam", "ldap"
or "cert". Note that "password"
# "krb5", "ident", "pam", "ldap"
, "radius" or "cert". Note that
#
sends passwords in clear text; "md5" is preferred since it sends
#
"password" sends passwords in clear text; "md5" is preferred since
# encrypted passwords.
#
it sends
encrypted passwords.
#
#
# OPTIONS are a set of options for the authentication in the format
# OPTIONS are a set of options for the authentication in the format
# NAME=VALUE. The available options depend on the different
# NAME=VALUE. The available options depend on the different
...
...
src/include/libpq/hba.h
View file @
b3daac5a
...
@@ -4,7 +4,7 @@
...
@@ -4,7 +4,7 @@
* Interface to hba.c
* Interface to hba.c
*
*
*
*
* $PostgreSQL: pgsql/src/include/libpq/hba.h,v 1.6
0 2009/12/12 21:35:21
mha Exp $
* $PostgreSQL: pgsql/src/include/libpq/hba.h,v 1.6
1 2010/01/27 12:12:00
mha Exp $
*
*
*-------------------------------------------------------------------------
*-------------------------------------------------------------------------
*/
*/
...
@@ -27,7 +27,8 @@ typedef enum UserAuth
...
@@ -27,7 +27,8 @@ typedef enum UserAuth
uaSSPI
,
uaSSPI
,
uaPAM
,
uaPAM
,
uaLDAP
,
uaLDAP
,
uaCert
uaCert
,
uaRADIUS
}
UserAuth
;
}
UserAuth
;
typedef
enum
IPCompareMethod
typedef
enum
IPCompareMethod
...
@@ -71,6 +72,10 @@ typedef struct
...
@@ -71,6 +72,10 @@ typedef struct
char
*
krb_server_hostname
;
char
*
krb_server_hostname
;
char
*
krb_realm
;
char
*
krb_realm
;
bool
include_realm
;
bool
include_realm
;
char
*
radiusserver
;
char
*
radiussecret
;
char
*
radiusidentifier
;
int
radiusport
;
}
HbaLine
;
}
HbaLine
;
/* kluge to avoid including libpq/libpq-be.h here */
/* kluge to avoid including libpq/libpq-be.h here */
...
...
src/include/libpq/md5.h
View file @
b3daac5a
...
@@ -9,7 +9,7 @@
...
@@ -9,7 +9,7 @@
* Portions Copyright (c) 1996-2010, PostgreSQL Global Development Group
* Portions Copyright (c) 1996-2010, PostgreSQL Global Development Group
* Portions Copyright (c) 1994, Regents of the University of California
* Portions Copyright (c) 1994, Regents of the University of California
*
*
* $PostgreSQL: pgsql/src/include/libpq/md5.h,v 1.
7 2010/01/02 16:58:04 momjian
Exp $
* $PostgreSQL: pgsql/src/include/libpq/md5.h,v 1.
8 2010/01/27 12:12:00 mha
Exp $
*
*
*-------------------------------------------------------------------------
*-------------------------------------------------------------------------
*/
*/
...
@@ -23,6 +23,7 @@
...
@@ -23,6 +23,7 @@
extern
bool
pg_md5_hash
(
const
void
*
buff
,
size_t
len
,
char
*
hexsum
);
extern
bool
pg_md5_hash
(
const
void
*
buff
,
size_t
len
,
char
*
hexsum
);
extern
bool
pg_md5_binary
(
const
void
*
buff
,
size_t
len
,
void
*
outbuf
);
extern
bool
pg_md5_encrypt
(
const
char
*
passwd
,
const
char
*
salt
,
extern
bool
pg_md5_encrypt
(
const
char
*
passwd
,
const
char
*
salt
,
size_t
salt_len
,
char
*
buf
);
size_t
salt_len
,
char
*
buf
);
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment