XRootD
Loading...
Searching...
No Matches
SubpathMatch Class Referencefinal

#include <XrdSciTokensAccess.hh>

+ Collaboration diagram for SubpathMatch:

Public Member Functions

 SubpathMatch ()=default
 
 SubpathMatch (const AccessRulesRaw &rules)
 
bool apply (Access_Operation oper, const std::string_view path) const
 
bool empty () const
 
size_t size () const
 
std::string str () const
 

Detailed Description

Definition at line 89 of file XrdSciTokensAccess.hh.

Constructor & Destructor Documentation

◆ SubpathMatch() [1/2]

SubpathMatch::SubpathMatch ( )
default

◆ SubpathMatch() [2/2]

SubpathMatch::SubpathMatch ( const AccessRulesRaw & rules)
inline

Definition at line 92 of file XrdSciTokensAccess.hh.

93 : m_rules(rules)
94 {}

Member Function Documentation

◆ apply()

bool SubpathMatch::apply ( Access_Operation oper,
const std::string_view path ) const
inline

Definition at line 97 of file XrdSciTokensAccess.hh.

97 {
98
99 for (const auto & rule : m_rules) {
100 // Skip rules that don't match the current operation
101 if (rule.first != oper)
102 continue;
103
104 // If the rule allows any path, allow the operation
105 if (rule.second == "/")
106 return true;
107
108 // Allow operation if path is a subdirectory of the rule's path
109 if (is_subdirectory(rule.second, path)) {
110 return true;
111 } else {
112 // Allow stat and mkdir of parent directories to comply with WLCG token specs
113 if (oper == AOP_Stat || oper == AOP_Mkdir)
114 if (is_subdirectory(path, rule.second))
115 return true;
116 }
117 }
118 return false;
119 }
@ AOP_Mkdir
mkdir()
@ AOP_Stat
exists(), stat()
static bool is_subdirectory(const std::string_view dir, const std::string_view subdir)

References AOP_Mkdir, AOP_Stat, and is_subdirectory().

+ Here is the call graph for this function:

◆ empty()

bool SubpathMatch::empty ( ) const
inline

Definition at line 121 of file XrdSciTokensAccess.hh.

121{return m_rules.empty();} // Returns true if there are no rules to match

◆ size()

size_t SubpathMatch::size ( ) const
inline

Definition at line 125 of file XrdSciTokensAccess.hh.

125{return m_rules.size();} // Returns the count of rules

◆ str()

std::string SubpathMatch::str ( ) const

Definition at line 326 of file XrdSciTokensAccess.cc.

326 {
327 return AccessRuleStr(m_rules); // Returns a human-friendly representation of the access rules
328}

The documentation for this class was generated from the following files: