forked from contamobi/go-oauth2-dynamodb
/
config.go
36 lines (32 loc) · 843 Bytes
/
config.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
package oauth2dynamodb
import (
"github.com/aws/aws-sdk-go/aws"
"github.com/aws/aws-sdk-go/aws/session"
)
// Config dynamodb configuration parameters
type Config struct {
SESSION *session.Session
TABLE *TableConfig
}
// TableConfig internally stores the table names to use for dynamodb
type TableConfig struct {
BasicCname string
AccessCName string
RefreshCName string
}
// NewConfig create dynamodb configuration
func NewConfig(awsConfig *aws.Config, basicTableName string, accessTableName string, refreshTablName string) (*Config, error) {
newSession, err := session.NewSession(awsConfig)
if err != nil {
return nil, err
}
config := &Config{
SESSION: newSession,
TABLE: &TableConfig{
BasicCname: basicTableName,
AccessCName: accessTableName,
RefreshCName: refreshTablName,
},
}
return config, nil
}