Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

XrdMacaroons: Allow chaining user defined XrdAccAuthorize plugin #1147

Closed
wants to merge 1 commit into from

Conversation

esindril
Copy link
Contributor

@esindril esindril commented Mar 4, 2020

This extends the current behavior and keeps full backwards compatibility with the way XrdMacaroons was loading the (default) authorization plugin or was chaining the XrdAccSciTokens library. I've just added support for specifying a custom library which provides a XrdAccAuthorization plugin to be chained to XrdMacaroons (both to the http and authz plugins).

This is done by using as configuration parameter the key "chain_authz=libCustomAcc.so". We need this since EOS for example does not use at all the default XrdAcc plugin but provides its own authorization plugin. This will be useful also for other projects that want to rely on XrdMacaroons but have their own authorization plugin.
It would be great if this gets merged into 4.11.3.
@bbockelm, could you please review it?
Thanks!

…thorize plugin

and not only the default XrdAcc plugin. The library holding the user defined plugin
can be specified as a paramter to the XrdMacaroons using a special key "chain_authz=".
All previous behavior remains unchanged.
Eg.
http.exthandler xrdmacaroons libXrdMacaroons.so chain_authz=libCustomXrdAuthorize.so

The same mechanism holds when the Macaroons::Authz plugin is loaded, it can be chained
to any other XrdAccAuthorize plugin as follows:
ofs.authlib libXrdMacaroons.so chain_authz=libCustomXrdAuthorize.so
@abh3
Copy link
Member

abh3 commented Mar 5, 2020

We cannot let this go in Elvin. It completely conflicts with the way this is done in R5 and we can't have two different mechanisms competing in the same code base. I know you spent a lot oftme on this but it really completely undoes everything we did in R5 to solve this problem. In your particular case, either port the R5 back to 4.11 or please branch the code.

@abh3 abh3 closed this Mar 5, 2020
@esindril
Copy link
Contributor Author

esindril commented Mar 5, 2020

Hi Andy,

I had a look at R5, more specifically at this commit which adds support for stacking different OFS plugins:
a56e9b4#diff-22c42d4e97f2203a846bb636eac80e77

but I don't quite see how this applies in this case where I would like to control the authorization plugin which is loaded by an XrdHttpExtHandler plugin namely XrdMacaroons?

I looked at the XrdMacaroons code in R5 and it's no different to what is now in 4.11. I'm happy to adapt my approach if you can tell me how I can have the XrdMacaroons load a different authz plugin here:
https://github.com/xrootd/xrootd/blob/stable-5.0.x/src/XrdMacaroons/XrdMacaroons.cc#L98

Thanks!

@esindril esindril reopened this Mar 5, 2020
@abh3
Copy link
Member

abh3 commented Mar 5, 2020

Hi Elvin,

You are dealing with some pretty nasty code. I agree that the stacking mechanism in Macaroons is pretty ad hoc and we are trying to standardize how plugins are stacked. There seems to be precious little information on how macaroons fits into the whole authorization scheme. The idea of simply stacking the default authorization is bad and it's even worse by using the linking trick (I know you tried to correct that but the code got even more obscure). You are correct that there was no change to Macaroons but the whole stacking phenomena should follow the convention:

ofs.authlib ++

See: https://xrootd.slac.stanford.edu/doc/dev50/ofs_config.htm#_Toc8244755

It's not clear to me where the initial load goes and what is the directive being used to load this plugin. But how it manages stacking is pretty bad (as I said) and I don't want it to get even worse by plastering it over with patches.

The other issue is that we normally do back-ports not forward ports. The pull request should have been against git head not a stable release, especially when it's in a release cycle. It also puts us in the position of dropping it unless we port forwards.

So, what directive controls this Macaroons plugin? How does it relate to XrdAccAuthorize? It really seem pretty hacky the way it is now (which has nothing to do with your patches).

@bbockelm
Copy link
Contributor

bbockelm commented Mar 5, 2020

FWIW - a lot of the direct linking code is due to the fact there's not a public API (and all this code originated as an external plugin). That's an opportunity for code cleanup now that this plugin has access to the private Xrootd APIs.

From the ofs.authlib point-of-view, an example of how it's loaded now is:

ofs.authlib libXrdMacaroons.so libXrdAccSciTokens.so

So, authorizations are first examined by libXrdMacaroons; if the result is inconclusive, then it's passed to libXrdAccSciTokens; if that result is inconclusive, then it is passed to the default plugin.

@esindril - can you kindly remind me of the use case here? I recall talking about it but don't think I wrote it down. That is, if you have libXrdAccEOS, why doesn't the following work:

ofs.authlib libXrdMacaroons.so libXrdAccEOS.so

?

@xrootd-dev
Copy link

xrootd-dev commented Mar 5, 2020 via email

@bbockelm
Copy link
Contributor

bbockelm commented Mar 5, 2020

This sounds very promising!

(One aside on the manual text for this - I was very confused by this sentence in the manual:

++        The specified plug-in should stack on top of the existing plug-in or default. Once specified, it cannot be overridden by a subsequent directive,

I read this as saying "this can only be used once", which somewhat contradicts what you wrote above. A clarification in the manual would be appreciated.)

The second unpleasant piece in this code is the fact that, within the HTTP handler, we need to have access to the XrdAccAuthorize object used by the OFS to generate the appropriate permissions for the Macaroon.

Is there such a way to do that? This is currently accomplished by directly constructing the object and via a reimplementation of the ofs.authlib logic. There's not much gain if we significantly clean up this usage only to add more complexity elsewhere. What you point out only helps the case of making an authorization object for the ofs and not recreating it in the plugin.

Thanks!

@abh3
Copy link
Member

abh3 commented Mar 5, 2020 via email

@abh3
Copy link
Member

abh3 commented Mar 5, 2020 via email

@esindril
Copy link
Contributor Author

esindril commented Mar 5, 2020

@bbockelm Concerning your question:

@esindril - can you kindly remind me of the use case here? I recall talking about it but don't think > I wrote it down. That is, if you have libXrdAccEOS, why doesn't the following work:

ofs.authlib libXrdMacaroons.so libXrdAccEOS.so
?

I think you already provided the answer in you subsequent comment:

The second unpleasant piece in this code is the fact that, within the HTTP handler, we need to
have access to the XrdAccAuthorize object used by the OFS to generate the appropriate
permissions for the Macaroon.

Is there such a way to do that? This is currently accomplished by directly constructing the object > and via a reimplementation of the ofs.authlib logic. There's not much gain if we significantly clean > up this usage only to add more complexity elsewhere. What you point out only helps the case of > making an authorization object for the ofs and not recreating it in the plugin.

I actually have a similar patch for the XrdSciTokens library, but I'll for the the things to settle on a cleaner solution for all this chaining business.

@abh3

If so, I can plop a pointer to an authorization object in the XrdOucEnv
object passed to the protocol plugin. Then you'll have access to all the
methods using whatever the config was in the ofs. Will that be better for you?

I think this looks reasonable and it's already cascaded from the XrdHttpProtocol to any XrdHttpExtHandler object. Anyhow, this will only be available in R5, right?

@abh3
Copy link
Member

abh3 commented Mar 5, 2020

It's a fairly simple change. It could be easily back ported. We already have an issue with 4.11.3 that will likely mean another RC. Not clear that it would be appropriate sneaking this in there. I hate releasing 4.11.4 because every time we create a new 4x release it postpones the 5 release and we can't go on like this forever. So, how critical is this for you so that you don't want to wait for R5?

@bbockelm
Copy link
Contributor

bbockelm commented Mar 9, 2020

@abh3:

If so, I can plop a pointer to an authorization object in the XrdOucEnv object passed to the protocol plugin

I think this would work; at least, would be willing to test for v5.

I do eventually need both a pointer to the authorization object and for the filesystem object (for XrdHttpTPC, not Macaroons).

For v4 versus v5: I'm OK with showing this works with v5 and seeing how much nasty code this allows us to remove -- and then making a decision about a backport.

@bbockelm
Copy link
Contributor

@abh3 - any updates on this?

@abh3
Copy link
Member

abh3 commented Mar 19, 2020

Yes, the env passed around will have three additional keys:

XrdAccAuthorize* pointer to the authorization plugin
XrdOss* Pointer to the storage system plugin
XrdSfsFileSystem* pointer to the file system plugin

The patches are already in R5 and will be back ported to 4.11.3.

@bbockelm
Copy link
Contributor

@abh3 -- I think #1159 has a better approach for Xrootd 5 (and keeps the backward compat).

So the question is - what should we do for the 4.11 branch? @esindril - do you have any workarounds?

I would be OK with something somewhat hack-ish going in just to get EOS un-stuck, especially if we have something better going forward.

@abh3
Copy link
Member

abh3 commented Mar 20, 2020

Yes, I agree that 1159 is much cleaner. BTW you know that the pointer will be zero if authorization was not enabled. So, you may want to rethink how to handle that. I suppose I should have added yet another envar to tell you that. Is not configuring authorization something that is acceptable to the Macaroon support? As for a work around, I'm looking for suggestions. I guess you need the stacking framework to make it all workable, right?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

5 participants