Commit 785b1c361cf71e02ac6a1af38b2e78e7564dd56f
1 parent
5fc9ce54
changed frontend to make it to use ldap login and simple session setup without username
Showing
4 changed files
with
33 additions
and
5 deletions
... | ... | @@ -24,6 +24,7 @@ |
24 | 24 | #include <stdio.h> |
25 | 25 | #include <stdlib.h> |
26 | 26 | #include <time.h> |
27 | +#include <string.h> | |
27 | 28 | #include <sys/time.h> |
28 | 29 | |
29 | 30 | #include "class.h" |
... | ... | @@ -116,7 +117,7 @@ httpWorkerProcess(HttpWorker this, Stream st) |
116 | 117 | * an empty 200 OK |
117 | 118 | */ |
118 | 119 | if (NULL == password || NULL == username) { |
119 | - response = new(HttpResponse, "HTTP/1.1", 200, "OK"); | |
120 | + response = new(HttpResponse, "HTTP/1.1", 403, "Forbidden"); | |
120 | 121 | } |
121 | 122 | |
122 | 123 | if (NULL == response) { |
... | ... | @@ -126,11 +127,22 @@ httpWorkerProcess(HttpWorker this, Stream st) |
126 | 127 | (char*)(password->value), password->nvalue); |
127 | 128 | |
128 | 129 | if (!authenticate(this->auth, cred)) { |
129 | - response = new(HttpResponse, "HTTP/1.1", 200, "OK"); | |
130 | + response = new(HttpResponse, "HTTP/1.1", 403, "Forbidden"); | |
130 | 131 | } else { |
131 | - this->session = sessionAdd( | |
132 | - this->sroot, | |
133 | - new(Session, username->value, username->nvalue)); | |
132 | + if (NULL == this->session) { | |
133 | + this->session = sessionAdd( | |
134 | + this->sroot, | |
135 | + new(Session, | |
136 | + username->value, | |
137 | + username->nvalue)); | |
138 | + } else { | |
139 | + this->session->username = malloc(username->nvalue + 1); | |
140 | + this->session->username[username->nvalue] = 0; | |
141 | + memcpy(this->session->username, | |
142 | + username->value, | |
143 | + username->nvalue); | |
144 | + } | |
145 | + | |
134 | 146 | nbuf = sprintf(buffer, |
135 | 147 | "sid=%lu;Path=/", |
136 | 148 | this->session->id); |
... | ... | @@ -161,6 +173,15 @@ httpWorkerProcess(HttpWorker this, Stream st) |
161 | 173 | response = (HttpMessage)httpResponseSession(this->session); |
162 | 174 | } |
163 | 175 | |
176 | + if (0 == strcmp("/sess/", request->path)) { | |
177 | + if (NULL == this->session) { | |
178 | + this->session = sessionAdd( | |
179 | + this->sroot, | |
180 | + new(Session, NULL, 0)); | |
181 | + } | |
182 | + response = (HttpMessage)httpResponseSession(this->session); | |
183 | + } | |
184 | + | |
164 | 185 | if (0 == strcmp("/randval/", request->path)) { |
165 | 186 | if (NULL != this->session) { |
166 | 187 | response = (HttpMessage)httpResponseRandval( | ... | ... |
Please
register
or
login
to post a comment