Skip to content

Commit

Permalink
Merge pull request #466 from okta/fix-panic-nil-accessToken
Browse files Browse the repository at this point in the history
fix panic for nil access token
  • Loading branch information
duytiennguyen-okta committed Jun 12, 2024
2 parents 6739ea3 + 65a5158 commit 8995013
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 12 deletions.
16 changes: 4 additions & 12 deletions .generator/okta-management-APIs-oasv3-noEnums-inheritance.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -31913,9 +31913,7 @@ components:
type: string
profile:
type: object
additionalProperties:
type: object
properties: {}
additionalProperties: true
_embedded:
type: object
additionalProperties:
Expand Down Expand Up @@ -32658,9 +32656,7 @@ components:
readOnly: true
detailEntry:
type: object
additionalProperties:
type: object
properties: {}
additionalProperties: true
readOnly: true
displayName:
type: string
Expand Down Expand Up @@ -33128,9 +33124,7 @@ components:
properties:
detail:
type: object
additionalProperties:
type: object
properties: {}
additionalProperties: true
readOnly: true
id:
type: string
Expand Down Expand Up @@ -33827,9 +33821,7 @@ components:
profile:
type: object
description: Contains any valid JSON schema for specifying properties that can be referenced from a request (only available to OAuth 2.0 client apps)
additionalProperties:
type: object
properties: {}
additionalProperties: true
settings:
$ref: '#/components/schemas/OINBaseSignOnModeApplicationSettings'
signOnMode:
Expand Down
8 changes: 8 additions & 0 deletions .generator/templates/client.mustache
Original file line number Diff line number Diff line change
Expand Up @@ -201,6 +201,10 @@ func (a *PrivateKeyAuth) Authorize(method, URL string) error {
return err
}

if accessToken == nil {
return errors.New("Empty access token")
}

a.req.Header.Set("Authorization", fmt.Sprintf("%v %v", accessToken.TokenType, accessToken.AccessToken))
if accessToken.TokenType == "DPoP" {
dpopJWT, err := generateDpopJWT(privateKey, method, URL, nonce, accessToken.AccessToken)
Expand Down Expand Up @@ -288,6 +292,10 @@ func (a *JWTAuth) Authorize(method, URL string) error {
return err
}

if accessToken == nil {
return errors.New("Empty access token")
}

a.req.Header.Set("Authorization", fmt.Sprintf("%v %v", accessToken.TokenType, accessToken.AccessToken))
if accessToken.TokenType == "DPoP" {
dpopJWT, err := generateDpopJWT(privateKey, method, URL, nonce, accessToken.AccessToken)
Expand Down
6 changes: 6 additions & 0 deletions .generator/templates/configuration.mustache
Original file line number Diff line number Diff line change
Expand Up @@ -566,6 +566,12 @@ func WithScopes(scopes []string) ConfigSetter {
}
}

func WithDebug(debug bool) ConfigSetter {
return func(c *Configuration) {
c.Debug = debug
}
}

// WithPrivateKey sets private key key. Can be either a path to a private key or private key itself.
func WithPrivateKey(privateKey string) ConfigSetter {
return func(c *Configuration) {
Expand Down

0 comments on commit 8995013

Please sign in to comment.