Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
G
git2
Overview
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
lvzhengyang
git2
Commits
39028eb6
Unverified
Commit
39028eb6
authored
Sep 09, 2019
by
Edward Thomson
Committed by
GitHub
Sep 09, 2019
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #5212 from libgit2/ethomson/creds_for_scheme
Use an HTTP scheme that supports the given credentials
parents
5fc27aac
4de51f9e
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
17 additions
and
9 deletions
+17
-9
src/transports/auth.c
+1
-1
src/transports/http.c
+16
-8
No files found.
src/transports/auth.c
View file @
39028eb6
...
@@ -70,6 +70,6 @@ int git_http_auth_dummy(
...
@@ -70,6 +70,6 @@ int git_http_auth_dummy(
GIT_UNUSED
(
url
);
GIT_UNUSED
(
url
);
*
out
=
NULL
;
*
out
=
NULL
;
return
0
;
return
GIT_PASSTHROUGH
;
}
}
src/transports/http.c
View file @
39028eb6
...
@@ -129,17 +129,22 @@ typedef struct {
...
@@ -129,17 +129,22 @@ typedef struct {
size_t
*
bytes_read
;
size_t
*
bytes_read
;
}
parser_context
;
}
parser_context
;
static
git_http_auth_scheme
*
scheme_for_challenge
(
const
char
*
challenge
)
static
git_http_auth_scheme
*
scheme_for_challenge
(
const
char
*
challenge
,
git_cred
*
cred
)
{
{
git_http_auth_scheme
*
scheme
=
NULL
;
git_http_auth_scheme
*
scheme
=
NULL
;
size_t
i
;
size_t
i
;
for
(
i
=
0
;
i
<
ARRAY_SIZE
(
auth_schemes
);
i
++
)
{
for
(
i
=
0
;
i
<
ARRAY_SIZE
(
auth_schemes
);
i
++
)
{
const
char
*
scheme_name
=
auth_schemes
[
i
].
name
;
const
char
*
scheme_name
=
auth_schemes
[
i
].
name
;
const
git_credtype_t
scheme_types
=
auth_schemes
[
i
].
credtypes
;
size_t
scheme_len
;
size_t
scheme_len
;
scheme_len
=
strlen
(
scheme_name
);
scheme_len
=
strlen
(
scheme_name
);
if
(
strncasecmp
(
challenge
,
scheme_name
,
scheme_len
)
==
0
&&
if
((
!
cred
||
(
cred
->
credtype
&
scheme_types
))
&&
strncasecmp
(
challenge
,
scheme_name
,
scheme_len
)
==
0
&&
(
challenge
[
scheme_len
]
==
'\0'
||
challenge
[
scheme_len
]
==
' '
))
{
(
challenge
[
scheme_len
]
==
'\0'
||
challenge
[
scheme_len
]
==
' '
))
{
scheme
=
&
auth_schemes
[
i
];
scheme
=
&
auth_schemes
[
i
];
break
;
break
;
...
@@ -256,7 +261,7 @@ static int set_authentication_types(http_server *server)
...
@@ -256,7 +261,7 @@ static int set_authentication_types(http_server *server)
size_t
i
;
size_t
i
;
git_vector_foreach
(
&
server
->
auth_challenges
,
i
,
challenge
)
{
git_vector_foreach
(
&
server
->
auth_challenges
,
i
,
challenge
)
{
if
((
scheme
=
scheme_for_challenge
(
challenge
))
!=
NULL
)
{
if
((
scheme
=
scheme_for_challenge
(
challenge
,
NULL
))
!=
NULL
)
{
server
->
authtypes
|=
scheme
->
type
;
server
->
authtypes
|=
scheme
->
type
;
server
->
credtypes
|=
scheme
->
credtypes
;
server
->
credtypes
|=
scheme
->
credtypes
;
}
}
...
@@ -430,9 +435,10 @@ static int init_auth(http_server *server)
...
@@ -430,9 +435,10 @@ static int init_auth(http_server *server)
git_http_auth_scheme
*
s
,
*
scheme
=
NULL
;
git_http_auth_scheme
*
s
,
*
scheme
=
NULL
;
char
*
c
,
*
challenge
=
NULL
;
char
*
c
,
*
challenge
=
NULL
;
size_t
i
;
size_t
i
;
int
error
;
git_vector_foreach
(
&
server
->
auth_challenges
,
i
,
c
)
{
git_vector_foreach
(
&
server
->
auth_challenges
,
i
,
c
)
{
s
=
scheme_for_challenge
(
c
);
s
=
scheme_for_challenge
(
c
,
server
->
cred
);
if
(
s
&&
!!
(
s
->
credtypes
&
server
->
credtypes
))
{
if
(
s
&&
!!
(
s
->
credtypes
&
server
->
credtypes
))
{
scheme
=
s
;
scheme
=
s
;
...
@@ -446,12 +452,14 @@ static int init_auth(http_server *server)
...
@@ -446,12 +452,14 @@ static int init_auth(http_server *server)
return
-
1
;
return
-
1
;
}
}
if
(
scheme
->
init_context
(
&
server
->
auth_context
,
&
server
->
url
)
<
0
)
if
((
error
=
scheme
->
init_context
(
&
server
->
auth_context
,
&
server
->
url
))
==
GIT_PASSTHROUGH
)
return
-
1
;
return
0
;
else
if
(
error
<
0
)
return
error
;
if
(
server
->
auth_context
->
set_challenge
&&
if
(
server
->
auth_context
->
set_challenge
&&
server
->
auth_context
->
set_challenge
(
server
->
auth_context
,
challenge
)
<
0
)
(
error
=
server
->
auth_context
->
set_challenge
(
server
->
auth_context
,
challenge
)
)
<
0
)
return
-
1
;
return
error
;
return
0
;
return
0
;
}
}
...
...
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