mirror of
https://github.com/processone/ejabberd.git
synced 2024-09-27 14:30:55 +02:00
Request basic auth dialog from browser
This commit is contained in:
parent
35a11526f9
commit
51fa438340
@ -59,8 +59,13 @@
|
|||||||
-define(HTTP_ERR_FILE_NOT_FOUND,
|
-define(HTTP_ERR_FILE_NOT_FOUND,
|
||||||
{-1, 404, [], <<"Not found">>}).
|
{-1, 404, [], <<"Not found">>}).
|
||||||
|
|
||||||
|
-define(REQUEST_AUTH_HEADERS,
|
||||||
|
[{<<"WWW-Authenticate">>, <<"Basic realm=\"ejabberd\"">>}]).
|
||||||
|
|
||||||
-define(HTTP_ERR_FORBIDDEN,
|
-define(HTTP_ERR_FORBIDDEN,
|
||||||
{-1, 403, [], <<"Forbidden">>}).
|
{-1, 403, [], <<"Forbidden">>}).
|
||||||
|
-define(HTTP_ERR_REQUEST_AUTH,
|
||||||
|
{-1, 401, ?REQUEST_AUTH_HEADERS, <<"Unauthorized">>}).
|
||||||
|
|
||||||
-define(DEFAULT_CONTENT_TYPE,
|
-define(DEFAULT_CONTENT_TYPE,
|
||||||
<<"application/octet-stream">>).
|
<<"application/octet-stream">>).
|
||||||
@ -317,12 +322,17 @@ serve(LocalPath, Auth, DocRoot, DirectoryIndices, CustomHeaders, DefaultContentT
|
|||||||
false
|
false
|
||||||
end,
|
end,
|
||||||
case CanProceed of
|
case CanProceed of
|
||||||
|
false ->
|
||||||
|
?HTTP_ERR_REQUEST_AUTH;
|
||||||
true ->
|
true ->
|
||||||
FileName = filename:join(filename:split(DocRoot) ++ LocalPath),
|
FileName = filename:join(filename:split(DocRoot) ++ LocalPath),
|
||||||
case file:read_file_info(FileName) of
|
case file:read_file_info(FileName) of
|
||||||
{error, enoent} -> ?HTTP_ERR_FILE_NOT_FOUND;
|
{error, enoent} ->
|
||||||
{error, enotdir} -> ?HTTP_ERR_FILE_NOT_FOUND;
|
?HTTP_ERR_FILE_NOT_FOUND;
|
||||||
{error, eacces} -> ?HTTP_ERR_FORBIDDEN;
|
{error, enotdir} ->
|
||||||
|
?HTTP_ERR_FILE_NOT_FOUND;
|
||||||
|
{error, eacces} ->
|
||||||
|
?HTTP_ERR_FORBIDDEN;
|
||||||
{ok, #file_info{type = directory}} -> serve_index(FileName,
|
{ok, #file_info{type = directory}} -> serve_index(FileName,
|
||||||
DirectoryIndices,
|
DirectoryIndices,
|
||||||
CustomHeaders,
|
CustomHeaders,
|
||||||
|
Loading…
Reference in New Issue
Block a user