Skip to content
Projects
Groups
Snippets
Help
Loading...
Sign in / Register
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
Packages
Packages
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
submodule
mongoose
Commits
9ab6d084
Commit
9ab6d084
authored
Nov 27, 2017
by
Dmitry Frank
Committed by
Cesanta Bot
Nov 28, 2017
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Expose digest auth checking functions
PUBLISHED_FROM=1bfc6e332f56b68eb6155bb729a97a0d8d5a316c
parent
cf8d0a25
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
54 additions
and
10 deletions
+54
-10
intro.md
docs/c-api/http.h/intro.md
+2
-0
mg_http_is_authorized.md
docs/c-api/http.h/mg_http_is_authorized.md
+16
-0
mg_http_send_digest_auth_request.md
docs/c-api/http.h/mg_http_send_digest_auth_request.md
+11
-0
mongoose.c
mongoose.c
+8
-10
mongoose.h
mongoose.h
+17
-0
No files found.
docs/c-api/http.h/intro.md
View file @
9ab6d084
...
...
@@ -5,6 +5,8 @@ decl_name: "http.h"
items
:
-
{
name
:
mg_connect_ws.md
}
-
{
name
:
mg_connect_ws_opt.md
}
-
{
name
:
mg_http_is_authorized.md
}
-
{
name
:
mg_http_send_digest_auth_request.md
}
-
{
name
:
mg_printf_websocket_frame.md
}
-
{
name
:
mg_send_websocket_frame.md
}
-
{
name
:
mg_send_websocket_framev.md
}
...
...
docs/c-api/http.h/mg_http_is_authorized.md
0 → 100644
View file @
9ab6d084
---
title
:
"
mg_http_is_authorized()"
decl_name
:
"
mg_http_is_authorized"
symbol_kind
:
"
func"
signature
:
|
int mg_http_is_authorized(struct http_message *hm, struct mg_str path,
int is_directory, const char *domain,
const char *passwords_file, int is_global_pass_file);
---
Checks whether an http request is authorized.
`domain`
is the authentication
realm,
`passwords_file`
is a htdigest file (can be created e.g. with
`htdigest`
utility). If either
`domain`
or
`passwords_file`
is NULL, this
function always returns 1; otherwise checks the authentication in the
http request and returns 1 only if there is a match; 0 otherwise.
docs/c-api/http.h/mg_http_send_digest_auth_request.md
0 → 100644
View file @
9ab6d084
---
title
:
"
mg_http_send_digest_auth_request()"
decl_name
:
"
mg_http_send_digest_auth_request"
symbol_kind
:
"
func"
signature
:
|
void mg_http_send_digest_auth_request(struct mg_connection *c,
const char *domain);
---
Sends 401 Unauthorized response.
mongoose.c
View file @
9ab6d084
...
...
@@ -7363,10 +7363,9 @@ int mg_check_digest_auth(struct mg_str method, struct mg_str uri,
return
0
;
}
static
int
mg_http_is_authorized
(
struct
http_message
*
hm
,
struct
mg_str
path
,
int
is_directory
,
const
char
*
domain
,
const
char
*
passwords_file
,
int
is_global_pass_file
)
{
int
mg_http_is_authorized
(
struct
http_message
*
hm
,
struct
mg_str
path
,
int
is_directory
,
const
char
*
domain
,
const
char
*
passwords_file
,
int
is_global_pass_file
)
{
char
buf
[
MG_MAX_PATH
];
const
char
*
p
;
FILE
*
fp
;
...
...
@@ -7399,10 +7398,9 @@ static int mg_http_is_authorized(struct http_message *hm, struct mg_str path,
return
authorized
;
}
#else
static
int
mg_http_is_authorized
(
struct
http_message
*
hm
,
const
struct
mg_str
path
,
int
is_directory
,
const
char
*
domain
,
const
char
*
passwords_file
,
int
is_global_pass_file
)
{
int
mg_http_is_authorized
(
struct
http_message
*
hm
,
const
struct
mg_str
path
,
int
is_directory
,
const
char
*
domain
,
const
char
*
passwords_file
,
int
is_global_pass_file
)
{
(
void
)
hm
;
(
void
)
path
;
(
void
)
is_directory
;
...
...
@@ -7942,8 +7940,8 @@ MG_INTERNAL int mg_is_not_modified(struct http_message *hm, cs_stat_t *st) {
}
}
static
void
mg_http_send_digest_auth_request
(
struct
mg_connection
*
c
,
const
char
*
domain
)
{
void
mg_http_send_digest_auth_request
(
struct
mg_connection
*
c
,
const
char
*
domain
)
{
mg_printf
(
c
,
"HTTP/1.1 401 Unauthorized
\r\n
"
"WWW-Authenticate: Digest qop=
\"
auth
\"
, "
...
...
mongoose.h
View file @
9ab6d084
...
...
@@ -4541,6 +4541,23 @@ extern void mg_hash_md5_v(size_t num_msgs, const uint8_t *msgs[],
extern
void
mg_hash_sha1_v
(
size_t
num_msgs
,
const
uint8_t
*
msgs
[],
const
size_t
*
msg_lens
,
uint8_t
*
digest
);
/*
* Checks whether an http request is authorized. `domain` is the authentication
* realm, `passwords_file` is a htdigest file (can be created e.g. with
* `htdigest` utility). If either `domain` or `passwords_file` is NULL, this
* function always returns 1; otherwise checks the authentication in the
* http request and returns 1 only if there is a match; 0 otherwise.
*/
int
mg_http_is_authorized
(
struct
http_message
*
hm
,
struct
mg_str
path
,
int
is_directory
,
const
char
*
domain
,
const
char
*
passwords_file
,
int
is_global_pass_file
);
/*
* Sends 401 Unauthorized response.
*/
void
mg_http_send_digest_auth_request
(
struct
mg_connection
*
c
,
const
char
*
domain
);
#ifdef __cplusplus
}
#endif
/* __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