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

Selectively enable client X509 authentication #1563

Merged
merged 3 commits into from
Aug 19, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions config/resources/osdf.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -26,3 +26,8 @@ Federation:
Registry:
RequireCacheApproval: true
RequireOriginApproval: true
Director:
X509ClientAuthenticationPrefixes:
- /xenon/PROTECTED/
- /user/ligo/
- /igwn/
7 changes: 7 additions & 0 deletions director/director.go
Original file line number Diff line number Diff line change
Expand Up @@ -798,6 +798,13 @@ func redirectToOrigin(ginCtx *gin.Context) {
ginCtx.Header("X-Pelican-Broker", brokerUrl.String())
}

for _, prefix := range param.Director_X509ClientAuthenticationPrefixes.GetStringSlice() {
if strings.HasPrefix(reqPath, prefix) {
ginCtx.Writer.Header().Add("X-Osdf-X509", "true")
break
}
}

// See note in RedirectToCache as to why we only add the authz query parameter to this URL,
// not those in the `Link`.
ginCtx.Redirect(http.StatusTemporaryRedirect, getFinalRedirectURL(redirectURL, reqParams))
Expand Down
2 changes: 1 addition & 1 deletion director/prom_query.go
Original file line number Diff line number Diff line change
Expand Up @@ -147,7 +147,7 @@ func parsePromRes(res promQLRes) (promParsed promQLParsed, err error) {
ResultType: data.ResultType,
}

if data.Result != nil && len(data.Result) > 0 {
if len(data.Result) > 0 {
switch data.Result[0].(type) {
case float64: // result: [unixtime, value]
if len(data.Result) == 2 && (data.ResultType == "scalar" || data.ResultType == "string") {
Expand Down
13 changes: 13 additions & 0 deletions docs/parameters.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -1402,6 +1402,19 @@ type: bool
default: false
components: ["director"]
---
name: Director.X509ClientAuthenticationPrefixes
description: |+
A list of object prefixes where the origin uses X.509 client authentication.

If a cache requests an object starting with one of these prefixes, then it will be instructed by the director
to use X.509 client authentication if available.

This setting allows for compatibility with specific legacy OSDF origins and is not needed for new origins.
type: stringSlice
default: none
components: ["director"]
hidden: true
---
############################
# Registry-level configs #
############################
Expand Down
2 changes: 1 addition & 1 deletion local_cache/local_cache.go
Original file line number Diff line number Diff line change
Expand Up @@ -803,7 +803,7 @@ func (cr *cacheReader) peekError(ctx context.Context) (err error) {
}

func (cr *cacheReader) Read(p []byte) (n int, err error) {
if cr.buf != nil && len(cr.buf) > 0 {
if len(cr.buf) > 0 {
bytesCopied := copy(p, cr.buf)
if len(cr.buf) > bytesCopied {
cr.buf = cr.buf[bytesCopied:]
Expand Down
1 change: 1 addition & 0 deletions param/parameters.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 2 additions & 0 deletions param/parameters_struct.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion registry/custom_reg_fields.go
Original file line number Diff line number Diff line change
Expand Up @@ -282,7 +282,7 @@ func InitCustomRegistrationFields() error {
return errors.New(fmt.Sprintf("Bad custom registration field, unsupported field type: %q with %q", conf.Name, conf.Type))
}
if conf.Type == "enum" {
if (conf.Options == nil || len(conf.Options) == 0) && conf.OptionsUrl == "" {
if len(conf.Options) == 0 && conf.OptionsUrl == "" {
return errors.New(fmt.Sprintf("Bad custom registration field, 'enum' type field does not have options or optionsUrl set: %q", conf.Name))
}
}
Expand Down
2 changes: 2 additions & 0 deletions xrootd/launch.go
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,8 @@ func makeUnprivilegedXrootdLauncher(daemonName string, configPath string, isCach
"XRD_PELICANBROKERSOCKET=" + filepath.Join(xrootdRun, "cache-reversal.sock"),
"XRD_PLUGINCONFDIR=" + filepath.Join(xrootdRun, "cache-client.plugins.d"),
"X509_CERT_FILE=" + filepath.Join(xrootdRun, "ca-bundle.crt"),
"XRD_PELICANCLIENTCERTFILE=" + filepath.Join(xrootdRun, "copied-tls-creds.crt"),
"XRD_PELICANCLIENTKEYFILE=" + filepath.Join(xrootdRun, "copied-tls-creds.crt"),
}
}
return
Expand Down
Loading