View previous topic :: View next topic |
Author |
Message |
Max
Joined: 15 Dec 2003 Posts: 51 Location: Italy
|
Authentication in web server with PIC18F67J60 |
Posted: Fri Aug 30, 2019 12:37 pm |
|
|
Dear all,
I built a small card with PIC18F67J60 with some I/O, I built a TCP/IP wizard project with the 5.076 version.
I modified the index.html and index.xml page by adding some buttons. Using makempfsimg.bat to create the mpfsimg.bin file.
Everything works, but now I don't understand two things:
The first is how to create an authenticated page, that is, having to enter user and password to log in, I have read that it must be enabled in ccs_http2.h Code: | HTTP_USE_AUTHENTICATION TRUE | that I did.
But now I can't figure out how to protect a page (even the index for example) so that it asks for user and password.
I read about htaccess. txt but I did not understand how to use it.
Second question:
In my card I have planned a SPI flash memory in which I would like
insert web pages and not put them in ROM so without having to reprogram the chip, this too should be possible, but
I don't understand the steps, what to enable/ disable and above all if to read/write the SPI flash the code is already included in the CCS library or if it is to be added.
Sorry for the length, and I thank in advance who will help me. |
|
|
PCM programmer
Joined: 06 Sep 2003 Posts: 21708
|
|
Posted: Fri Aug 30, 2019 1:56 pm |
|
|
Look at the post at the end of this thread (this is a 2 page thread):
Create User Authentication page and password ENC28J60+PIC18f
http://www.ccsinfo.com/forum/viewtopic.php?t=53623
Also do a web search for this:
Quote: | Development Kit for the Embedded Ethernet Exercise Book pdf |
Read about http authentification, starting at the bottom of page 54. |
|
|
Max
Joined: 15 Dec 2003 Posts: 51 Location: Italy
|
|
Posted: Mon Sep 02, 2019 4:34 am |
|
|
Thanks for reply,
I tried, the post of the link I had read, but I can't get it to work.
I have inserted
Code: | int1 http_check_authentication(char *fileName, char *user, char *pwd)
{
static char goodUser[]="admin";
static char goodPwd[]="admin";
unsigned int1 a;
a= 0;
a=((stricmp(goodUser,user)==0) && (stricmp(goodPwd,pwd)==0));
return(a);
} |
But it is never called.
my htaccess.txt file is like this
Code: |
admin|admin|index.html |
I put it where there is index.html and with makempfsimg.
I create the img file, recompile it all and run it in debug.
From a browser I call the webserver (192.168.xxx.xxx) and open the web page without asking user and password. |
|
|
-Terppa-
Joined: 08 Jan 2018 Posts: 59 Location: Finland
|
|
Posted: Mon Nov 13, 2023 3:21 pm |
|
|
I am also try that and it doesen’t work.. I have one difference, i have folder called protect/test.htm and always it says ”internal server error” ccs_http2.c file i turned on debug files and in terminal i can see message, it cannot found my test.htm
What functions should i use to getting authentication works?
Everything else runs ok dynamic vars, index.htm, serial port etc but not authentication.
Somebody have basic guidelines for that?
Br |
|
|
-Terppa-
Joined: 08 Jan 2018 Posts: 59 Location: Finland
|
|
Posted: Tue Nov 14, 2023 5:49 am |
|
|
A little digging i found some interesting failure. When i use MPFS (my bat file have: mpfs /b /r0 /ll /k ../pages mpfsimg.bin)
It only generates ”root” files in mpfsimg.bin
All files what includes /protect folder missing. (test.htm, htaccess.txt)
Should i use mpfs2 or use more parameters for my make.bat? |
|
|
|