diff options
-rw-r--r-- | Cargo.lock | 101 | ||||
-rw-r--r-- | Cargo.toml | 2 | ||||
-rw-r--r-- | shell.nix | 1 | ||||
-rw-r--r-- | src/bin/server.rs | 17 | ||||
-rw-r--r-- | src/handlers/rating.rs | 1 | ||||
-rw-r--r-- | src/handlers/users.rs | 4 |
6 files changed, 92 insertions, 34 deletions
@@ -11,7 +11,7 @@ dependencies = [ | |||
11 | "futures-core", | 11 | "futures-core", |
12 | "futures-sink", | 12 | "futures-sink", |
13 | "log", | 13 | "log", |
14 | "pin-project", | 14 | "pin-project 0.4.23", |
15 | "tokio", | 15 | "tokio", |
16 | "tokio-util", | 16 | "tokio-util", |
17 | ] | 17 | ] |
@@ -37,14 +37,16 @@ dependencies = [ | |||
37 | 37 | ||
38 | [[package]] | 38 | [[package]] |
39 | name = "actix-cors" | 39 | name = "actix-cors" |
40 | version = "0.4.0" | 40 | version = "0.5.3" |
41 | source = "registry+https://github.com/rust-lang/crates.io-index" | 41 | source = "registry+https://github.com/rust-lang/crates.io-index" |
42 | checksum = "d88ea83af46935098feec2e19a28c919b54eb3cbf0e239b330298e2e69d4b76b" | 42 | checksum = "3f3a3d5493dbc9b8769fe88c030d057ef8d2edc5728e5e26267780e8fc5db0be" |
43 | dependencies = [ | 43 | dependencies = [ |
44 | "actix-service", | ||
45 | "actix-web", | 44 | "actix-web", |
46 | "derive_more", | 45 | "derive_more", |
47 | "futures-util", | 46 | "futures-util", |
47 | "log", | ||
48 | "once_cell", | ||
49 | "tinyvec 1.1.0", | ||
48 | ] | 50 | ] |
49 | 51 | ||
50 | [[package]] | 52 | [[package]] |
@@ -83,7 +85,7 @@ dependencies = [ | |||
83 | "log", | 85 | "log", |
84 | "mime", | 86 | "mime", |
85 | "percent-encoding 2.1.0", | 87 | "percent-encoding 2.1.0", |
86 | "pin-project", | 88 | "pin-project 0.4.23", |
87 | "rand", | 89 | "rand", |
88 | "regex", | 90 | "regex", |
89 | "serde", | 91 | "serde", |
@@ -173,7 +175,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" | |||
173 | checksum = "0052435d581b5be835d11f4eb3bce417c8af18d87ddf8ace99f8e67e595882bb" | 175 | checksum = "0052435d581b5be835d11f4eb3bce417c8af18d87ddf8ace99f8e67e595882bb" |
174 | dependencies = [ | 176 | dependencies = [ |
175 | "futures-util", | 177 | "futures-util", |
176 | "pin-project", | 178 | "pin-project 0.4.23", |
177 | ] | 179 | ] |
178 | 180 | ||
179 | [[package]] | 181 | [[package]] |
@@ -233,7 +235,7 @@ dependencies = [ | |||
233 | "futures-sink", | 235 | "futures-sink", |
234 | "futures-util", | 236 | "futures-util", |
235 | "log", | 237 | "log", |
236 | "pin-project", | 238 | "pin-project 0.4.23", |
237 | "slab", | 239 | "slab", |
238 | ] | 240 | ] |
239 | 241 | ||
@@ -265,14 +267,14 @@ dependencies = [ | |||
265 | "fxhash", | 267 | "fxhash", |
266 | "log", | 268 | "log", |
267 | "mime", | 269 | "mime", |
268 | "pin-project", | 270 | "pin-project 0.4.23", |
269 | "regex", | 271 | "regex", |
270 | "serde", | 272 | "serde", |
271 | "serde_json", | 273 | "serde_json", |
272 | "serde_urlencoded", | 274 | "serde_urlencoded", |
273 | "socket2", | 275 | "socket2", |
274 | "time 0.2.21", | 276 | "time 0.2.21", |
275 | "tinyvec", | 277 | "tinyvec 0.3.4", |
276 | "url 2.1.1", | 278 | "url 2.1.1", |
277 | ] | 279 | ] |
278 | 280 | ||
@@ -832,9 +834,9 @@ dependencies = [ | |||
832 | 834 | ||
833 | [[package]] | 835 | [[package]] |
834 | name = "futures-channel" | 836 | name = "futures-channel" |
835 | version = "0.3.5" | 837 | version = "0.3.8" |
836 | source = "registry+https://github.com/rust-lang/crates.io-index" | 838 | source = "registry+https://github.com/rust-lang/crates.io-index" |
837 | checksum = "f366ad74c28cca6ba456d95e6422883cfb4b252a83bed929c83abfdbbf2967d5" | 839 | checksum = "4b7109687aa4e177ef6fe84553af6280ef2778bdb7783ba44c9dc3399110fe64" |
838 | dependencies = [ | 840 | dependencies = [ |
839 | "futures-core", | 841 | "futures-core", |
840 | "futures-sink", | 842 | "futures-sink", |
@@ -842,21 +844,21 @@ dependencies = [ | |||
842 | 844 | ||
843 | [[package]] | 845 | [[package]] |
844 | name = "futures-core" | 846 | name = "futures-core" |
845 | version = "0.3.5" | 847 | version = "0.3.8" |
846 | source = "registry+https://github.com/rust-lang/crates.io-index" | 848 | source = "registry+https://github.com/rust-lang/crates.io-index" |
847 | checksum = "59f5fff90fd5d971f936ad674802482ba441b6f09ba5e15fd8b39145582ca399" | 849 | checksum = "847ce131b72ffb13b6109a221da9ad97a64cbe48feb1028356b836b47b8f1748" |
848 | 850 | ||
849 | [[package]] | 851 | [[package]] |
850 | name = "futures-io" | 852 | name = "futures-io" |
851 | version = "0.3.5" | 853 | version = "0.3.8" |
852 | source = "registry+https://github.com/rust-lang/crates.io-index" | 854 | source = "registry+https://github.com/rust-lang/crates.io-index" |
853 | checksum = "de27142b013a8e869c14957e6d2edeef89e97c289e69d042ee3a49acd8b51789" | 855 | checksum = "611834ce18aaa1bd13c4b374f5d653e1027cf99b6b502584ff8c9a64413b30bb" |
854 | 856 | ||
855 | [[package]] | 857 | [[package]] |
856 | name = "futures-macro" | 858 | name = "futures-macro" |
857 | version = "0.3.5" | 859 | version = "0.3.8" |
858 | source = "registry+https://github.com/rust-lang/crates.io-index" | 860 | source = "registry+https://github.com/rust-lang/crates.io-index" |
859 | checksum = "d0b5a30a4328ab5473878237c447333c093297bded83a4983d10f4deea240d39" | 861 | checksum = "77408a692f1f97bcc61dc001d752e00643408fbc922e4d634c655df50d595556" |
860 | dependencies = [ | 862 | dependencies = [ |
861 | "proc-macro-hack", | 863 | "proc-macro-hack", |
862 | "proc-macro2", | 864 | "proc-macro2", |
@@ -866,24 +868,24 @@ dependencies = [ | |||
866 | 868 | ||
867 | [[package]] | 869 | [[package]] |
868 | name = "futures-sink" | 870 | name = "futures-sink" |
869 | version = "0.3.5" | 871 | version = "0.3.8" |
870 | source = "registry+https://github.com/rust-lang/crates.io-index" | 872 | source = "registry+https://github.com/rust-lang/crates.io-index" |
871 | checksum = "3f2032893cb734c7a05d85ce0cc8b8c4075278e93b24b66f9de99d6eb0fa8acc" | 873 | checksum = "f878195a49cee50e006b02b93cf7e0a95a38ac7b776b4c4d9cc1207cd20fcb3d" |
872 | 874 | ||
873 | [[package]] | 875 | [[package]] |
874 | name = "futures-task" | 876 | name = "futures-task" |
875 | version = "0.3.5" | 877 | version = "0.3.8" |
876 | source = "registry+https://github.com/rust-lang/crates.io-index" | 878 | source = "registry+https://github.com/rust-lang/crates.io-index" |
877 | checksum = "bdb66b5f09e22019b1ab0830f7785bcea8e7a42148683f99214f73f8ec21a626" | 879 | checksum = "7c554eb5bf48b2426c4771ab68c6b14468b6e76cc90996f528c3338d761a4d0d" |
878 | dependencies = [ | 880 | dependencies = [ |
879 | "once_cell", | 881 | "once_cell", |
880 | ] | 882 | ] |
881 | 883 | ||
882 | [[package]] | 884 | [[package]] |
883 | name = "futures-util" | 885 | name = "futures-util" |
884 | version = "0.3.5" | 886 | version = "0.3.8" |
885 | source = "registry+https://github.com/rust-lang/crates.io-index" | 887 | source = "registry+https://github.com/rust-lang/crates.io-index" |
886 | checksum = "8764574ff08b701a084482c3c7031349104b07ac897393010494beaa18ce32c6" | 888 | checksum = "d304cff4a7b99cfb7986f7d43fbe93d175e72e704a8860787cc95e9ffd85cbd2" |
887 | dependencies = [ | 889 | dependencies = [ |
888 | "futures-channel", | 890 | "futures-channel", |
889 | "futures-core", | 891 | "futures-core", |
@@ -892,7 +894,7 @@ dependencies = [ | |||
892 | "futures-sink", | 894 | "futures-sink", |
893 | "futures-task", | 895 | "futures-task", |
894 | "memchr", | 896 | "memchr", |
895 | "pin-project", | 897 | "pin-project 1.0.2", |
896 | "pin-utils", | 898 | "pin-utils", |
897 | "proc-macro-hack", | 899 | "proc-macro-hack", |
898 | "proc-macro-nested", | 900 | "proc-macro-nested", |
@@ -1378,7 +1380,16 @@ version = "0.4.23" | |||
1378 | source = "registry+https://github.com/rust-lang/crates.io-index" | 1380 | source = "registry+https://github.com/rust-lang/crates.io-index" |
1379 | checksum = "ca4433fff2ae79342e497d9f8ee990d174071408f28f726d6d83af93e58e48aa" | 1381 | checksum = "ca4433fff2ae79342e497d9f8ee990d174071408f28f726d6d83af93e58e48aa" |
1380 | dependencies = [ | 1382 | dependencies = [ |
1381 | "pin-project-internal", | 1383 | "pin-project-internal 0.4.23", |
1384 | ] | ||
1385 | |||
1386 | [[package]] | ||
1387 | name = "pin-project" | ||
1388 | version = "1.0.2" | ||
1389 | source = "registry+https://github.com/rust-lang/crates.io-index" | ||
1390 | checksum = "9ccc2237c2c489783abd8c4c80e5450fc0e98644555b1364da68cc29aa151ca7" | ||
1391 | dependencies = [ | ||
1392 | "pin-project-internal 1.0.2", | ||
1382 | ] | 1393 | ] |
1383 | 1394 | ||
1384 | [[package]] | 1395 | [[package]] |
@@ -1393,6 +1404,17 @@ dependencies = [ | |||
1393 | ] | 1404 | ] |
1394 | 1405 | ||
1395 | [[package]] | 1406 | [[package]] |
1407 | name = "pin-project-internal" | ||
1408 | version = "1.0.2" | ||
1409 | source = "registry+https://github.com/rust-lang/crates.io-index" | ||
1410 | checksum = "f8e8d2bf0b23038a4424865103a4df472855692821aab4e4f5c3312d461d9e5f" | ||
1411 | dependencies = [ | ||
1412 | "proc-macro2", | ||
1413 | "quote", | ||
1414 | "syn", | ||
1415 | ] | ||
1416 | |||
1417 | [[package]] | ||
1396 | name = "pin-project-lite" | 1418 | name = "pin-project-lite" |
1397 | version = "0.1.7" | 1419 | version = "0.1.7" |
1398 | source = "registry+https://github.com/rust-lang/crates.io-index" | 1420 | source = "registry+https://github.com/rust-lang/crates.io-index" |
@@ -1438,9 +1460,9 @@ dependencies = [ | |||
1438 | 1460 | ||
1439 | [[package]] | 1461 | [[package]] |
1440 | name = "proc-macro-hack" | 1462 | name = "proc-macro-hack" |
1441 | version = "0.5.18" | 1463 | version = "0.5.19" |
1442 | source = "registry+https://github.com/rust-lang/crates.io-index" | 1464 | source = "registry+https://github.com/rust-lang/crates.io-index" |
1443 | checksum = "99c605b9a0adc77b7211c6b1f722dcb613d68d66859a44f3d485a6da332b0598" | 1465 | checksum = "dbf0c48bc1d91375ae5c3cd81e3722dff1abcf81a30960240640d223f59fe0e5" |
1444 | 1466 | ||
1445 | [[package]] | 1467 | [[package]] |
1446 | name = "proc-macro-nested" | 1468 | name = "proc-macro-nested" |
@@ -1450,9 +1472,9 @@ checksum = "eba180dafb9038b050a4c280019bbedf9f2467b61e5d892dcad585bb57aadc5a" | |||
1450 | 1472 | ||
1451 | [[package]] | 1473 | [[package]] |
1452 | name = "proc-macro2" | 1474 | name = "proc-macro2" |
1453 | version = "1.0.21" | 1475 | version = "1.0.24" |
1454 | source = "registry+https://github.com/rust-lang/crates.io-index" | 1476 | source = "registry+https://github.com/rust-lang/crates.io-index" |
1455 | checksum = "36e28516df94f3dd551a587da5357459d9b36d945a7c37c3557928c1c2ff2a2c" | 1477 | checksum = "1e0704ee1a7e00d7bb417d0770ea303c1bccbabf0ef1667dae92b5967f5f8a71" |
1456 | dependencies = [ | 1478 | dependencies = [ |
1457 | "unicode-xid", | 1479 | "unicode-xid", |
1458 | ] | 1480 | ] |
@@ -1784,9 +1806,9 @@ checksum = "343f3f510c2915908f155e94f17220b19ccfacf2a64a2a5d8004f2c3e311e7fd" | |||
1784 | 1806 | ||
1785 | [[package]] | 1807 | [[package]] |
1786 | name = "syn" | 1808 | name = "syn" |
1787 | version = "1.0.41" | 1809 | version = "1.0.54" |
1788 | source = "registry+https://github.com/rust-lang/crates.io-index" | 1810 | source = "registry+https://github.com/rust-lang/crates.io-index" |
1789 | checksum = "6690e3e9f692504b941dc6c3b188fd28df054f7fb8469ab40680df52fdcc842b" | 1811 | checksum = "9a2af957a63d6bd42255c359c93d9bfdb97076bd3b820897ce55ffbfbf107f44" |
1790 | dependencies = [ | 1812 | dependencies = [ |
1791 | "proc-macro2", | 1813 | "proc-macro2", |
1792 | "quote", | 1814 | "quote", |
@@ -1896,6 +1918,21 @@ source = "registry+https://github.com/rust-lang/crates.io-index" | |||
1896 | checksum = "238ce071d267c5710f9d31451efec16c5ee22de34df17cc05e56cbc92e967117" | 1918 | checksum = "238ce071d267c5710f9d31451efec16c5ee22de34df17cc05e56cbc92e967117" |
1897 | 1919 | ||
1898 | [[package]] | 1920 | [[package]] |
1921 | name = "tinyvec" | ||
1922 | version = "1.1.0" | ||
1923 | source = "registry+https://github.com/rust-lang/crates.io-index" | ||
1924 | checksum = "ccf8dbc19eb42fba10e8feaaec282fb50e2c14b2726d6301dbfeed0f73306a6f" | ||
1925 | dependencies = [ | ||
1926 | "tinyvec_macros", | ||
1927 | ] | ||
1928 | |||
1929 | [[package]] | ||
1930 | name = "tinyvec_macros" | ||
1931 | version = "0.1.0" | ||
1932 | source = "registry+https://github.com/rust-lang/crates.io-index" | ||
1933 | checksum = "cda74da7e1a664f795bb1f8a87ec406fb89a02522cf6e50620d016add6dbbf5c" | ||
1934 | |||
1935 | [[package]] | ||
1899 | name = "tokio" | 1936 | name = "tokio" |
1900 | version = "0.2.22" | 1937 | version = "0.2.22" |
1901 | source = "registry+https://github.com/rust-lang/crates.io-index" | 1938 | source = "registry+https://github.com/rust-lang/crates.io-index" |
@@ -2010,7 +2047,7 @@ version = "0.1.13" | |||
2010 | source = "registry+https://github.com/rust-lang/crates.io-index" | 2047 | source = "registry+https://github.com/rust-lang/crates.io-index" |
2011 | checksum = "6fb19cf769fa8c6a80a162df694621ebeb4dafb606470b2b2fce0be40a98a977" | 2048 | checksum = "6fb19cf769fa8c6a80a162df694621ebeb4dafb606470b2b2fce0be40a98a977" |
2012 | dependencies = [ | 2049 | dependencies = [ |
2013 | "tinyvec", | 2050 | "tinyvec 0.3.4", |
2014 | ] | 2051 | ] |
2015 | 2052 | ||
2016 | [[package]] | 2053 | [[package]] |
@@ -15,7 +15,7 @@ serde_json = "1.0" | |||
15 | log = "0.4" | 15 | log = "0.4" |
16 | pretty_env_logger = "0.4" | 16 | pretty_env_logger = "0.4" |
17 | actix-identity = "0.3.1" | 17 | actix-identity = "0.3.1" |
18 | actix-cors = "0.4.0" | 18 | actix-cors = "0.5" |
19 | bigdecimal = "0.0.14" | 19 | bigdecimal = "0.0.14" |
20 | rand = "0.7" | 20 | rand = "0.7" |
21 | 21 | ||
@@ -29,5 +29,6 @@ in | |||
29 | libmysqlclient | 29 | libmysqlclient |
30 | jq | 30 | jq |
31 | python3 | 31 | python3 |
32 | insomnia | ||
32 | ]; | 33 | ]; |
33 | } | 34 | } |
diff --git a/src/bin/server.rs b/src/bin/server.rs index 5af3135..7c67e4f 100644 --- a/src/bin/server.rs +++ b/src/bin/server.rs | |||
@@ -24,9 +24,24 @@ async fn main() -> std::io::Result<()> { | |||
24 | .wrap(IdentityService::new( | 24 | .wrap(IdentityService::new( |
25 | CookieIdentityPolicy::new(&private_key) | 25 | CookieIdentityPolicy::new(&private_key) |
26 | .name("user-login") | 26 | .name("user-login") |
27 | .domain("127.0.0.1") | ||
28 | .path("/") | ||
29 | .same_site(actix_web::cookie::SameSite::None) | ||
30 | .http_only(true) | ||
27 | .secure(false), | 31 | .secure(false), |
28 | )) | 32 | )) |
29 | .wrap(Cors::new().supports_credentials().finish()) | 33 | .wrap( |
34 | Cors::default() | ||
35 | .allowed_origin("http://127.0.0.1:8000") | ||
36 | .allowed_origin("http://localhost:8000") | ||
37 | .allow_any_method() | ||
38 | .allow_any_header(), | ||
39 | ) | ||
40 | .wrap( | ||
41 | middleware::DefaultHeaders::new() | ||
42 | .header("Access-Control-Allow-Credentials", "true") | ||
43 | .header("Access-Control-Expose-Headers", "set-cookie"), | ||
44 | ) | ||
30 | .wrap(middleware::Logger::default()) | 45 | .wrap(middleware::Logger::default()) |
31 | .data(pool.clone()) | 46 | .data(pool.clone()) |
32 | .service( | 47 | .service( |
diff --git a/src/handlers/rating.rs b/src/handlers/rating.rs index 309c2c6..dfbeb3e 100644 --- a/src/handlers/rating.rs +++ b/src/handlers/rating.rs | |||
@@ -22,6 +22,7 @@ pub async fn add_rating( | |||
22 | pool: web::Data<TPool>, | 22 | pool: web::Data<TPool>, |
23 | ) -> impl Responder { | 23 | ) -> impl Responder { |
24 | info!("Add rating hit: {:?}", rating_details.product_id); | 24 | info!("Add rating hit: {:?}", rating_details.product_id); |
25 | info!("{:?}", cookie.identity()); | ||
25 | let conn = pool.get().unwrap(); | 26 | let conn = pool.get().unwrap(); |
26 | if let Some(uname) = cookie.identity() { | 27 | if let Some(uname) = cookie.identity() { |
27 | let selected_user = customer | 28 | let selected_user = customer |
diff --git a/src/handlers/users.rs b/src/handlers/users.rs index bff532c..73fca84 100644 --- a/src/handlers/users.rs +++ b/src/handlers/users.rs | |||
@@ -57,6 +57,10 @@ pub async fn login( | |||
57 | login_details: web::Json<Login>, | 57 | login_details: web::Json<Login>, |
58 | ) -> impl Responder { | 58 | ) -> impl Responder { |
59 | info!("Login hit"); | 59 | info!("Login hit"); |
60 | if let Some(uname) = cookie.identity() { | ||
61 | info!("Found existing cookie: {:?}", cookie.identity()); | ||
62 | return HttpResponse::Ok().finish(); | ||
63 | } | ||
60 | let conn = pool.get().unwrap(); | 64 | let conn = pool.get().unwrap(); |
61 | let entered_pass = &login_details.password; | 65 | let entered_pass = &login_details.password; |
62 | let selected_user = customer | 66 | let selected_user = customer |