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 22namespace Ubiquity \security \csrf ;
33
44use Ubiquity \utils \http \UCookie ;
5+ use Ubiquity \controllers \Startup ;
56
67/**
78 * Ubiquity\security\csrf$UCsrfHttp
@@ -45,6 +46,19 @@ public static function isValidCookie(string $name): bool {
4546 }
4647 return false ;
4748 }
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+ }
4862
4963 /**
5064 * Adds a token in headers.
You can’t perform that action at this time.
0 commit comments