Skip to content
This repository has been archived by the owner on Jan 27, 2021. It is now read-only.

Change: Add OIDC config flags #66

Merged
merged 1 commit into from
Jul 10, 2020
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
11 changes: 11 additions & 0 deletions changelog/unreleased/add-oidc-config-flags.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
Change: Add OIDC config flags

To authenticate requests with an oidc provider we added two environment variables:
- `PROXY_OIDC_ISSUER="https://localhost:9200"` and
- `PROXY_OIDC_INSECURE=true`

This changes ocis-proxy to now load the oidc-middleware by default, requiring a bearer token and exchanging the email in the OIDC claims for an account id at the ocis-accounts service.

Setting `PROXY_OIDC_ISSUER=""` will disable the OIDC middleware.

https://github.com/owncloud/ocis-proxy/pull/66
4 changes: 2 additions & 2 deletions pkg/command/server.go
Original file line number Diff line number Diff line change
Expand Up @@ -245,7 +245,7 @@ func Server(cfg *config.Config) *cli.Command {
}

func loadMiddlewares(ctx context.Context, l log.Logger, cfg *config.Config) alice.Chain {
if cfg.OIDC != nil {
if cfg.OIDC.Issuer != "" {
l.Info().Msg("Loading OIDC-Middleware")
l.Debug().Interface("oidc_config", cfg.OIDC).Msg("OIDC-Config")

Expand All @@ -265,7 +265,7 @@ func loadMiddlewares(ctx context.Context, l log.Logger, cfg *config.Config) alic
// it will fetch the keys from the issuer using the .well-known
// endpoint
provider := func() (middleware.OIDCProvider, error) {
return oidc.NewProvider(customCtx, cfg.OIDC.Endpoint)
return oidc.NewProvider(customCtx, cfg.OIDC.Issuer)
}

oidcMW := middleware.OpenIDConnect(
Expand Down
4 changes: 2 additions & 2 deletions pkg/config/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@ type Config struct {
Tracing Tracing
Asset Asset
Policies []Policy
OIDC *OIDC
OIDC OIDC
TokenManager TokenManager
PolicySelector *PolicySelector `mapstructure:"policy_selector"`
Reva Reva
Expand All @@ -94,7 +94,7 @@ type Config struct {
// OIDC is the config for the OpenID-Connect middleware. If set the proxy will try to authenticate every request
// with the configured oidc-provider
type OIDC struct {
Endpoint string
Issuer string
Insecure bool
}

Expand Down
18 changes: 18 additions & 0 deletions pkg/flagset/flagset.go
Original file line number Diff line number Diff line change
Expand Up @@ -171,5 +171,23 @@ func ServerWithConfig(cfg *config.Config) []cli.Flag {
EnvVars: []string{"PROXY_REVA_GATEWAY_ADDR"},
Destination: &cfg.Reva.Address,
},

// OIDC

&cli.StringFlag{
Name: "oidc-issuer",
Value: "https://localhost:9200",
Usage: "OIDC issuer",
EnvVars: []string{"PROXY_OIDC_ISSUER"},
Destination: &cfg.OIDC.Issuer,
},
&cli.BoolFlag{
Name: "oidc-insecure",
Value: true,
Usage: "OIDC allow insecure communication",
EnvVars: []string{"PROXY_OIDC_INSECURE"},
Destination: &cfg.OIDC.Insecure,
},
}

}
2 changes: 1 addition & 1 deletion pkg/proxy/proxy_integration_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -216,7 +216,7 @@ func testConfig(policy []config.Policy) *config.Config {
Tracing: config.Tracing{},
Asset: config.Asset{},
Policies: policy,
OIDC: nil,
OIDC: config.OIDC{},
PolicySelector: nil,
}
}