Subversion Repositories RepoView

Rev

Rev 62 | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 62 Rev 64
Line 1... Line 1...
1
/* $Id: cookie.c 62 2024-08-22 07:35:24Z nishi $ */
1
/* $Id: cookie.c 64 2024-08-23 10:53:59Z nishi $ */
2
 
2
 
3
#include "rv_auth.h"
3
#include "rv_auth.h"
4
 
4
 
5
#include "rv_util.h"
5
#include "rv_util.h"
6
#include "rv_db.h"
6
#include "rv_db.h"
Line 73... Line 73...
73
	int i;
73
	int i;
74
	for(i = 0; cookie_entries[i] != NULL; i++) {
74
	for(i = 0; cookie_entries[i] != NULL; i++) {
75
		if(strcmp(cookie_entries[i]->key, "token") == 0) {
75
		if(strcmp(cookie_entries[i]->key, "token") == 0) {
76
			char* who = rv_who_has_token(cookie_entries[i]->value);
76
			char* who = rv_who_has_token(cookie_entries[i]->value);
77
			if(who == NULL) {
77
			if(who == NULL) {
78
				printf("Set-Cookie: token=; HttpOnly; Expires=0; SameStie=Lax\r\n");
78
				printf("Set-Cookie: token=; HttpOnly; Expires=0; SameSite=Lax\r\n");
79
			}
79
			}
80
			return who;
80
			return who;
81
			break;
81
			break;
82
		}
82
		}
83
	}
83
	}
Line 86... Line 86...
86
 
86
 
87
void rv_logout(void) {
87
void rv_logout(void) {
88
	int i;
88
	int i;
89
	for(i = 0; cookie_entries[i] != NULL; i++) {
89
	for(i = 0; cookie_entries[i] != NULL; i++) {
90
		if(strcmp(cookie_entries[i]->key, "token") == 0) {
90
		if(strcmp(cookie_entries[i]->key, "token") == 0) {
91
			printf("Set-Cookie: token=; HttpOnly; Expires=0; SameStie=Lax\r\n");
91
			printf("Set-Cookie: token=; HttpOnly; Expires=0; SameSite=Lax\r\n");
92
			rv_remove_token(cookie_entries[i]->value);
92
			rv_remove_token(cookie_entries[i]->value);
93
			break;
93
			break;
94
		}
94
		}
95
	}
95
	}
96
}
96
}
97
 
97
 
98
void rv_save_login(const char* username) {
98
void rv_save_login(const char* username) {
99
	char* token = rv_new_token(username);
99
	char* token = rv_new_token(username);
100
	printf("Set-Cookie: token=%s; HttpOnly; SameStie=Lax\r\n", token);
100
	printf("Set-Cookie: token=%s; HttpOnly; SameSite=Lax\r\n", token);
101
	free(token);
101
	free(token);
102
}
102
}
103
 
103
 
104
void rv_init_auth(void) { parse_cookie(); }
104
void rv_init_auth(void) { parse_cookie(); }
105
 
105