Skip to content

Commit 0ec3626

Browse files
authored
Merge pull request #84 from TheThingsNetwork/feature/skip-cac
Export CACs only on explicit request
2 parents 5d909b7 + 1125cf5 commit 0ec3626

File tree

3 files changed

+24
-6
lines changed

3 files changed

+24
-6
lines changed

CHANGELOG.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
99
### Added
1010

1111
- Each source has its own dedicated command.
12+
- End Device Claim Authentication Codes are exported only if `--export-cacs` is set.
1213

1314
### Changed
1415

@@ -22,6 +23,8 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
2223

2324
### Fixed
2425

26+
- Wrong flag name `appplication-server-grpc-address` fixed to `application-server-grpc-address`.
27+
2528
### Security
2629

2730
## [v0.9.0]

pkg/source/tts/config/config.go

Lines changed: 13 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -98,7 +98,7 @@ func New() (*Config, *pflag.FlagSet) {
9898
os.Getenv("TTS_DEFAULT_GRPC_ADDRESS"),
9999
"TTS default GRPC Address (optional)")
100100
flags.StringVar(&config.ServerConfig.ApplicationServerGRPCAddress,
101-
"appplication-server-grpc-address",
101+
"application-server-grpc-address",
102102
os.Getenv("TTS_APPLICATION_SERVER_GRPC_ADDRESS"),
103103
"TTS Application Server GRPC Address")
104104
flags.StringVar(&config.ServerConfig.IdentityServerGRPCAddress,
@@ -123,6 +123,12 @@ func New() (*Config, *pflag.FlagSet) {
123123
false,
124124
"TTS delete exported devices")
125125

126+
flags.BoolVar(&config.ExportCACs,
127+
"export-cacs",
128+
false,
129+
"Export Claim Authentication Codes (CAC)",
130+
)
131+
126132
return config, flags
127133
}
128134

@@ -131,11 +137,14 @@ type Config struct {
131137

132138
ServerConfig *serverConfig
133139

134-
caPath, appAPIKey,
135-
AppID string
140+
insecure bool
141+
caPath string
142+
appAPIKey string
136143

137-
insecure, NoSession,
144+
ExportCACs bool
145+
NoSession bool
138146
DeleteSourceDevice bool
147+
AppID string
139148
}
140149

141150
func (c *Config) Initialize(rootConfig source.Config) error {

pkg/source/tts/source.go

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,13 @@ func (s Source) ExportDevice(devID string) (*ttnpb.EndDevice, error) {
4848
return nil, errNoAppID.New()
4949
}
5050

51-
isPaths, nsPaths, asPaths, jsPaths := splitEndDeviceGetPaths(ttnpb.BottomLevelFields(ttnpb.EndDeviceFieldPathsNested)...)
51+
basePaths := ttnpb.EndDeviceFieldPathsNested
52+
53+
if !s.config.ExportCACs {
54+
basePaths = ttnpb.ExcludeFields(basePaths, claimAuthenticationCodePaths...)
55+
}
56+
57+
isPaths, nsPaths, asPaths, jsPaths := splitEndDeviceGetPaths(ttnpb.BottomLevelFields(basePaths)...)
5258
if len(nsPaths) > 0 {
5359
isPaths = ttnpb.AddFields(isPaths, "network_server_address")
5460
}
@@ -73,7 +79,7 @@ func (s Source) ExportDevice(devID string) (*ttnpb.EndDevice, error) {
7379
if err != nil {
7480
return nil, err
7581
}
76-
if dev.ClaimAuthenticationCode.GetValue() != "" {
82+
if dev.ClaimAuthenticationCode.GetValue() != "" || !s.config.ExportCACs {
7783
// ClaimAuthenticationCode is already retrieved from the IS. We can unset the related JS paths
7884
jsPaths = ttnpb.ExcludeFields(jsPaths, claimAuthenticationCodePaths...)
7985
}

0 commit comments

Comments
 (0)