Skip to content

Commit 6739ea3

Browse files
Merge pull request #463 from okta/fix-empty-nonce-for-dpop
fix empty nonce for dpop
2 parents 90b60d8 + 610231f commit 6739ea3

File tree

4 files changed

+16
-10
lines changed

4 files changed

+16
-10
lines changed

.generator/config.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ additionalProperties:
88
enumClassPrefix: true
99
generateInterfaces: true
1010
packageName: okta
11-
packageVersion: 4.1.0
11+
packageVersion: 4.1.1
1212
useOneOfDiscriminatorLookup: true
1313
disallowAdditionalPropertiesIfNotPresent: false
1414
files:

.generator/okta-management-APIs-oasv3-noEnums-inheritance.yaml

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -33112,9 +33112,7 @@ components:
3311233112
readOnly: true
3311333113
detailEntry:
3311433114
type: object
33115-
additionalProperties:
33116-
type: object
33117-
properties: {}
33115+
additionalProperties: true
3311833116
readOnly: true
3311933117
displayName:
3312033118
type: string

.generator/templates/client.mustache

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -161,13 +161,13 @@ func NewPrivateKeyAuth(config PrivateKeyAuthConfig) *PrivateKeyAuth {
161161

162162
func (a *PrivateKeyAuth) Authorize(method, URL string) error {
163163
accessToken, hasToken := a.tokenCache.Get(AccessTokenCacheKey)
164-
if hasToken {
164+
if hasToken && accessToken != "" {
165165
accessTokenWithTokenType := accessToken.(string)
166166
a.req.Header.Add("Authorization", accessTokenWithTokenType)
167167
nonce, hasNonce := a.tokenCache.Get(DpopAccessTokenNonce)
168-
if hasNonce {
168+
if hasNonce && nonce != "" {
169169
privateKey, ok := a.tokenCache.Get(DpopAccessTokenPrivateKey)
170-
if ok {
170+
if ok && privateKey != nil {
171171
res := strings.Split(accessTokenWithTokenType, " ")
172172
if len(res) != 2 {
173173
return errors.New("Unidentified access token")
@@ -178,6 +178,8 @@ func (a *PrivateKeyAuth) Authorize(method, URL string) error {
178178
}
179179
a.req.Header.Set("Dpop", dpopJWT)
180180
a.req.Header.Set("x-okta-user-agent-extended", "isDPoP:true")
181+
} else {
182+
return errors.New("Using Dpop but signing key not found")
181183
}
182184
}
183185
} else {
@@ -259,13 +261,13 @@ func NewJWTAuth(config JWTAuthConfig) *JWTAuth {
259261

260262
func (a *JWTAuth) Authorize(method, URL string) error {
261263
accessToken, hasToken := a.tokenCache.Get(AccessTokenCacheKey)
262-
if hasToken {
264+
if hasToken && accessToken != "" {
263265
accessTokenWithTokenType := accessToken.(string)
264266
a.req.Header.Add("Authorization", accessTokenWithTokenType)
265267
nonce, hasNonce := a.tokenCache.Get(DpopAccessTokenNonce)
266-
if hasNonce {
268+
if hasNonce && nonce != "" {
267269
privateKey, ok := a.tokenCache.Get(DpopAccessTokenPrivateKey)
268-
if ok {
270+
if ok && privateKey != nil {
269271
res := strings.Split(accessTokenWithTokenType, " ")
270272
if len(res) != 2 {
271273
return errors.New("Unidentified access token")
@@ -276,6 +278,8 @@ func (a *JWTAuth) Authorize(method, URL string) error {
276278
}
277279
a.req.Header.Set("Dpop", dpopJWT)
278280
a.req.Header.Set("x-okta-user-agent-extended", "isDPoP:true")
281+
} else {
282+
return errors.New("Using Dpop but signing key not found")
279283
}
280284
}
281285
} else {

CHANGELOG.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,10 @@
11
# Changelog
22
Running changelog of releases since `2.0.0-rc.4`
33

4+
## v4.1.0
5+
- Fix panic issue when using bearer token (#463) Thanks [@duytiennguyen-okta]
6+
- Fix object that does not have additional properties (#463) Thanks [@duytiennguyen-okta]
7+
48
## v4.1.0
59
- Add support for dpop (#454) Thanks [@duytiennguyen-okta]
610
- Fix object that does not have additional properties (#456) Thanks [@duytiennguyen-okta]

0 commit comments

Comments
 (0)