Skip to content

Commit cf8d7fd

Browse files
committed
refactor: make composition variables internal
1 parent c4d4d4d commit cf8d7fd

File tree

3 files changed

+17
-9
lines changed

3 files changed

+17
-9
lines changed

Sources/FusionAuth/oauth/OAuthAuthorizationService.swift

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,7 @@ public class OAuthAuthorizationService {
6363
let request = OIDAuthorizationRequest(configuration: configuration,
6464
clientId: clientId,
6565
scopes: [OIDScopeOpenID, "offline_access"] + self.additionalScopes,
66-
redirectURL: URL(string: options.bundleId + options.redirectUri)!,
66+
redirectURL: URL(string: options.redirectUri)!,
6767
responseType: OIDResponseTypeCode,
6868
additionalParameters: getParametersFromOptions(options))
6969

@@ -158,7 +158,7 @@ public class OAuthAuthorizationService {
158158
if options.state == nil || options.state!.isEmpty {
159159
request = OIDEndSessionRequest(configuration: configuration,
160160
idTokenHint: idToken,
161-
postLogoutRedirectURL: URL(string: options.bundleId + options.postLogoutRedirectUri)!,
161+
postLogoutRedirectURL: URL(string: options.postLogoutRedirectUri)!,
162162
additionalParameters: nil)
163163
} else {
164164
request = OIDEndSessionRequest(configuration: configuration,

Sources/FusionAuth/oauth/OAuthAuthorizeOptions.swift

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,9 +6,12 @@ import Foundation
66
/// for more information.
77
public struct OAuthAuthorizeOptions {
88
/// The Bundle Identifier used for the redirect URI
9-
let bundleId: String
9+
private let bundleId: String
10+
/// The redirect URI suffix for comprising the redirect URI
11+
private let redirectUriSuffix: String
1012
/// The redirect URI to be used for the OAuth authorize request.
1113
/// Default is "io.fusionauth.app:/oauth2redirect/ios-provider".
14+
/// Which is a combination of bundleId and postLogoutRedirectUriSuffix
1215
let redirectUri: String
1316
/// The identity provider hint to be used for the OAuth authorize request.
1417
let idpHint: String?
@@ -31,7 +34,7 @@ public struct OAuthAuthorizeOptions {
3134

3235
public init(
3336
bundleId: String = Bundle.main.bundleIdentifier ?? "",
34-
redirectUri: String = ":/oauth2redirect/ios-provider",
37+
redirectUriSuffix: String = ":/oauth2redirect/ios-provider",
3538
idpHint: String? = nil,
3639
codeChallenge: String? = nil,
3740
codeChallengeMethod: OAuthCodeChallengeMethod? = nil,
@@ -41,8 +44,9 @@ public struct OAuthAuthorizeOptions {
4144
state: String? = nil,
4245
userCode: String? = nil
4346
) {
47+
self.redirectUriSuffix = redirectUriSuffix
4448
self.bundleId = bundleId
45-
self.redirectUri = redirectUri
49+
self.redirectUri = bundleId + redirectUriSuffix
4650
self.idpHint = idpHint
4751
self.codeChallenge = codeChallenge
4852
self.codeChallengeMethod = codeChallengeMethod

Sources/FusionAuth/oauth/OAuthLogoutOptions.swift

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -5,22 +5,26 @@ import Foundation
55
/// See [FusionAuth OAuth 2.0 Authorization Endpoint](https://fusionauth.io/docs/lifecycle/authenticate-users/oauth/endpoints#logout)
66
/// for more information.
77
public struct OAuthLogoutOptions {
8-
/// The Bundle Identifier used for the redirect URI
9-
let bundleId: String
8+
/// The Bundle Identifier used for comprising the redirect URI
9+
private let bundleId: String
10+
/// The post logout redirect URI suffix for comprising the redirect URI
11+
private let postLogoutRedirectUriSuffix: String
1012
/// The post logout redirect URI to be used for the OAuth logout request.
1113
/// Default is "io.fusionauth.app:/oauth2redirect/ios-provider".
14+
/// Which is a combination of bundleId and postLogoutRedirectUriSuffix
1215
let postLogoutRedirectUri: String
1316
/// An opaque value used by the client to maintain state between the request and callback.
1417
/// The authorization server includes this value when redirecting the user-agent back to the client.
1518
let state: String?
1619

1720
public init(
1821
bundleId: String = Bundle.main.bundleIdentifier ?? "",
19-
postLogoutRedirectUri: String = ":/oauth2redirect/ios-provider",
22+
postLogoutRedirectUriSuffix: String = ":/oauth2redirect/ios-provider",
2023
state: String? = nil
2124
) {
2225
self.bundleId = bundleId
23-
self.postLogoutRedirectUri = postLogoutRedirectUri
26+
self.postLogoutRedirectUriSuffix = postLogoutRedirectUriSuffix
27+
self.postLogoutRedirectUri = bundleId + postLogoutRedirectUriSuffix
2428
self.state = state
2529
}
2630
}

0 commit comments

Comments
 (0)