Skip to content

Commit

Permalink
refactor: make composition variables internal
Browse files Browse the repository at this point in the history
  • Loading branch information
Aaron-Ritter committed Sep 19, 2024
1 parent c4d4d4d commit cf8d7fd
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 9 deletions.
4 changes: 2 additions & 2 deletions Sources/FusionAuth/oauth/OAuthAuthorizationService.swift
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ public class OAuthAuthorizationService {
let request = OIDAuthorizationRequest(configuration: configuration,
clientId: clientId,
scopes: [OIDScopeOpenID, "offline_access"] + self.additionalScopes,
redirectURL: URL(string: options.bundleId + options.redirectUri)!,
redirectURL: URL(string: options.redirectUri)!,
responseType: OIDResponseTypeCode,
additionalParameters: getParametersFromOptions(options))

Expand Down Expand Up @@ -158,7 +158,7 @@ public class OAuthAuthorizationService {
if options.state == nil || options.state!.isEmpty {
request = OIDEndSessionRequest(configuration: configuration,
idTokenHint: idToken,
postLogoutRedirectURL: URL(string: options.bundleId + options.postLogoutRedirectUri)!,
postLogoutRedirectURL: URL(string: options.postLogoutRedirectUri)!,
additionalParameters: nil)
} else {
request = OIDEndSessionRequest(configuration: configuration,
Expand Down
10 changes: 7 additions & 3 deletions Sources/FusionAuth/oauth/OAuthAuthorizeOptions.swift
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,12 @@ import Foundation
/// for more information.
public struct OAuthAuthorizeOptions {
/// The Bundle Identifier used for the redirect URI
let bundleId: String
private let bundleId: String
/// The redirect URI suffix for comprising the redirect URI
private let redirectUriSuffix: String
/// The redirect URI to be used for the OAuth authorize request.
/// Default is "io.fusionauth.app:/oauth2redirect/ios-provider".
/// Which is a combination of bundleId and postLogoutRedirectUriSuffix
let redirectUri: String
/// The identity provider hint to be used for the OAuth authorize request.
let idpHint: String?
Expand All @@ -31,7 +34,7 @@ public struct OAuthAuthorizeOptions {

public init(
bundleId: String = Bundle.main.bundleIdentifier ?? "",
redirectUri: String = ":/oauth2redirect/ios-provider",
redirectUriSuffix: String = ":/oauth2redirect/ios-provider",
idpHint: String? = nil,
codeChallenge: String? = nil,
codeChallengeMethod: OAuthCodeChallengeMethod? = nil,
Expand All @@ -41,8 +44,9 @@ public struct OAuthAuthorizeOptions {
state: String? = nil,
userCode: String? = nil
) {
self.redirectUriSuffix = redirectUriSuffix
self.bundleId = bundleId
self.redirectUri = redirectUri
self.redirectUri = bundleId + redirectUriSuffix
self.idpHint = idpHint
self.codeChallenge = codeChallenge
self.codeChallengeMethod = codeChallengeMethod
Expand Down
12 changes: 8 additions & 4 deletions Sources/FusionAuth/oauth/OAuthLogoutOptions.swift
Original file line number Diff line number Diff line change
Expand Up @@ -5,22 +5,26 @@ import Foundation
/// See [FusionAuth OAuth 2.0 Authorization Endpoint](https://fusionauth.io/docs/lifecycle/authenticate-users/oauth/endpoints#logout)
/// for more information.
public struct OAuthLogoutOptions {
/// The Bundle Identifier used for the redirect URI
let bundleId: String
/// The Bundle Identifier used for comprising the redirect URI
private let bundleId: String
/// The post logout redirect URI suffix for comprising the redirect URI
private let postLogoutRedirectUriSuffix: String
/// The post logout redirect URI to be used for the OAuth logout request.
/// Default is "io.fusionauth.app:/oauth2redirect/ios-provider".
/// Which is a combination of bundleId and postLogoutRedirectUriSuffix
let postLogoutRedirectUri: String
/// An opaque value used by the client to maintain state between the request and callback.
/// The authorization server includes this value when redirecting the user-agent back to the client.
let state: String?

public init(
bundleId: String = Bundle.main.bundleIdentifier ?? "",
postLogoutRedirectUri: String = ":/oauth2redirect/ios-provider",
postLogoutRedirectUriSuffix: String = ":/oauth2redirect/ios-provider",
state: String? = nil
) {
self.bundleId = bundleId
self.postLogoutRedirectUri = postLogoutRedirectUri
self.postLogoutRedirectUriSuffix = postLogoutRedirectUriSuffix
self.postLogoutRedirectUri = bundleId + postLogoutRedirectUriSuffix
self.state = state
}
}

0 comments on commit cf8d7fd

Please sign in to comment.