Skip to content

Commit f262b54

Browse files
cholickluckyj5
authored andcommitted
Update nozzle with client-id and client-secret for token refresh authentication
1 parent c8493db commit f262b54

File tree

460 files changed

+343
-92719
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

460 files changed

+343
-92719
lines changed

.circleci/ci_nozzle_manifest.yml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,8 @@ applications:
1010
API_ENDPOINT:
1111
API_USER:
1212
API_PASSWORD:
13+
CLIENT_ID:
14+
CLIENT_SECRET:
1315
SPLUNK_HOST:
1416
SPLUNK_TOKEN:
1517
SPLUNK_INDEX:

.circleci/update_manifest.sh

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,8 @@ set -e
66
sed -i 's@API_ENDPOINT:.*@'"API_ENDPOINT: $API_ENDPOINT"'@' .circleci/ci_nozzle_manifest.yml
77
sed -i 's@API_USER:.*@'"API_USER: $API_USER"'@' .circleci/ci_nozzle_manifest.yml
88
sed -i 's@API_PASSWORD:.*@'"API_PASSWORD: $API_PASSWORD"'@' .circleci/ci_nozzle_manifest.yml
9+
sed -i 's@CLIENT_ID:.*@'"CLIENT_ID: $CLIENT_ID"'@' .circleci/ci_nozzle_manifest.yml
10+
sed -i 's@CLIENT_SECRET:.*@'"CLIENT_SECRET: $CLIENT_SECRET"'@' .circleci/ci_nozzle_manifest.yml
911
sed -i 's@SPLUNK_HOST:.*@'"SPLUNK_HOST: $SPLUNK_HOST"'@' .circleci/ci_nozzle_manifest.yml
1012
sed -i 's@SPLUNK_TOKEN:.*@'"SPLUNK_TOKEN: $SPLUNK_TOKEN"'@' .circleci/ci_nozzle_manifest.yml
1113
sed -i 's@SPLUNK_INDEX:.*@'"SPLUNK_INDEX: $SPLUNK_INDEX"'@' .circleci/ci_nozzle_manifest.yml

README.md

Lines changed: 19 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -19,30 +19,36 @@ In addition, logs from the nozzle itself are of sourcetype `cf:splunknozzle`.
1919

2020
### Setup
2121

22-
The Nozzle requires a user with the scope `doppler.firehose` and
23-
`cloud_controller.admin_read_only` (the latter is only required if `ADD_APP_INFO` is true). If `cloud_controller.admin_read_only` is not
22+
The Nozzle requires a client with the authorities `doppler.firehose` and `cloud_controller.admin_read_only` (the latter is only required if `ADD_APP_INFO` is true) and grant-types `client_credentials` and `refresh_token`. If `cloud_controller.admin_read_only` is not
2423
available in the system, switch to use `cloud_controller.admin`.
2524

2625
You can either
27-
* Add the user manually using [uaac](https://github.com/cloudfoundry/cf-uaac)
28-
* Add a new user to the deployment manifest; see [uaa.scim.users](https://github.com/cloudfoundry/uaa-release/blob/master/jobs/uaa/spec)
26+
* Add the client manually using [uaac](https://github.com/cloudfoundry/cf-uaac)
27+
* Add the client to the deployment manifest; see [uaa.scim.users](https://github.com/cloudfoundry/uaa-release/blob/master/jobs/uaa/spec)
2928

3029
Manifest example:
3130

3231
```yaml
33-
uaa:
34-
scim:
35-
users:
36-
- splunk-firehose|password123|cloud_controller.admin_read_only,doppler.firehose
32+
33+
# Clients
34+
uaa.clients:
35+
splunk-firehose:
36+
id: splunk-firehose
37+
override: true
38+
secret: splunk-firehose-secret
39+
authorized-grant-types: client_credentials,refresh_token
40+
authorities: doppler.firehose,cloud_controller.admin_read_only
3741
```
3842
3943
`uaac` example:
4044
```shell
4145
uaac target https://uaa.[system domain url]
4246
uaac token client get admin -s [admin client credentials secret]
43-
uaac -t user add splunk-nozzle --password password123 --emails na
44-
uaac -t member add cloud_controller.admin_read_only splunk-nozzle
45-
uaac -t member add doppler.firehose splunk-nozzle
47+
uaac client add splunk-firehose --name splunk-firehose
48+
uaac client add splunk-firehose --secret [your_client_secret]
49+
uaac client add splunk-firehose --authorized_grant_types client_credentials,refresh_token
50+
uaac client add splunk-firehose --authorities doppler.firehose,cloud_controller.admin_read_only
51+
4652
```
4753

4854
`cloud_controller.admin_read_only` will work for cf v241
@@ -55,8 +61,8 @@ You can declare parameters by making a copy of the scripts/nozzle.sh.template.
5561

5662
__Cloud Foundry configuration parameters:__
5763
* `API_ENDPOINT`: Cloud Foundry API endpoint address.
58-
* `API_USER`: Cloud Foundry user name. (Must have scope described above)
59-
* `API_PASSWORD`: Cloud Foundry user password.
64+
* `CLIENT_ID`: UAA Client ID (Must have authorities and grant_types described above).
65+
* `CLIENT_SECRET`: Secret for Client ID.
6066

6167
__Splunk configuration parameters:__
6268
* `SPLUNK_TOKEN`: [Splunk HTTP event collector token](http://docs.splunk.com/Documentation/Splunk/latest/Data/UsetheHTTPEventCollector/).

cache/boltdb.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -359,6 +359,7 @@ func (c *Boltdb) fromPCFApp(app *cfclient.App) *App {
359359
Guid: app.Guid,
360360
SpaceGuid: app.SpaceGuid,
361361
IgnoredApp: c.isOptOut(app.Environment),
362+
CfAppEnv: app.Environment,
362363
}
363364

364365
c.fillOrgAndSpace(cachedApp)

ci/nozzle_manifest.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,8 @@ applications:
88
env:
99
GOPACKAGENAME: main
1010
API_ENDPOINT:
11-
API_USER:
12-
API_PASSWORD:
11+
CLIENT_ID:
12+
CLIENT_SECRET:
1313
SPLUNK_HOST:
1414
SPLUNK_TOKEN:
1515
SPLUNK_INDEX:

glide.lock

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

splunknozzle/config.go

Lines changed: 11 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -11,9 +11,11 @@ import (
1111
)
1212

1313
type Config struct {
14-
ApiEndpoint string `json:"api-endpoint"`
15-
User string `json:"-"`
16-
Password string `json:"-"`
14+
ApiEndpoint string `json:"api-endpoint"`
15+
User string `json:"-"`
16+
Password string `json:"-"`
17+
ClientID string `json:"-"`
18+
ClientSecret string `json:"-"`
1719

1820
SplunkToken string `json:"-"`
1921
SplunkHost string `json:"splunk-host"`
@@ -67,9 +69,13 @@ func NewConfigFromCmdFlags(version, branch, commit, buildos string) *Config {
6769
kingpin.Flag("api-endpoint", "API endpoint address").
6870
OverrideDefaultFromEnvar("API_ENDPOINT").Required().StringVar(&c.ApiEndpoint)
6971
kingpin.Flag("user", "Admin user.").
70-
OverrideDefaultFromEnvar("API_USER").Required().StringVar(&c.User)
72+
OverrideDefaultFromEnvar("API_USER").StringVar(&c.User)
7173
kingpin.Flag("password", "Admin password.").
72-
OverrideDefaultFromEnvar("API_PASSWORD").Required().StringVar(&c.Password)
74+
OverrideDefaultFromEnvar("API_PASSWORD").StringVar(&c.Password)
75+
kingpin.Flag("client-id", "Client ID.").
76+
OverrideDefaultFromEnvar("CLIENT_ID").Required().StringVar(&c.ClientID)
77+
kingpin.Flag("client-secret", "Client secret.").
78+
OverrideDefaultFromEnvar("CLIENT_SECRET").Required().StringVar(&c.ClientSecret)
7379

7480
kingpin.Flag("splunk-host", "Splunk HTTP event collector host").
7581
OverrideDefaultFromEnvar("SPLUNK_HOST").Required().StringVar(&c.SplunkHost)

splunknozzle/config_test.go

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,8 @@ var _ = Describe("Config", func() {
2828
os.Setenv("API_ENDPOINT", "api.bosh-lite.com")
2929
os.Setenv("API_USER", "admin")
3030
os.Setenv("API_PASSWORD", "abc123")
31+
os.Setenv("CLIENT_ID", "client123")
32+
os.Setenv("CLIENT_SECRET", "secret123")
3133

3234
os.Setenv("SPLUNK_TOKEN", "sometoken")
3335
os.Setenv("SPLUNK_HOST", "splunk.example.com")
@@ -69,6 +71,8 @@ var _ = Describe("Config", func() {
6971
Expect(c.ApiEndpoint).To(Equal("api.bosh-lite.com"))
7072
Expect(c.User).To(Equal("admin"))
7173
Expect(c.Password).To(Equal("abc123"))
74+
Expect(c.ClientID).To(Equal("client123"))
75+
Expect(c.ClientSecret).To(Equal("secret123"))
7276

7377
Expect(c.SplunkHost).To(Equal("splunk.example.com"))
7478
Expect(c.SplunkToken).To(Equal("sometoken"))
@@ -160,6 +164,8 @@ var _ = Describe("Config", func() {
160164
"--api-endpoint=api.bosh-lite.comc",
161165
"--user=adminc",
162166
"--password=abc123c",
167+
"--client-id=client123",
168+
"--client-secret=secret123",
163169
"--splunk-host=splunk.example.comc",
164170
"--splunk-token=sometokenc",
165171
"--splunk-index=splunk_indexc",
@@ -196,6 +202,8 @@ var _ = Describe("Config", func() {
196202
Expect(c.ApiEndpoint).To(Equal("api.bosh-lite.comc"))
197203
Expect(c.User).To(Equal("adminc"))
198204
Expect(c.Password).To(Equal("abc123c"))
205+
Expect(c.ClientID).To(Equal("client123"))
206+
Expect(c.ClientSecret).To(Equal("secret123"))
199207

200208
Expect(c.SplunkHost).To(Equal("splunk.example.comc"))
201209
Expect(c.SplunkToken).To(Equal("sometokenc"))

splunknozzle/nozzle.go

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,8 @@ func (s *SplunkFirehoseNozzle) PCFClient() (*cfclient.Client, error) {
4343
Username: s.config.User,
4444
Password: s.config.Password,
4545
SkipSslValidation: s.config.SkipSSLCF,
46+
ClientID: s.config.ClientID,
47+
ClientSecret: s.config.ClientSecret,
4648
}
4749

4850
return cfclient.NewClient(cfConfig)
@@ -80,7 +82,6 @@ func (s *SplunkFirehoseNozzle) EventSink(logger lager.Logger) (eventsink.Sink, e
8082
Logger: logger,
8183
}
8284

83-
8485
var writers []eventwriter.Writer
8586
for i := 0; i < s.config.HecWorkers+1; i++ {
8687
splunkWriter := eventwriter.NewSplunk(writerConfig)

splunknozzle/nozzle_test.go

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -16,9 +16,11 @@ import (
1616

1717
func newConfig() *Config {
1818
return &Config{
19-
ApiEndpoint: "http://localhost:9911",
20-
User: "admin",
21-
Password: "admin",
19+
ApiEndpoint: "http://localhost:9911",
20+
User: "admin",
21+
Password: "admin",
22+
ClientID: "admin",
23+
ClientSecret: "admin",
2224

2325
SplunkToken: "token",
2426
SplunkHost: "localhost:8088",

0 commit comments

Comments
 (0)