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

Allow the app-auth announce www-authenticate: basic header. #11123

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
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
6 changes: 6 additions & 0 deletions changelog/unreleased/fix-app-auth.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
Bugfix: Fix app-auth

Allow the app-auth announce `www-authenticate: basic` header.

https://github.com/owncloud/ocis/pull/11123
https://github.com/owncloud/ocis/issues/11113
1 change: 1 addition & 0 deletions services/proxy/pkg/command/server.go
Original file line number Diff line number Diff line change
Expand Up @@ -353,6 +353,7 @@ func loadMiddlewares(logger log.Logger, cfg *config.Config,
middleware.Logger(logger),
middleware.OIDCIss(cfg.OIDC.Issuer),
middleware.EnableBasicAuth(cfg.EnableBasicAuth),
middleware.AllowAppAuth(cfg.AuthMiddleware.AllowAppAuth),
middleware.TraceProvider(traceProvider),
),
middleware.AccountResolver(
Expand Down
4 changes: 2 additions & 2 deletions services/proxy/pkg/middleware/authentication.go
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ func Authentication(auths []Authenticator, opts ...Option) func(next http.Handle
r = r.WithContext(ctx)

ri := router.ContextRoutingInfo(ctx)
if isOIDCTokenAuth(r) || ri.IsRouteUnprotected() || r.Method == "OPTIONS" {
if isOIDCTokenAuth(r) || ri.IsRouteUnprotected() || r.Method == http.MethodOptions {
// Either this is a request that does not need any authentication or
// the authentication for this request is handled by the IdP.
next.ServeHTTP(w, r)
Expand Down Expand Up @@ -146,7 +146,7 @@ func configureSupportedChallenges(options Options) {
SupportedAuthStrategies = append(SupportedAuthStrategies, "bearer")
}

if options.EnableBasicAuth {
if options.EnableBasicAuth || options.AllowAppAuth {
SupportedAuthStrategies = append(SupportedAuthStrategies, "basic")
}
}
Expand Down
9 changes: 9 additions & 0 deletions services/proxy/pkg/middleware/options.go
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,8 @@ type Options struct {
AutoprovisionAccounts bool
// EnableBasicAuth to allow basic auth
EnableBasicAuth bool
// AllowAppAuth specifies whether authentication using application tokens is permitted.
AllowAppAuth bool
// DefaultAccessTokenTTL is used to calculate the expiration when an access token has no expiration set
DefaultAccessTokenTTL time.Duration
// UserInfoCache sets the access token cache store
Expand Down Expand Up @@ -183,6 +185,13 @@ func EnableBasicAuth(enableBasicAuth bool) Option {
}
}

// AllowAppAuth provides a function to set the AllowAppAuth config
func AllowAppAuth(allowAppAuth bool) Option {
return func(o *Options) {
o.AllowAppAuth = allowAppAuth
}
}

// DefaultAccessTokenTTL provides a function to set the DefaultAccessTokenTTL
func DefaultAccessTokenTTL(ttl time.Duration) Option {
return func(o *Options) {
Expand Down