Skip to content

Commit

Permalink
Add options for redis to rest user pkg
Browse files Browse the repository at this point in the history
  • Loading branch information
ishank011 committed Jul 24, 2020
1 parent c58061b commit 3ef1849
Show file tree
Hide file tree
Showing 9 changed files with 57 additions and 22 deletions.
8 changes: 8 additions & 0 deletions docs/content/en/docs/config/packages/storage/fs/eos/_index.md
Original file line number Diff line number Diff line change
Expand Up @@ -136,3 +136,11 @@ use_keytab = false
{{< /highlight >}}
{{% /dir %}}

{{% dir name="gatewaysvc" type="string" default="0.0.0.0:19000" %}}
GatewaySvc stores the endpoint at which the GRPC gateway is exposed. [[Ref]](https://github.com/cs3org/reva/tree/master/pkg/storage/fs/eos/eos.go#L94)
{{< highlight toml >}}
[storage.fs.eos]
gatewaysvc = "0.0.0.0:19000"
{{< /highlight >}}
{{% /dir %}}

Original file line number Diff line number Diff line change
Expand Up @@ -144,3 +144,11 @@ use_keytab = false
{{< /highlight >}}
{{% /dir %}}

{{% dir name="gatewaysvc" type="string" default="0.0.0.0:19000" %}}
GatewaySvc stores the endpoint at which the GRPC gateway is exposed. [[Ref]](https://github.com/cs3org/reva/tree/master/pkg/storage/fs/eoshome/eoshome.go#L100)
{{< highlight toml >}}
[storage.fs.eoshome]
gatewaysvc = "0.0.0.0:19000"
{{< /highlight >}}
{{% /dir %}}

20 changes: 10 additions & 10 deletions docs/content/en/docs/config/packages/user/manager/rest/_index.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,64 +8,64 @@ description: >

# _struct: config_

{{% dir name="redis" type="string" default=":6379" %}}
The port on which the redis server is running [[Ref]](https://github.com/cs3org/reva/tree/master/pkg/user/manager/rest/rest.go#L68)
{{% dir name="redis_address" type="string" default="localhost:6379" %}}
The address at which the redis server is running [[Ref]](https://github.com/cs3org/reva/tree/master/pkg/user/manager/rest/rest.go#L68)
{{< highlight toml >}}
[user.manager.rest]
redis = ":6379"
redis_address = "localhost:6379"
{{< /highlight >}}
{{% /dir %}}

{{% dir name="user_groups_cache_expiration" type="int" default=5 %}}
The time in minutes for which the groups to which a user belongs would be cached [[Ref]](https://github.com/cs3org/reva/tree/master/pkg/user/manager/rest/rest.go#L70)
The time in minutes for which the groups to which a user belongs would be cached [[Ref]](https://github.com/cs3org/reva/tree/master/pkg/user/manager/rest/rest.go#L74)
{{< highlight toml >}}
[user.manager.rest]
user_groups_cache_expiration = 5
{{< /highlight >}}
{{% /dir %}}

{{% dir name="id_provider" type="string" default="http://cernbox.cern.ch" %}}
The OIDC Provider [[Ref]](https://github.com/cs3org/reva/tree/master/pkg/user/manager/rest/rest.go#L72)
The OIDC Provider [[Ref]](https://github.com/cs3org/reva/tree/master/pkg/user/manager/rest/rest.go#L76)
{{< highlight toml >}}
[user.manager.rest]
id_provider = "http://cernbox.cern.ch"
{{< /highlight >}}
{{% /dir %}}

{{% dir name="api_base_url" type="string" default="https://authorization-service-api-dev.web.cern.ch/api/v1.0" %}}
Base API Endpoint [[Ref]](https://github.com/cs3org/reva/tree/master/pkg/user/manager/rest/rest.go#L74)
Base API Endpoint [[Ref]](https://github.com/cs3org/reva/tree/master/pkg/user/manager/rest/rest.go#L78)
{{< highlight toml >}}
[user.manager.rest]
api_base_url = "https://authorization-service-api-dev.web.cern.ch/api/v1.0"
{{< /highlight >}}
{{% /dir %}}

{{% dir name="client_id" type="string" default="-" %}}
Client ID needed to authenticate [[Ref]](https://github.com/cs3org/reva/tree/master/pkg/user/manager/rest/rest.go#L76)
Client ID needed to authenticate [[Ref]](https://github.com/cs3org/reva/tree/master/pkg/user/manager/rest/rest.go#L80)
{{< highlight toml >}}
[user.manager.rest]
client_id = "-"
{{< /highlight >}}
{{% /dir %}}

{{% dir name="client_secret" type="string" default="-" %}}
Client Secret [[Ref]](https://github.com/cs3org/reva/tree/master/pkg/user/manager/rest/rest.go#L78)
Client Secret [[Ref]](https://github.com/cs3org/reva/tree/master/pkg/user/manager/rest/rest.go#L82)
{{< highlight toml >}}
[user.manager.rest]
client_secret = "-"
{{< /highlight >}}
{{% /dir %}}

{{% dir name="oidc_token_endpoint" type="string" default="https://keycloak-dev.cern.ch/auth/realms/cern/api-access/token" %}}
Endpoint to generate token to access the API [[Ref]](https://github.com/cs3org/reva/tree/master/pkg/user/manager/rest/rest.go#L81)
Endpoint to generate token to access the API [[Ref]](https://github.com/cs3org/reva/tree/master/pkg/user/manager/rest/rest.go#L85)
{{< highlight toml >}}
[user.manager.rest]
oidc_token_endpoint = "https://keycloak-dev.cern.ch/auth/realms/cern/api-access/token"
{{< /highlight >}}
{{% /dir %}}

{{% dir name="target_api" type="string" default="authorization-service-api" %}}
The target application for which token needs to be generated [[Ref]](https://github.com/cs3org/reva/tree/master/pkg/user/manager/rest/rest.go#L83)
The target application for which token needs to be generated [[Ref]](https://github.com/cs3org/reva/tree/master/pkg/user/manager/rest/rest.go#L87)
{{< highlight toml >}}
[user.manager.rest]
target_api = "authorization-service-api"
Expand Down
2 changes: 1 addition & 1 deletion go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ require (
github.com/go-openapi/strfmt v0.19.2 // indirect
github.com/gofrs/uuid v3.3.0+incompatible
github.com/golang/protobuf v1.4.2
github.com/gomodule/redigo v2.0.0+incompatible
github.com/gomodule/redigo v1.8.2
github.com/google/uuid v1.1.1
github.com/grpc-ecosystem/go-grpc-middleware v1.2.0
github.com/huandu/xstrings v1.3.0 // indirect
Expand Down
4 changes: 2 additions & 2 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -350,8 +350,8 @@ github.com/golang/protobuf v1.4.0/go.mod h1:jodUvKwWbYaEsadDk5Fwe5c77LiNKVO9IDvq
github.com/golang/protobuf v1.4.2 h1:+Z5KGCizgyZCbGh1KZqA0fcLLkwbsjIzS4aV2v7wJX0=
github.com/golang/protobuf v1.4.2/go.mod h1:oDoupMAO8OvCJWAcko0GGGIgR6R6ocIYbsSw735rRwI=
github.com/golang/snappy v0.0.0-20180518054509-2e65f85255db/go.mod h1:/XxbfmMg8lxefKM7IXC3fBNl/7bRcc72aCRzEWrmP2Q=
github.com/gomodule/redigo v2.0.0+incompatible h1:K/R+8tc58AaqLkqG2Ol3Qk+DR/TlNuhuh457pBFPtt0=
github.com/gomodule/redigo v2.0.0+incompatible/go.mod h1:B4C85qUVwatsJoIUNIfCRsp7qO0iAmpGFZ4EELWSbC4=
github.com/gomodule/redigo v1.8.2 h1:H5XSIre1MB5NbPYFp+i1NBbb5qN1W8Y8YAQoAYbkm8k=
github.com/gomodule/redigo v1.8.2/go.mod h1:P9dn9mFrCBvWhGE1wpxx6fgq7BAeLBk+UUUzlpkBYO0=
github.com/google/btree v0.0.0-20180813153112-4030bb1f1f0c/go.mod h1:lNA+9X1NB3Zf8V7Ke586lFgjr2dZNuvo3lPJSGZ5JPQ=
github.com/google/btree v1.0.0/go.mod h1:lNA+9X1NB3Zf8V7Ke586lFgjr2dZNuvo3lPJSGZ5JPQ=
github.com/google/go-cmp v0.2.0/go.mod h1:oXzfMopK8JAjlY9xF4vHSVASa0yLyX7SntLO5aqRK0M=
Expand Down
2 changes: 1 addition & 1 deletion pkg/storage/fs/eos/eos.go
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,7 @@ type config struct {
UseKeytab bool `mapstructure:"use_keytab" docs:"false"`

// GatewaySvc stores the endpoint at which the GRPC gateway is exposed.
GatewaySvc string `mapstructure:"gatewaysvc"`
GatewaySvc string `mapstructure:"gatewaysvc" docs:"0.0.0.0:19000"`
}

func parseConfig(m map[string]interface{}) (*config, error) {
Expand Down
2 changes: 1 addition & 1 deletion pkg/storage/fs/eoshome/eoshome.go
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,7 @@ type config struct {
UseKeytab bool `mapstructure:"use_keytab" docs:"false"`

// GatewaySvc stores the endpoint at which the GRPC gateway is exposed.
GatewaySvc string `mapstructure:"gatewaysvc"`
GatewaySvc string `mapstructure:"gatewaysvc" docs:"0.0.0.0:19000"`
}

func parseConfig(m map[string]interface{}) (*config, error) {
Expand Down
19 changes: 17 additions & 2 deletions pkg/user/manager/rest/cache.go
Original file line number Diff line number Diff line change
Expand Up @@ -34,15 +34,30 @@ const (
userUIDPrefix = "uid:"
)

func initRedisPool(port string) *redis.Pool {
func initRedisPool(address, username, password string) *redis.Pool {
return &redis.Pool{

MaxIdle: 50,
MaxActive: 1000,
IdleTimeout: 240 * time.Second,

Dial: func() (redis.Conn, error) {
c, err := redis.Dial("tcp", port)
var c redis.Conn
var err error
switch {
case username != "":
c, err = redis.Dial("tcp", address,
redis.DialUsername(username),
redis.DialPassword(password),
)
case password != "":
c, err = redis.Dial("tcp", address,
redis.DialPassword(password),
)
default:
c, err = redis.Dial("tcp", address)
}

if err != nil {
return nil, err
}
Expand Down
14 changes: 9 additions & 5 deletions pkg/user/manager/rest/rest.go
Original file line number Diff line number Diff line change
Expand Up @@ -64,8 +64,12 @@ type OIDCToken struct {
}

type config struct {
// The port on which the redis server is running
Redis string `mapstructure:"redis" docs:":6379"`
// The address at which the redis server is running
RedisAddress string `mapstructure:"redis_address" docs:"localhost:6379"`
// The username for connecting to the redis server
RedisUsername string `mapstructure:"redis_username" docs:""`
// The password for connecting to the redis server
RedisPassword string `mapstructure:"redis_password" docs:""`
// The time in minutes for which the groups to which a user belongs would be cached
UserGroupsCacheExpiration int `mapstructure:"user_groups_cache_expiration" docs:"5"`
// The OIDC Provider
Expand All @@ -87,8 +91,8 @@ func (c *config) init() {
if c.UserGroupsCacheExpiration == 0 {
c.UserGroupsCacheExpiration = 5
}
if c.Redis == "" {
c.Redis = ":6379"
if c.RedisAddress == "" {
c.RedisAddress = ":6379"
}
if c.APIBaseURL == "" {
c.APIBaseURL = "https://authorization-service-api-dev.web.cern.ch/api/v1.0"
Expand Down Expand Up @@ -120,7 +124,7 @@ func New(m map[string]interface{}) (user.Manager, error) {
}
c.init()

redisPool := initRedisPool(c.Redis)
redisPool := initRedisPool(c.RedisAddress, c.RedisUsername, c.RedisPassword)
return &manager{
conf: c,
redisPool: redisPool,
Expand Down

0 comments on commit 3ef1849

Please sign in to comment.