@@ -9,29 +9,24 @@ import (
99 "go.uber.org/zap"
1010)
1111
12+ // basicAuth struct implements authInterface for this integration
1213type basicAuth struct {
13- Sugar * zap.SugaredLogger
14-
15- // Set
16- baseDomain string
17- username string
18- password string
19- bufferPeriod time.Duration
20- hideSensitiveData bool
21-
22- // Computed
23- // basicToken string
14+ Sugar * zap.SugaredLogger
15+ baseDomain string
16+ username string
17+ password string
18+ bufferPeriod time.Duration
19+ hideSensitiveData bool
2420 bearerToken string
2521 bearerTokenExpiryTime time.Time
2622}
2723
24+ // basicAuthResponse serves as a json structure map for the basicAuth response from Jamf.
2825type basicAuthResponse struct {
2926 Token string `json:"token"`
3027 Expires time.Time `json:"expires"`
3128}
3229
33- // Operations
34-
3530// getNewToken obtains a new bearer token from the authentication server.
3631// This function constructs a new HTTP request to the bearer token endpoint using the basic authentication credentials,
3732// sends the request, and updates the basicAuth instance with the new bearer token and its expiry time.
@@ -50,14 +45,14 @@ type basicAuthResponse struct {
5045// TODO migrate strings
5146func (a * basicAuth ) getNewToken () error {
5247 client := http.Client {}
53-
5448 completeBearerEndpoint := a .baseDomain + bearerTokenEndpoint
5549 a .Sugar .Debugf ("bearer endpoint constructed: %s" , completeBearerEndpoint )
5650
5751 req , err := http .NewRequest ("POST" , completeBearerEndpoint , nil )
5852 if err != nil {
5953 return err
6054 }
55+
6156 a .Sugar .Debugf ("bearer token request constructed: %+v" , req )
6257
6358 req .SetBasicAuth (a .username , a .password )
@@ -67,6 +62,7 @@ func (a *basicAuth) getNewToken() error {
6762 return err
6863 }
6964 defer resp .Body .Close ()
65+
7066 a .Sugar .Debugf ("bearer token request made: %v" , resp .StatusCode )
7167
7268 if resp .StatusCode != http .StatusOK {
@@ -110,8 +106,6 @@ func (a *basicAuth) getExpiryTime() time.Time {
110106 return a .bearerTokenExpiryTime
111107}
112108
113- // Utils
114-
115109// tokenExpired checks if the current bearer token has expired.
116110// This function compares the current time with the bearer token's expiry time to determine if the token has expired.
117111//
0 commit comments