|
@@ -25,7 +25,6 @@
|
|
|
|
|
|
#include "goahead.h"
|
|
|
#include "ResultUtils.h"
|
|
|
-#include <stdio.h>
|
|
|
|
|
|
#if ME_GOAHEAD_AUTH
|
|
|
|
|
@@ -138,7 +137,6 @@ PUBLIC bool websAuthenticate(Webs *wp)
|
|
|
websSetSessionVar(wp, WEBS_SESSION_USERNAME, wp->username);
|
|
|
}
|
|
|
}
|
|
|
- printf("---> websAuthenticate, wp->username: %s\n", wp->username);
|
|
|
return 1;
|
|
|
}
|
|
|
|
|
@@ -187,7 +185,6 @@ PUBLIC void websCloseAuth(void)
|
|
|
{
|
|
|
WebsKey *key, *next;
|
|
|
|
|
|
- printf("---> websCloseAuth, users = %d, roles = %d\n", users, roles);
|
|
|
wfree(masterSecret);
|
|
|
if (users >= 0) {
|
|
|
for (key = hashFirst(users); key; key = next) {
|
|
@@ -220,7 +217,6 @@ PUBLIC int websWriteAuthFile(char *path)
|
|
|
assert(path && *path);
|
|
|
|
|
|
tempFile = websTempFile(NULL, NULL);
|
|
|
- printf("---> websTempFile: %s\n", tempFile);
|
|
|
if ((fp = fopen(tempFile, "w" FILE_TEXT)) == 0) {
|
|
|
error("Cannot open %s", tempFile);
|
|
|
wfree(tempFile);
|
|
@@ -272,8 +268,6 @@ static WebsUser *createUser(cchar *username, cchar *password, cchar *roles)
|
|
|
user->roles = sclone(roles);
|
|
|
user->password = sclone(password);
|
|
|
user->abilities = -1;
|
|
|
-
|
|
|
- printf("---> createUser, name: %s, roles: %s, password: %s\n", user->name, user->roles, user->password);
|
|
|
return user;
|
|
|
}
|
|
|
|
|
@@ -282,7 +276,6 @@ WebsUser *websAddUser(cchar *username, cchar *password, cchar *roles)
|
|
|
{
|
|
|
WebsUser *user;
|
|
|
|
|
|
- printf("---> websAddUser, name: %s, roles: %s, password: %s\n", username, roles, password);
|
|
|
if (!username) {
|
|
|
error("User is missing name");
|
|
|
return 0;
|
|
@@ -298,7 +291,6 @@ WebsUser *websAddUser(cchar *username, cchar *password, cchar *roles)
|
|
|
if (hashEnter(users, username, valueSymbol(user), 0) == 0) {
|
|
|
return 0;
|
|
|
}
|
|
|
-
|
|
|
return user;
|
|
|
}
|
|
|
|
|
@@ -307,7 +299,6 @@ PUBLIC int websRemoveUser(cchar *username)
|
|
|
{
|
|
|
WebsKey *key;
|
|
|
|
|
|
- printf("---> websRemoveUser, name: %s\n", username);
|
|
|
assert(username);
|
|
|
if ((key = hashLookup(users, username)) != 0) {
|
|
|
freeUser(key->content.value.symbol);
|
|
@@ -318,7 +309,6 @@ PUBLIC int websRemoveUser(cchar *username)
|
|
|
|
|
|
static void freeUser(WebsUser *up)
|
|
|
{
|
|
|
- printf("---> freeUser\n");
|
|
|
assert(up);
|
|
|
hashFree(up->abilities);
|
|
|
wfree(up->name);
|
|
@@ -332,7 +322,6 @@ PUBLIC int websSetUserPassword(cchar *username, cchar *password)
|
|
|
{
|
|
|
WebsUser *user;
|
|
|
|
|
|
- printf("---> websSetUserPassword, username: %s, password: %s\n", username, password);
|
|
|
assert(username);
|
|
|
if ((user = websLookupUser(username)) == 0) {
|
|
|
return -1;
|
|
@@ -347,7 +336,6 @@ PUBLIC int websSetUserRoles(cchar *username, cchar *roles)
|
|
|
{
|
|
|
WebsUser *user;
|
|
|
|
|
|
- printf("---> websSetUserRoles, username: %s, roles: %s\n", username, roles);
|
|
|
assert(username);
|
|
|
if ((user = websLookupUser(username)) == 0) {
|
|
|
return -1;
|
|
@@ -363,7 +351,6 @@ WebsUser *websLookupUser(cchar *username)
|
|
|
{
|
|
|
WebsKey *key;
|
|
|
|
|
|
- printf("---> websLookupUser, username: %s\n", username);
|
|
|
assert(username);
|
|
|
if ((key = hashLookup(users, username)) == 0) {
|
|
|
return 0;
|
|
@@ -511,10 +498,9 @@ PUBLIC bool websLoginUser(Webs *wp, cchar *username, cchar *password)
|
|
|
assert(wp->route);
|
|
|
assert(username);
|
|
|
assert(password);
|
|
|
+ logmsg(2, "%s-----------username auth0- ---------", username);
|
|
|
logmsg(2, "%s-----------password auth0- ---------", password);
|
|
|
logmsg(2, "%s-----------begin auth1 ---------", wp->route);
|
|
|
-
|
|
|
- printf("---> websLoginUser, username: %s, password: %s\n", username, password);
|
|
|
if (!wp->route || !wp->route->verify) {
|
|
|
return 0;
|
|
|
}
|
|
@@ -536,8 +522,6 @@ PUBLIC bool websLoginUser(Webs *wp, cchar *username, cchar *password)
|
|
|
/*update by lusa fix redirect to return json*/
|
|
|
PUBLIC bool websLogoutUser(Webs *wp)
|
|
|
{
|
|
|
-
|
|
|
- printf("---> websLoginUser\n");
|
|
|
assert(wp);
|
|
|
websRemoveSessionVar(wp, WEBS_SESSION_USERNAME);
|
|
|
websDestroySession(wp);
|
|
@@ -560,13 +544,17 @@ PUBLIC bool websLogoutUser(Webs *wp)
|
|
|
static void loginServiceProc(Webs *wp)
|
|
|
{
|
|
|
WebsRoute *route;
|
|
|
- logmsg(1, "--------------login come in --------在这里用------");
|
|
|
- HelloWord(wp); //test
|
|
|
+ char *username, *password;
|
|
|
+ username = websGetVar(wp, "username", NULL);
|
|
|
+ password = websGetVar(wp, "password", NULL);
|
|
|
+ logmsg(1, "--------------login come in --------------%s", username);
|
|
|
+ logmsg(1, "--------------login come in --------------%s", password);
|
|
|
+ // HelloWord(wp); //test
|
|
|
assert(wp);
|
|
|
route = wp->route;
|
|
|
assert(route);
|
|
|
|
|
|
- if (websLoginUser(wp, websGetVar(wp, "username", ""), websGetVar(wp, "password", ""))) {
|
|
|
+ if (websLoginUser(wp, username, password)) {
|
|
|
/* If the application defines a referrer session var, redirect to that */
|
|
|
//update start
|
|
|
/* cchar *referrer;
|
|
@@ -623,8 +611,9 @@ PUBLIC bool websVerifyPasswordFromFile(Webs *wp)
|
|
|
{
|
|
|
char passbuf[ME_GOAHEAD_LIMIT_PASSWORD * 3 + 3];
|
|
|
bool success;
|
|
|
-
|
|
|
- logmsg(2, "***************start to auth pwd***************")
|
|
|
+ char *username, *password;
|
|
|
+ username = websGetVar(wp, "username", NULL);
|
|
|
+ password = websGetVar(wp, "password", NULL);
|
|
|
assert(wp);
|
|
|
if (!wp->user && (wp->user = websLookupUser(wp->username)) == 0) {
|
|
|
trace(5, "verifyUser: Unknown user \"%s\"", wp->username);
|
|
@@ -634,11 +623,12 @@ PUBLIC bool websVerifyPasswordFromFile(Webs *wp)
|
|
|
Verify the password. If using Digest auth, we compare the digest of the password.
|
|
|
Otherwise we encode the plain-text password and compare that
|
|
|
*/
|
|
|
- // logmsg(2, "***************start to auth pwd111***************%s" , websMD5(passbuf))
|
|
|
+
|
|
|
if (!wp->encoded) {
|
|
|
fmt(passbuf, sizeof(passbuf), "%s:%s:%s", wp->username, ME_GOAHEAD_REALM, wp->password);
|
|
|
wfree(wp->password);
|
|
|
- logmsg(2, "***************start to auth pwd222***************%s" , websMD5(passbuf));
|
|
|
+ // logmsg(2, "***************start to auth pwd222***************%s" , websMD5(passbuf));
|
|
|
+
|
|
|
wp->password = websMD5(passbuf);
|
|
|
wp->encoded = 1;
|
|
|
}
|