Skip to content

Commit

Permalink
Merge pull request #32 from Authress/improve-session-logging-level
Browse files Browse the repository at this point in the history
Improve logging level for session continuation.
  • Loading branch information
wparad authored Dec 27, 2023
2 parents 6260846 + 698f97a commit f4e613b
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 12 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ This is the changelog for [Authress Login](readme.md).
## 2.3 ##
* Add MFA device methods.
* Improve http error handling when there is an issue authenticating.
* Reduce logging level for SESSION continuation.

## 2.2 ##
* Automatically retry on network connection issues.
Expand Down
24 changes: 13 additions & 11 deletions src/httpClient.js
Original file line number Diff line number Diff line change
Expand Up @@ -49,37 +49,37 @@ class HttpClient {
this.loginUrl = `${loginHostFullUrl.origin}/api`;
}

get(url, withCredentials, headers) {
get(url, withCredentials, headers, ignoreExpectedWarnings) {
return retryExecutor(() => {
return this.fetchWrapper('GET', url, null, headers, withCredentials);
return this.fetchWrapper('GET', url, null, headers, withCredentials, ignoreExpectedWarnings);
});
}

delete(url, withCredentials, headers) {
delete(url, withCredentials, headers, ignoreExpectedWarnings) {
return retryExecutor(() => {
return this.fetchWrapper('DELETE', url, null, headers, withCredentials);
return this.fetchWrapper('DELETE', url, null, headers, withCredentials, ignoreExpectedWarnings);
});
}

post(url, withCredentials, data, headers) {
post(url, withCredentials, data, headers, ignoreExpectedWarnings) {
return retryExecutor(() => {
return this.fetchWrapper('POST', url, data, headers, withCredentials);
return this.fetchWrapper('POST', url, data, headers, withCredentials, ignoreExpectedWarnings);
});
}

put(url, withCredentials, data, headers) {
put(url, withCredentials, data, headers, ignoreExpectedWarnings) {
return retryExecutor(() => {
return this.fetchWrapper('PUT', url, data, headers, withCredentials);
return this.fetchWrapper('PUT', url, data, headers, withCredentials, ignoreExpectedWarnings);
});
}

patch(url, withCredentials, data, headers) {
patch(url, withCredentials, data, headers, ignoreExpectedWarnings) {
return retryExecutor(() => {
return this.fetchWrapper('PATCH', url, data, headers, withCredentials);
return this.fetchWrapper('PATCH', url, data, headers, withCredentials, ignoreExpectedWarnings);
});
}

async fetchWrapper(rawMethod, urlObject, data, requestHeaders, withCredentials) {
async fetchWrapper(rawMethod, urlObject, data, requestHeaders, withCredentials, ignoreExpectedWarnings) {
const url = `${this.loginUrl}${urlObject.toString()}`;
const method = rawMethod.toUpperCase();
const headers = Object.assign({}, defaultHeaders, requestHeaders);
Expand Down Expand Up @@ -124,6 +124,8 @@ class HttpClient {
} else if (status === 404) {
message = 'HttpClient Response: Not Found';
level = 'debug';
} else if (status < 500 && ignoreExpectedWarnings) {
level = 'debug';
}

if (this.logger && this.logger[level]) {
Expand Down
2 changes: 1 addition & 1 deletion src/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -354,7 +354,7 @@ class LoginClient {

if (!this.isLocalHost() && !backgroundTrigger) {
try {
const sessionResult = await this.httpClient.patch('/session', this.enableCredentials, {});
const sessionResult = await this.httpClient.patch('/session', this.enableCredentials, {}, null, true);
// In the case that the session contains non cookie based data, store it back to the cookie for this domain
if (sessionResult.data.access_token) {
const idToken = jwtManager.decode(sessionResult.data.id_token);
Expand Down

0 comments on commit f4e613b

Please sign in to comment.