Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
A
authserv
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Deploy
Releases
Model registry
Monitor
Incidents
Service Desk
Analyze
Value stream analytics
Contributor analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
This is an archived project. Repository and other project resources are read-only.
Show more breadcrumbs
ai
authserv
Commits
c9f890a5
Commit
c9f890a5
authored
10 years ago
by
ale
Browse files
Options
Downloads
Patches
Plain Diff
implement sharded services (client side)
parent
ce40618d
No related branches found
Branches containing commit
No related tags found
No related merge requests found
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
pam/auth_client.c
+5
-1
5 additions, 1 deletion
pam/auth_client.c
pam/auth_client.h
+2
-1
2 additions, 1 deletion
pam/auth_client.h
pam/auth_client_test.cc
+5
-5
5 additions, 5 deletions
pam/auth_client_test.cc
pam/pam_authclient.c
+4
-1
4 additions, 1 deletion
pam/pam_authclient.c
with
16 additions
and
8 deletions
pam/auth_client.c
+
5
−
1
View file @
c9f890a5
...
...
@@ -192,7 +192,8 @@ int auth_client_authenticate(auth_client_t ac,
const
char
*
username
,
const
char
*
password
,
const
char
*
otp_token
,
const
char
*
source_ip
)
{
const
char
*
source_ip
,
const
char
*
shard
)
{
struct
curl_slist
*
headers
=
NULL
;
struct
cbuf
form
;
struct
cbuf
responsebuf
;
...
...
@@ -212,6 +213,9 @@ int auth_client_authenticate(auth_client_t ac,
if
(
source_ip
)
{
post_field_add
(
&
form
,
"source_ip"
,
source_ip
);
}
if
(
shard
)
{
post_field_add
(
&
form
,
"shard"
,
shard
);
}
curl_easy_setopt
(
ac
->
c
,
CURLOPT_POSTFIELDS
,
form
.
buf
);
// Set request headers.
...
...
This diff is collapsed.
Click to expand it.
pam/auth_client.h
+
2
−
1
View file @
c9f890a5
...
...
@@ -27,6 +27,7 @@ int auth_client_authenticate(auth_client_t ac,
const
char
*
username
,
const
char
*
password
,
const
char
*
otp_token
,
const
char
*
source_ip
);
const
char
*
source_ip
,
const
char
*
shard
);
#endif
This diff is collapsed.
Click to expand it.
pam/auth_client_test.cc
+
5
−
5
View file @
c9f890a5
...
...
@@ -54,7 +54,7 @@ TEST_F(AuthClientTest, AuthOK) {
result
=
auth_client_set_certificate
(
ac
,
ssl_ca
,
ssl_cert
,
ssl_key
);
EXPECT_EQ
(
AC_OK
,
result
)
<<
"set_certificate() error: "
<<
auth_client_strerror
(
result
);
result
=
auth_client_authenticate
(
ac
,
"user"
,
"pass"
,
NULL
,
"127.0.0.1"
);
result
=
auth_client_authenticate
(
ac
,
"user"
,
"pass"
,
NULL
,
"127.0.0.1"
,
NULL
);
EXPECT_EQ
(
AC_OK
,
result
)
<<
"authenticate() error: "
<<
auth_client_strerror
(
result
)
<<
", server="
<<
server
;
}
...
...
@@ -65,7 +65,7 @@ TEST_F(AuthClientTest, AuthFail) {
result
=
auth_client_set_certificate
(
ac
,
ssl_ca
,
ssl_cert
,
ssl_key
);
EXPECT_EQ
(
AC_OK
,
result
)
<<
"set_certificate() error: "
<<
auth_client_strerror
(
result
);
result
=
auth_client_authenticate
(
ac
,
"user"
,
"bad_password"
,
NULL
,
"127.0.0.1"
);
result
=
auth_client_authenticate
(
ac
,
"user"
,
"bad_password"
,
NULL
,
"127.0.0.1"
,
NULL
);
EXPECT_NE
(
AC_OK
,
result
)
<<
"authenticate() didn't fail"
<<
", server="
<<
server
;
}
...
...
@@ -82,7 +82,7 @@ TEST_F(AuthClientTest, SSLFailsWithBadCertificate) {
result
=
auth_client_set_certificate
(
ac
,
ssl_ca
,
ssl_ca
,
ssl_key
);
EXPECT_EQ
(
AC_OK
,
result
)
<<
"set_certificate() error: "
<<
auth_client_strerror
(
result
);
result
=
auth_client_authenticate
(
ac
,
"user"
,
"pass"
,
NULL
,
"127.0.0.1"
);
result
=
auth_client_authenticate
(
ac
,
"user"
,
"pass"
,
NULL
,
"127.0.0.1"
,
NULL
);
EXPECT_NE
(
AC_OK
,
result
)
<<
"authenticate() didn't fail, server="
<<
server
;
}
...
...
@@ -93,7 +93,7 @@ TEST_F(AuthClientTest, SSLFailsWithBadCAClientSide) {
result
=
auth_client_set_certificate
(
ac
,
ssl_bad_ca
,
ssl_cert
,
ssl_key
);
EXPECT_EQ
(
AC_OK
,
result
)
<<
"set_certificate() error: "
<<
auth_client_strerror
(
result
);
result
=
auth_client_authenticate
(
ac
,
"user"
,
"pass"
,
NULL
,
"127.0.0.1"
);
result
=
auth_client_authenticate
(
ac
,
"user"
,
"pass"
,
NULL
,
"127.0.0.1"
,
NULL
);
EXPECT_NE
(
AC_OK
,
result
)
<<
"authenticate() didn't fail, server="
<<
server
;
}
...
...
@@ -104,7 +104,7 @@ TEST_F(AuthClientTest, SSLFailsWithBadCAServerSide) {
result
=
auth_client_set_certificate
(
ac
,
ssl_ca
,
ssl_bad_cert
,
ssl_bad_key
);
EXPECT_EQ
(
AC_OK
,
result
)
<<
"set_certificate() error: "
<<
auth_client_strerror
(
result
);
result
=
auth_client_authenticate
(
ac
,
"user"
,
"pass"
,
NULL
,
"127.0.0.1"
);
result
=
auth_client_authenticate
(
ac
,
"user"
,
"pass"
,
NULL
,
"127.0.0.1"
,
NULL
);
EXPECT_NE
(
AC_OK
,
result
)
<<
"authenticate() didn't fail, server="
<<
server
;
}
...
...
This diff is collapsed.
Click to expand it.
pam/pam_authclient.c
+
4
−
1
View file @
c9f890a5
...
...
@@ -55,6 +55,7 @@ struct cfg {
char
*
ssl_crt
;
char
*
ssl_key
;
char
*
ca_file
;
char
*
shard
;
};
static
void
parse_cfg
(
int
argc
,
const
char
**
argv
,
struct
cfg
*
cfg
)
{
...
...
@@ -76,6 +77,8 @@ static void parse_cfg(int argc, const char **argv, struct cfg *cfg) {
cfg
->
ssl_key
=
(
char
*
)(
argv
[
i
]
+
8
);
}
else
if
(
!
strncmp
(
argv
[
i
],
"ca="
,
3
))
{
cfg
->
ca_file
=
(
char
*
)(
argv
[
i
]
+
3
);
}
else
if
(
!
strncmp
(
argv
[
i
],
"shard="
,
6
))
{
cfg
->
shard
=
(
char
*
)(
argv
[
i
]
+
6
);
}
}
}
...
...
@@ -155,7 +158,7 @@ PAM_EXTERN int pam_sm_authenticate(pam_handle_t *pamh,
// Allow two authentication attempts in case we receive an
// OTP_REQUIRED response from the server.
for
(
i
=
0
;
i
<
2
;
i
++
)
{
int
ac_err
=
auth_client_authenticate
(
ac
,
username
,
password
,
otp_token
,
source_ip
);
int
ac_err
=
auth_client_authenticate
(
ac
,
username
,
password
,
otp_token
,
source_ip
,
cfg
.
shard
);
if
(
ac_err
==
AC_OK
)
{
retval
=
PAM_SUCCESS
;
}
else
if
(
ac_err
==
AC_ERR_OTP_REQUIRED
)
{
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment