XRootD
Loading...
Searching...
No Matches
XrdMacaroons.cc File Reference
#include "XrdMacaroonsAuthz.hh"
#include "XrdMacaroonsHandler.hh"
#include "XrdOuc/XrdOucEnv.hh"
#include "XrdOuc/XrdOucString.hh"
#include "XrdOuc/XrdOucPinPath.hh"
#include "XrdSys/XrdSysError.hh"
#include "XrdSys/XrdSysLogger.hh"
#include "XrdHttp/XrdHttpExtHandler.hh"
#include "XrdAcc/XrdAccAuthorize.hh"
#include "XrdVersion.hh"
#include <stdexcept>
#include <dlfcn.h>
Include dependency graph for XrdMacaroons.cc:

Go to the source code of this file.

Functions

XrdEXPORT XrdAccAuthorize * XrdAccAuthorizeObjAdd (XrdSysLogger *log, const char *config, const char *params, XrdOucEnv *, XrdAccAuthorize *chain_authz)
XrdEXPORT XrdAccAuthorize * XrdAccAuthorizeObject (XrdSysLogger *log, const char *config, const char *parms)
XrdAccAuthorize * XrdAccDefaultAuthorizeObject (XrdSysLogger *lp, const char *cfn, const char *parm, XrdVersionInfo &myVer)
XrdEXPORT XrdHttpExtHandler * XrdHttpGetExtHandler (XrdSysError *log, const char *config, const char *parms, XrdOucEnv *env)
 XrdVERSIONINFO (XrdAccAuthorizeObjAdd, XrdMacaroons)
 XrdVERSIONINFO (XrdAccAuthorizeObject, XrdMacaroons)
 XrdVERSIONINFO (XrdHttpGetExtHandler, XrdMacaroons)
static XrdVERSIONINFODEF (compiledVer, XrdAccTest, XrdVNUMBER, XrdVERSION)

Variables

XrdEXPORT XrdSciTokensHelper * SciTokensHelper = nullptr

Function Documentation

◆ XrdAccAuthorizeObjAdd()

XrdEXPORT XrdAccAuthorize * XrdAccAuthorizeObjAdd ( XrdSysLogger * log,
const char * config,
const char * params,
XrdOucEnv * ,
XrdAccAuthorize * chain_authz )

Definition at line 34 of file XrdMacaroons.cc.

39{
40 try
41 {
42 auto new_authz = new Macaroons::Authz(log, config, chain_authz);
43 SciTokensHelper = new_authz;
44 return new_authz;
45 }
46 catch (std::runtime_error &e)
47 {
48 XrdSysError err(log, "macaroons");
49 err.Emsg("Config", "Configuration of Macaroon authorization handler failed", e.what());
50 return nullptr;
51 }
52}
XrdEXPORT XrdSciTokensHelper * SciTokensHelper

References XrdSysError::Emsg(), SciTokensHelper, and XrdAccAuthorizeObjAdd().

Referenced by XrdAccAuthorizeObjAdd(), XrdAccAuthorizeObjAdd(), XrdVERSIONINFO(), and XrdVERSIONINFO().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ XrdAccAuthorizeObject()

XrdEXPORT XrdAccAuthorize * XrdAccAuthorizeObject ( XrdSysLogger * log,
const char * config,
const char * parms )

Definition at line 55 of file XrdMacaroons.cc.

58{
59 XrdAccAuthorize *chain_authz = nullptr;
60 XrdSysError err(log, "macaroons");
61
62 if (parms && parms[0]) {
63 XrdOucString parms_str(parms);
64 XrdOucString chained_lib;
65 int from = parms_str.tokenize(chained_lib, 0, ' ');
66 const char *chained_parms = nullptr;
67 err.Emsg("Config", "Will chain library", chained_lib.c_str());
68 if (from > 0)
69 {
70 parms_str.erasefromstart(from);
71 if (parms_str.length())
72 {
73 err.Emsg("Config", "Will chain parameters", parms_str.c_str());
74 chained_parms = parms_str.c_str();
75 }
76 }
77 char resolvePath[2048];
78 bool usedAltPath{true};
79 if (!XrdOucPinPath(chained_lib.c_str(), usedAltPath, resolvePath, 2048)) {
80 err.Emsg("Config", "Failed to locate appropriately versioned chained auth library:", parms);
81 return nullptr;
82 }
83 void *handle_base = dlopen(resolvePath, RTLD_LOCAL|RTLD_NOW);
84 if (handle_base == nullptr) {
85 err.Emsg("Config", "Failed to base plugin ", resolvePath, dlerror());
86 return nullptr;
87 }
88
89 XrdAccAuthorize *(*ep)(XrdSysLogger *, const char *, const char *);
90 ep = (XrdAccAuthorize *(*)(XrdSysLogger *, const char *, const char *))
91 (dlsym(handle_base, "XrdAccAuthorizeObject"));
92 if (!ep)
93 {
94 dlclose(handle_base);
95 err.Emsg("Config", "Unable to chain second authlib after macaroons", parms);
96 return nullptr;
97 }
98
99 chain_authz = (*ep)(log, config, chained_parms);
100
101 if (chain_authz == nullptr) {
102 dlclose(handle_base);
103 err.Emsg("Config", "Unable to chain second authlib after macaroons "
104 "which returned nullptr");
105 return nullptr;
106 }
107 }
108 else
109 {
110 chain_authz = XrdAccDefaultAuthorizeObject(log, config, parms, compiledVer);
111 }
112 try
113 {
114 auto new_authz = new Macaroons::Authz(log, config, chain_authz);
115 SciTokensHelper = new_authz;
116 return new_authz;
117 }
118 catch (const std::runtime_error &e)
119 {
120 err.Emsg("Config", "Configuration of Macaroon authorization handler failed", e.what());
121 return nullptr;
122 }
123}
XrdAccAuthorize * XrdAccDefaultAuthorizeObject(XrdSysLogger *lp, const char *cfn, const char *parm, XrdVersionInfo &urVer)
int XrdOucPinPath(const char *piPath, bool &noAltP, char *buff, int blen)
int tokenize(XrdOucString &tok, int from, char del=':')
const char * c_str() const

References XrdOucString::c_str(), XrdSysError::Emsg(), XrdOucString::erasefromstart(), XrdOucString::length(), SciTokensHelper, XrdOucString::tokenize(), XrdAccAuthorizeObject(), XrdAccDefaultAuthorizeObject(), and XrdOucPinPath().

Referenced by XrdAccAuthorizeObject(), XrdAccAuthorizeObject(), XrdVERSIONINFO(), and XrdVERSIONINFO().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ XrdAccDefaultAuthorizeObject()

XrdAccAuthorize * XrdAccDefaultAuthorizeObject ( XrdSysLogger * lp,
const char * cfn,
const char * parm,
XrdVersionInfo & myVer )
extern

Definition at line 64 of file XrdAccAccess.cc.

68{
69 static XrdVERSIONINFODEF(myVer, XrdAcc, XrdVNUMBER, XrdVERSION);
70 static XrdSysError Eroute(lp, "acc_");
71
72// Verify version compatibility
73//
74 if (urVer.vNum != myVer.vNum && !XrdSysPlugin::VerCmp(urVer,myVer))
75 return 0;
76
77// Configure the authorization system
78//
79 if (XrdAccConfiguration.Configure(Eroute, cfn)) return (XrdAccAuthorize *)0;
80
81// Set error object pointer
82//
84
85// All is well, return the actual pointer to the object
86//
88}
XrdAccConfig XrdAccConfiguration
int Configure(XrdSysError &Eroute, const char *cfn)
XrdAccAccess * Authorization
static void setError(XrdSysError *errP)
static bool VerCmp(XrdVersionInfo &vInf1, XrdVersionInfo &vInf2, bool noMsg=false)
XrdVERSIONINFODEF(myVersion, cmsclient, XrdVNUMBER, XrdVERSION)

References XrdAccConfig::Authorization, XrdAccConfig::Configure(), XrdAccEntity::setError(), XrdSysPlugin::VerCmp(), XrdAccConfiguration, and XrdAccDefaultAuthorizeObject().

Referenced by main(), XrdAccAuthorizeObject(), XrdAccDefaultAuthorizeObject(), and XrdVERSIONINFODEF().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ XrdHttpGetExtHandler()

XrdEXPORT XrdHttpExtHandler * XrdHttpGetExtHandler ( XrdSysError * log,
const char * config,
const char * parms,
XrdOucEnv * env )

Definition at line 127 of file XrdMacaroons.cc.

130{
131 void *authz_raw = env->GetPtr("XrdAccAuthorize*");
132 XrdAccAuthorize *def_authz = static_cast<XrdAccAuthorize *>(authz_raw);
133
134 log->Emsg("Initialize", "Creating new Macaroon handler object");
135 try
136 {
137 return new Macaroons::Handler(log, config, env, def_authz);
138 }
139 catch (std::runtime_error &e)
140 {
141 log->Emsg("Config", "Generation of Macaroon handler failed", e.what());
142 return nullptr;
143 }
144}
void * GetPtr(const char *varname)
Definition XrdOucEnv.cc:263
int Emsg(const char *esfx, int ecode, const char *text1, const char *text2=0)

References XrdSysError::Emsg(), XrdOucEnv::GetPtr(), and XrdHttpGetExtHandler().

Here is the call graph for this function:

◆ XrdVERSIONINFO() [1/3]

XrdVERSIONINFO ( XrdAccAuthorizeObjAdd ,
XrdMacaroons  )

References XrdAccAuthorizeObjAdd(), and XrdVERSIONINFO().

Here is the call graph for this function:

◆ XrdVERSIONINFO() [2/3]

XrdVERSIONINFO ( XrdAccAuthorizeObject ,
XrdMacaroons  )

References XrdAccAuthorizeObject(), and XrdVERSIONINFO().

Here is the call graph for this function:

◆ XrdVERSIONINFO() [3/3]

XrdVERSIONINFO ( XrdHttpGetExtHandler ,
XrdMacaroons  )

References XrdHttpGetExtHandler(), and XrdVERSIONINFO().

Here is the call graph for this function:

◆ XrdVERSIONINFODEF()

XrdVERSIONINFODEF ( compiledVer ,
XrdAccTest ,
XrdVNUMBER ,
XrdVERSION  )
static

References XrdAccDefaultAuthorizeObject().

Here is the call graph for this function:

Variable Documentation

◆ SciTokensHelper

XrdEXPORT XrdSciTokensHelper* SciTokensHelper = nullptr

Definition at line 29 of file XrdMacaroons.cc.

Referenced by InitAccSciTokens(), XrdAccAuthorizeObjAdd(), and XrdAccAuthorizeObject().