From 225ecd5f7bd1f3bb2d1b09d0f9983289d35fb4e0 Mon Sep 17 00:00:00 2001 From: Quinn Thomson Date: Fri, 24 Sep 2021 16:16:44 -0600 Subject: [PATCH 1/3] Allow custom scope to be entered, such as offline_access --- Auth0/BaseWebAuth.swift | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/Auth0/BaseWebAuth.swift b/Auth0/BaseWebAuth.swift index e01a8602..f47b4397 100644 --- a/Auth0/BaseWebAuth.swift +++ b/Auth0/BaseWebAuth.swift @@ -259,10 +259,16 @@ class BaseWebAuth: WebAuthenticatable { var entries = defaults entries["client_id"] = self.clientId entries["redirect_uri"] = redirectURL.absoluteString - entries["scope"] = "openid" entries["state"] = state entries["response_type"] = self.responseType.map { $0.label! }.joined(separator: " ") + // Allow custom scope to be entered, such as offline_access + if let customScope = entries["scope"] { + entries["scope"] = customScope + } else { + entries["scope"] = "openid" + } + if let maxAge = self.maxAge { entries["max_age"] = String(maxAge) } From 51d1be631900cbd0bae1fca6b88d7f7b1ac38b5f Mon Sep 17 00:00:00 2001 From: Quinn Thomson Date: Thu, 30 Sep 2021 11:41:29 -0600 Subject: [PATCH 2/3] temp push to turn off reuse of valid tokens --- Auth0/CredentialsManager.swift | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/Auth0/CredentialsManager.swift b/Auth0/CredentialsManager.swift index b78ee48f..018f46fa 100644 --- a/Auth0/CredentialsManager.swift +++ b/Auth0/CredentialsManager.swift @@ -200,9 +200,9 @@ public struct CredentialsManager { private func retrieveCredentials(withScope scope: String?, minTTL: Int, parameters: [String: Any] = [:], callback: @escaping (CredentialsManagerError?, Credentials?) -> Void) { guard let credentials = retrieveCredentials(), let expiresIn = credentials.expiresIn else { return callback(.noCredentials, nil) } - guard self.hasExpired(credentials) || - self.willExpire(credentials, within: minTTL) || - self.hasScopeChanged(credentials, from: scope) else { return callback(nil, credentials) } +// guard self.hasExpired(credentials) || +// self.willExpire(credentials, within: minTTL) || +// self.hasScopeChanged(credentials, from: scope) else { return callback(nil, credentials) } guard let refreshToken = credentials.refreshToken else { return callback(.noRefreshToken, nil) } self.authentication From 83d34f8b211fac5400f8a05c506922ce89a514e7 Mon Sep 17 00:00:00 2001 From: Quinn Thomson Date: Mon, 29 Nov 2021 15:56:36 -0700 Subject: [PATCH 3/3] uncomment some lines --- Auth0/CredentialsManager.swift | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/Auth0/CredentialsManager.swift b/Auth0/CredentialsManager.swift index 018f46fa..b78ee48f 100644 --- a/Auth0/CredentialsManager.swift +++ b/Auth0/CredentialsManager.swift @@ -200,9 +200,9 @@ public struct CredentialsManager { private func retrieveCredentials(withScope scope: String?, minTTL: Int, parameters: [String: Any] = [:], callback: @escaping (CredentialsManagerError?, Credentials?) -> Void) { guard let credentials = retrieveCredentials(), let expiresIn = credentials.expiresIn else { return callback(.noCredentials, nil) } -// guard self.hasExpired(credentials) || -// self.willExpire(credentials, within: minTTL) || -// self.hasScopeChanged(credentials, from: scope) else { return callback(nil, credentials) } + guard self.hasExpired(credentials) || + self.willExpire(credentials, within: minTTL) || + self.hasScopeChanged(credentials, from: scope) else { return callback(nil, credentials) } guard let refreshToken = credentials.refreshToken else { return callback(.noRefreshToken, nil) } self.authentication