PDA

View Full Version : Form for secure settings


koutasek
03-07-2007, 12:35 AM
Hello,
I have a simple problem, but I'm a beginner and I have not idea how to do that. I made secure www pages with SSL autentization from sample programs and now I want to make a simple form, which will change password for login entered user.

Can you help me pls?

IWriteCode
03-08-2007, 01:55 AM
What is it exactly what you want to do?

You have SSL & authentication? And you want a user to be able to change the password for logging in to the server?

Posting the code you used, or relevant parts of it, would be very useful!

koutasek
03-08-2007, 04:24 PM
What is it exactly what you want to do?

You have SSL & authentication? And you want a user to be able to change the password for logging in to the server?

Posting the code you used, or relevant parts of it, would be very useful!

Yes. I'm using sample program Sample/tcpip/SSL/SSL_AUTHENTICATION.C for loggin to the www pages and now I looking for sample how to change user's password which is log in. Some sample how to call function with html(form) arguments. Maybe it is a simple but I don't know how to make it, because I'm begginer and I have not time learn all dynamic C :(

I need this for my diplome thesis :)

IWriteCode
03-09-2007, 03:11 AM
Users are added with sauth_adduser & sspec_adduser...

Removing a user can be done by calling the 'reverse' of these functions: sauth_removeuser & sspec_removeuser

So changing the password is easy, remove the user for which the password must be altered, and add the same user again with the new password...

koutasek
03-09-2007, 04:39 AM
Users are added with sauth_adduser & sspec_adduser...

Removing a user can be done by calling the 'reverse' of these functions: sauth_removeuser & sspec_removeuser

So changing the password is easy, remove the user for which the password must be altered, and add the same user again with the new password...

And how I make it from http request(simple form with one button and one text field)? Some cgi? Or something else?
I'm trying traslate TCP/IP V.2 documentacion now - maybe I find there what I want. Sorry for a dump question to you but I' kind of lost in Dynamic C. :(

Maybe is some good sample, which I overlooked it?

IWriteCode
03-09-2007, 05:22 AM
The problem I had with the SSL site, is that it's more difficult to access the buffers which are sent and received. So I used the default rabbit way of making forms, which is shown in the SSL_FORM.C sample.
Then I added an extra cgi page, which saves the config form data to flash... don't know if there's a callback function available for when you save the rabbit form for altering the password there...

koutasek
03-10-2007, 01:51 PM
The problem I had with the SSL site, is that it's more difficult to access the buffers which are sent and received. So I used the default rabbit way of making forms, which is shown in the SSL_FORM.C sample.
Then I added an extra cgi page, which saves the config form data to flash... don't know if there's a callback function available for when you save the rabbit form for altering the password there...

Maybe I have it!
I used SSL_FORM.C sample, how you said me. I didn't use CGI, but sspec_setfvcheck(form, var, check_and_change); , which compare two inputs and if the inputs are identic function changes the password.
Now I have two problems with the form and with the new password. First problem is with text field. Now is the field type text. How do I make the field as type password?
Second problem is: when I shutdown rabbit, rabbit doesn't remebmer new password. Is a sample, which this problem resolves?

Thx for help!

IWriteCode
03-10-2007, 02:36 PM
The variables are in RAM, so when the power is switched off, it's gone. You need to store the password, on a lot of boards, there's serial flash available. Store the password there, and retrieve it when the application starts.

Not sure on the password box, will check on monday at work.

koutasek
03-11-2007, 03:05 AM
The variables are in RAM, so when the power is switched off, it's gone. You need to store the password, on a lot of boards, there's serial flash available. Store the password there, and retrieve it when the application starts.

Not sure on the password box, will check on monday at work.

Thank you for support. I thought it too but i didn't know how to do it :) I try to find in documentation. So... "see you tomorrov on monday here"

Thx

IWriteCode
03-11-2007, 03:21 AM
Check the samples directory of your board / core module. There might be a serial_flash sample which you can use.

koutasek
03-11-2007, 05:30 AM
Check the samples directory of your board / core module. There might be a serial_flash sample which you can use.

Thx. I will check it.
Please, can you try to give a part(in the sample SSL_FORM.C), which creates a form to the function and then this function call in main()? I tried it but the function didn't create a form but something indescribably(crashed form without inputs) :(

IWriteCode
03-11-2007, 06:13 AM
Uhmm.. what is it exactly what you want? What module are you using anyways? That's handy to know :)

koutasek
03-11-2007, 07:56 AM
Uhmm.. what is it exactly what you want? What module are you using anyways? That's handy to know :)

I want to create form as function not in main(). The part, which creates the form I incuded to the function and call it.

Exactly this part(part was saparate from SSL_FORM.C):

void form_init()
{


// Declare the FormVar array to hold form variable information
auto FormVar myform[1];
auto int var;
auto int form;
// This array lists the options that are possible for the fail variable
static const char* const fail_options[] = {
"Email",
"Page",
"Email and page",
"Nothing"
};

// Initialize variables
temphi = 80;
tempnow = 72;
templo = 65;
humidity = 0.3;
strcpy(fail, "Page");

// Add the form (array of variables)
// Note the use of SERVER_HTTPS instead of SERVER_HTTP. This means that
// the form declared here is only accessible from an SSL-secured HTTPS
// socket. If you want this form to be accessible from both HTTPS and
// HTTP clients, then the final parameter would be
// SERVER_HTTPS | SERVER_HTTP
form = sspec_addform("myform.html", myform, 1, SERVER_HTTPS);

// Set the title of the form
sspec_setformtitle(form, "ACME Thermostat Settings");

// Add the first variable, and set it up with the form
var = sspec_addvariable("temphi", &temphi, INT16, "%d", SERVER_HTTPS);
var = sspec_addfv(form, var);
sspec_setfvname(form, var, "High Temp");
sspec_setfvdesc(form, var, "Maximum in temperature range (60 - 90 °F)");
sspec_setfvlen(form, var, 5);
sspec_setfvrange(form, var, 60, 90);
sspec_setfvcheck(form, var, checkHighTemp);



// Create aliases for this form. This allows the form to be accessed from
// other locations.
sspec_aliasspec(form, "index.html");
sspec_aliasspec(form, "/");
}

void main(void)
{

form_init();
sock_init();
http_init();
tcp_reserveport(80);

// We need to reserve the HTTPS port as well, which is TCP port 443
tcp_reserveport(443);

while (1) {
http_handler();
}
}



and when I call this part as function... you can see result here --> http://v-design.cz/mata/form.JPG

I see, that similary way is in SERIAL_FLASHLOG.C sample, where form is create as function too. I try to understand from this sample.

Btw. I use RCM3700 development kit. I appreciate your help. Thank you for your time. ;)

koutasek
03-11-2007, 08:16 AM
Oh. I have it..
I changed declaration of variable form from auto to static and form is good. :)

What do you think about the TYPE of text's fields? How do I make "password" type of text field? Now they are created as "text" type. I mean this:

<INPUT TYPE="text" NAME="temphi" VALUE="80" SIZE="5">

IWriteCode
03-12-2007, 03:54 AM
I check the code in ZSERVER.LIB, it looks like there's no option to make a password box...

koutasek
03-12-2007, 07:53 AM
I check the code in ZSERVER.LIB, it looks like there's no option to make a password box...

So, next way how to make it is by using POST2.C sample, where is presented method how to work with post data from a small form. But i try it with SSL and something in function int parse_post(HttpState* state) was bad.

:(

IWriteCode
03-12-2007, 08:05 AM
Yah, that was also my initial approach when working with SSL, but since it's difficult to access the decrypted buffers directly, I switched to the rabbit form handling...