Skip to content

Conversation

@Jo-stfc
Copy link
Collaborator

@Jo-stfc Jo-stfc commented Apr 24, 2025

token to macaroon conversion for redirection

bbockelm and others added 20 commits September 3, 2024 16:37
Map various connection-related errors in XrdCl in XCache all the
way through to the HTTP layer.

This allows a failure to connect to the origin to be represented
with the correct status code ("Bad Gateway"); currently, a down
origin results in a 500 ("Internal Server Error") which is misleading
for users.
Seen on hppa Linux where EBADE is 160.

In function ‘int {anonymous}::initErrTable()’,
    inlined from ‘void __static_initialization_and_destruction_0()’ at /<<PKGBUILDDIR>>/src/XrdSys/XrdSysE2T.cc:92:28,
    inlined from ‘(static initializers for /<<PKGBUILDDIR>>/src/XrdSys/XrdSysE2T.cc)’ at /<<PKGBUILDDIR>>/src/XrdSys/XrdSysE2T.cc:128:1:
/<<PKGBUILDDIR>>/src/XrdSys/XrdSysE2T.cc:70:26: warning: array subscript 160 is above array bounds of ‘const char* [144]’ [-Warray-bounds=]
   70 |    if (Errno2String[EBADE]) {
      |        ~~~~~~~~~~~~~~~~~~^
/<<PKGBUILDDIR>>/src/XrdSys/XrdSysE2T.cc: In function ‘(static initializers for /<<PKGBUILDDIR>>/src/XrdSys/XrdSysE2T.cc)’:
/<<PKGBUILDDIR>>/src/XrdSys/XrdSysE2T.cc:48:28: note: while referencing ‘{anonymous}::Errno2String’
   48 |        const char*         Errno2String[errSlots] = {0};
      |                            ^~~~~~~~~~~~
In function ‘int {anonymous}::initErrTable()’,
    inlined from ‘void __static_initialization_and_destruction_0()’ at /<<PKGBUILDDIR>>/src/XrdSys/XrdSysE2T.cc:92:28,
    inlined from ‘(static initializers for /<<PKGBUILDDIR>>/src/XrdSys/XrdSysE2T.cc)’ at /<<PKGBUILDDIR>>/src/XrdSys/XrdSysE2T.cc:128:1:
/<<PKGBUILDDIR>>/src/XrdSys/XrdSysE2T.cc:74:22: warning: array subscript 160 is above array bounds of ‘const char* [144]’ [-Warray-bounds=]
   74 |    Errno2String[EBADE] = "authentication failed - possible invalid exchange";
      |    ~~~~~~~~~~~~~~~~~~^
/<<PKGBUILDDIR>>/src/XrdSys/XrdSysE2T.cc: In function ‘(static initializers for /<<PKGBUILDDIR>>/src/XrdSys/XrdSysE2T.cc)’:
/<<PKGBUILDDIR>>/src/XrdSys/XrdSysE2T.cc:48:28: note: while referencing ‘{anonymous}::Errno2String’
   48 |        const char*         Errno2String[errSlots] = {0};
      |                            ^~~~~~~~~~~~
The XrdSutCacheArg_t type is used to pass arguments of different
types. The type used must be wide enough to fit the widest of the
types passed. One of the types passed is time_t, which can be 64 bits
wide also on 32-bit systems. So a long, which is 32 bits wide on a
32-bit system is not sufficient.

This commit changes the type to long long.

Fixes: xrootd#2272
Without the patch, Mac OS X is missing the macros for the json-c
library.
When `http.redirtoken` is enabled, a valid SciToken in the URL as
an `authz` argument will be replaced with a sufficient Macaroon.

The redirected Macaroon will have a few-second lifetime and be specific
to the path being accessed.
Given the handler and the SciTokens plugin will want to invoke the
macaroon generation code, extract it out into a standalone class in
the XrdMacaroons directory.

The intent of this code is to keep the libmacaroons code inside the
XrdMacaroons directory.  The cmake changes to build this code will
eventually be replaced with a plugin interface.

A subsequent commit will switch XrdMacaroons library to utilize
this generator code.
This migrates the handler class to use the new XrdMacaroonsGenerator
class for its HTTP plugin.
This commit consolidates all the invocations of the Macaroons
configuration to a single implementation, ensuring that the logic
is only invoked once per process.
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.

5 participants