File tree Expand file tree Collapse file tree 1 file changed +14
-0
lines changed
src/Ubiquity/security/csrf Expand file tree Collapse file tree 1 file changed +14
-0
lines changed Original file line number Diff line number Diff line change 2
2
namespace Ubiquity \security \csrf ;
3
3
4
4
use Ubiquity \utils \http \UCookie ;
5
+ use Ubiquity \controllers \Startup ;
5
6
6
7
/**
7
8
* Ubiquity\security\csrf$UCsrfHttp
@@ -45,6 +46,19 @@ public static function isValidCookie(string $name): bool {
45
46
}
46
47
return false ;
47
48
}
49
+
50
+ /**
51
+ * Returns whether the given CSRF token is present and valid in header meta csrf-token, given his name.
52
+ * @param string $name
53
+ * @return bool
54
+ */
55
+ public static function isValidMeta (string $ name ):bool {
56
+ $ headers =Startup::getHttpInstance ()->getAllHeaders ();
57
+ if (isset ($ headers ['csrf-token ' ])){
58
+ list ($ id ,$ value )=explode (': ' , $ headers ['csrf-token ' ]);
59
+ return $ id ===CsrfManager::getSelector ($ name ) && CsrfManager::isValidByName ($ name , $ value );
60
+ }
61
+ }
48
62
49
63
/**
50
64
* Adds a token in headers.
You can’t perform that action at this time.
0 commit comments