Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Contribute to GitLab
Sign in
Toggle navigation
M
mongoose
Project
Project
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
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
esp
mongoose
Commits
a3663da9
Commit
a3663da9
authored
Jan 13, 2014
by
Sergey Lyubka
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Exposed mg_send_digest_auth_request(). Exported conn->content to Lua
parent
f74a1e1d
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
14 additions
and
8 deletions
+14
-8
mongoose.c
mongoose.c
+13
-8
mongoose.h
mongoose.h
+1
-0
No files found.
mongoose.c
View file @
a3663da9
...
...
@@ -2628,15 +2628,15 @@ static void send_options(struct connection *conn) {
#endif // NO_DAV
#ifndef NO_AUTH
static
void
send_authorization_request
(
struct
connection
*
conn
)
{
conn
->
mg_conn
.
status_code
=
401
;
mg_printf
(
&
conn
->
mg_conn
,
void
mg_send_digest_auth_request
(
struct
mg_connection
*
c
)
{
struct
connection
*
conn
=
(
struct
connection
*
)
c
;
c
->
status_code
=
401
;
mg_printf
(
c
,
"HTTP/1.1 401 Unauthorized
\r\n
"
"WWW-Authenticate: Digest qop=
\"
auth
\"
, "
"realm=
\"
%s
\"
, nonce=
\"
%lu
\"\r\n\r\n
"
,
conn
->
server
->
config_options
[
AUTH_DOMAIN
],
(
unsigned
long
)
time
(
NULL
));
close_local_endpoint
(
conn
);
}
// Use the global passwords file, if specified by auth_gpass option,
...
...
@@ -2963,7 +2963,7 @@ static int is_authorized_for_dav(struct connection *conn) {
return
authorized
;
}
static
int
is_da
ngerous_dav_request
(
const
struct
connection
*
conn
)
{
static
int
is_da
v_mutation
(
const
struct
connection
*
conn
)
{
const
char
*
s
=
conn
->
mg_conn
.
request_method
;
return
s
&&
(
!
strcmp
(
s
,
"PUT"
)
||
!
strcmp
(
s
,
"DELETE"
)
||
!
strcmp
(
s
,
"MKCOL"
));
...
...
@@ -3186,6 +3186,10 @@ static void prepare_lua_environment(struct mg_connection *ri, lua_State *L) {
reg_string
(
L
,
"query_string"
,
ri
->
query_string
);
reg_string
(
L
,
"remote_ip"
,
ri
->
remote_ip
);
reg_int
(
L
,
"remote_port"
,
ri
->
remote_port
);
lua_pushstring
(
L
,
"content"
);
lua_pushlstring
(
L
,
ri
->
content
==
NULL
?
""
:
ri
->
content
,
0
);
lua_rawset
(
L
,
-
3
);
reg_int
(
L
,
"content_len"
,
ri
->
content_len
);
reg_int
(
L
,
"num_headers"
,
ri
->
num_headers
);
lua_pushstring
(
L
,
"http_headers"
);
lua_newtable
(
L
);
...
...
@@ -3310,9 +3314,10 @@ static void open_local_endpoint(struct connection *conn) {
}
else
if
(
conn
->
server
->
config_options
[
DOCUMENT_ROOT
]
==
NULL
)
{
send_http_error
(
conn
,
404
,
NULL
);
#ifndef NO_AUTH
}
else
if
((
!
is_dangerous_dav_request
(
conn
)
&&
!
is_authorized
(
conn
,
path
))
||
(
is_dangerous_dav_request
(
conn
)
&&
!
is_authorized_for_dav
(
conn
)))
{
send_authorization_request
(
conn
);
}
else
if
((
!
is_dav_mutation
(
conn
)
&&
!
is_authorized
(
conn
,
path
))
||
(
is_dav_mutation
(
conn
)
&&
!
is_authorized_for_dav
(
conn
)))
{
mg_send_digest_auth_request
(
&
conn
->
mg_conn
);
close_local_endpoint
(
conn
);
#endif
#ifndef NO_DAV
}
else
if
(
!
strcmp
(
conn
->
mg_conn
.
request_method
,
"PROPFIND"
))
{
...
...
mongoose.h
View file @
a3663da9
...
...
@@ -97,6 +97,7 @@ int mg_parse_header(const char *hdr, const char *var_name, char *buf, size_t);
void
*
mg_start_thread
(
void
*
(
*
func
)(
void
*
),
void
*
param
);
char
*
mg_md5
(
char
buf
[
33
],
...);
int
mg_authorize_digest
(
struct
mg_connection
*
c
,
FILE
*
fp
);
void
mg_send_digest_auth_request
(
struct
mg_connection
*
conn
);
#ifdef __cplusplus
}
...
...
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