Skip to content

Commit

Permalink
Add config for machine driver to bearer auth
Browse files Browse the repository at this point in the history
  • Loading branch information
ishank011 committed Sep 22, 2021
1 parent c0d029d commit fd2bf9c
Show file tree
Hide file tree
Showing 3 changed files with 31 additions and 1 deletion.
5 changes: 4 additions & 1 deletion storage/pkg/command/authbearer.go
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,7 @@ func authBearerConfigFromStruct(c *cli.Context, cfg *config.Config) map[string]i
// TODO build services dynamically
"services": map[string]interface{}{
"authprovider": map[string]interface{}{
"auth_manager": "oidc",
"auth_manager": cfg.Reva.AuthBearerConfig.Driver,
"auth_managers": map[string]interface{}{
"oidc": map[string]interface{}{
"issuer": cfg.Reva.OIDC.Issuer,
Expand All @@ -111,6 +111,9 @@ func authBearerConfigFromStruct(c *cli.Context, cfg *config.Config) map[string]i
"gid_claim": cfg.Reva.OIDC.GIDClaim,
"gatewaysvc": cfg.Reva.Gateway.Endpoint,
},
"machine": map[string]interface{}{
"api_key": cfg.Reva.AuthBearerConfig.MachineAuthAPIKey,
},
},
},
},
Expand Down
8 changes: 8 additions & 0 deletions storage/pkg/config/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -119,6 +119,13 @@ type Users struct {
UserGroupsCacheExpiration int
}

// AuthBearerConfig defines the available configuration for the bearer auth drivers.
type AuthBearerConfig struct {
Port
Driver string
MachineAuthAPIKey string
}

// Groups defines the available groups configuration.
type Groups struct {
Port
Expand Down Expand Up @@ -423,6 +430,7 @@ type Reva struct {
Users Users
Groups Groups
AuthProvider Users
AuthBearerConfig AuthBearerConfig
AuthBasic Port
AuthBearer Port
Sharing Sharing
Expand Down
19 changes: 19 additions & 0 deletions storage/pkg/flagset/authbearer.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,15 @@ func AuthBearerWithConfig(cfg *config.Config) []cli.Flag {
Destination: &cfg.Reva.AuthBearer.DebugAddr,
},

// Driver
&cli.StringFlag{
Name: "auth-driver",
Value: flags.OverrideDefaultString(cfg.Reva.AuthBearerConfig.Driver, "oidc"),
Usage: "bearer auth driver: 'oidc' or 'machine'",
EnvVars: []string{"STORAGE_AUTH_BEARER_DRIVER"},
Destination: &cfg.Reva.AuthBearerConfig.Driver,
},

// OIDC

&cli.StringFlag{
Expand Down Expand Up @@ -63,6 +72,16 @@ func AuthBearerWithConfig(cfg *config.Config) []cli.Flag {
Destination: &cfg.Reva.OIDC.GIDClaim,
},

// Machine Auth

&cli.StringFlag{
Name: "machine-auth-api-key",
Value: flags.OverrideDefaultString(cfg.Reva.AuthBearerConfig.MachineAuthAPIKey, "change-me-please"),
Usage: "the API key to be used for the machine auth driver in reva",
EnvVars: []string{"STORAGE_AUTH_BEARER_MACHINE_AUTH_API_KEY", "OCIS_MACHINE_AUTH_API_KEY"},
Destination: &cfg.Reva.AuthBearerConfig.MachineAuthAPIKey,
},

// Services

// AuthBearer
Expand Down

0 comments on commit fd2bf9c

Please sign in to comment.