Skip to content

Commit c4d4d4d

Browse files
committed
fix: redirectUri bundleIdentifier usage
1 parent 15264de commit c4d4d4d

File tree

3 files changed

+12
-4
lines changed

3 files changed

+12
-4
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.redirectUri)!,
66+
redirectURL: URL(string: options.bundleId + 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.postLogoutRedirectUri)!,
161+
postLogoutRedirectURL: URL(string: options.bundleId + options.postLogoutRedirectUri)!,
162162
additionalParameters: nil)
163163
} else {
164164
request = OIDEndSessionRequest(configuration: configuration,

Sources/FusionAuth/oauth/OAuthAuthorizeOptions.swift

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,8 @@ import Foundation
55
/// See [FusionAuth OAuth 2.0 Authorization Endpoint](https://fusionauth.io/docs/lifecycle/authenticate-users/oauth/endpoints#authorize)
66
/// for more information.
77
public struct OAuthAuthorizeOptions {
8+
/// The Bundle Identifier used for the redirect URI
9+
let bundleId: String
810
/// The redirect URI to be used for the OAuth authorize request.
911
/// Default is "io.fusionauth.app:/oauth2redirect/ios-provider".
1012
let redirectUri: String
@@ -28,7 +30,8 @@ public struct OAuthAuthorizeOptions {
2830
let userCode: String?
2931

3032
public init(
31-
redirectUri: String = "\(String(describing: Bundle.main.bundleIdentifier ?? "")):/oauth2redirect/ios-provider",
33+
bundleId: String = Bundle.main.bundleIdentifier ?? "",
34+
redirectUri: String = ":/oauth2redirect/ios-provider",
3235
idpHint: String? = nil,
3336
codeChallenge: String? = nil,
3437
codeChallengeMethod: OAuthCodeChallengeMethod? = nil,
@@ -38,6 +41,7 @@ public struct OAuthAuthorizeOptions {
3841
state: String? = nil,
3942
userCode: String? = nil
4043
) {
44+
self.bundleId = bundleId
4145
self.redirectUri = redirectUri
4246
self.idpHint = idpHint
4347
self.codeChallenge = codeChallenge

Sources/FusionAuth/oauth/OAuthLogoutOptions.swift

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,8 @@ 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
810
/// The post logout redirect URI to be used for the OAuth logout request.
911
/// Default is "io.fusionauth.app:/oauth2redirect/ios-provider".
1012
let postLogoutRedirectUri: String
@@ -13,9 +15,11 @@ public struct OAuthLogoutOptions {
1315
let state: String?
1416

1517
public init(
16-
postLogoutRedirectUri: String = "\(String(describing: Bundle.main.bundleIdentifier ?? "")):/oauth2redirect/ios-provider",
18+
bundleId: String = Bundle.main.bundleIdentifier ?? "",
19+
postLogoutRedirectUri: String = ":/oauth2redirect/ios-provider",
1720
state: String? = nil
1821
) {
22+
self.bundleId = bundleId
1923
self.postLogoutRedirectUri = postLogoutRedirectUri
2024
self.state = state
2125
}

0 commit comments

Comments
 (0)