Skip to content
This repository was archived by the owner on Feb 5, 2025. It is now read-only.

Commit 93b9052

Browse files
committed
Make WordPress.com URLs configurable through WordPressAuthenticatorConfiguration
1 parent 76bc6df commit 93b9052

File tree

4 files changed

+31
-1
lines changed

4 files changed

+31
-1
lines changed

WordPressAuthenticator.xcodeproj/project.pbxproj

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77
objects = {
88

99
/* Begin PBXBuildFile section */
10+
1A21EE9822832BC300C940C6 /* WordPressComOAuthClientFacade+Swift.swift in Sources */ = {isa = PBXBuildFile; fileRef = 1A21EE9722832BC200C940C6 /* WordPressComOAuthClientFacade+Swift.swift */; };
1011
1A4095182271AEFC009AA86D /* WPAuthenticator-Swift.h in Headers */ = {isa = PBXBuildFile; fileRef = 1A4095152271AEFC009AA86D /* WPAuthenticator-Swift.h */; settings = {ATTRIBUTES = (Private, ); }; };
1112
7A7A9B9CD2D81959F9AB9AF6 /* Pods_WordPressAuthenticator.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = C736FF243DE333FCAB1C2614 /* Pods_WordPressAuthenticator.framework */; };
1213
98AA5A5720AA1A7000A5958A /* WPHelpIndicatorView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 98AA5A5620AA1A7000A5958A /* WPHelpIndicatorView.swift */; };
@@ -139,6 +140,7 @@
139140
/* End PBXCopyFilesBuildPhase section */
140141

141142
/* Begin PBXFileReference section */
143+
1A21EE9722832BC200C940C6 /* WordPressComOAuthClientFacade+Swift.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = "WordPressComOAuthClientFacade+Swift.swift"; sourceTree = "<group>"; };
142144
1A4095152271AEFC009AA86D /* WPAuthenticator-Swift.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = "WPAuthenticator-Swift.h"; sourceTree = "<group>"; };
143145
276354F054C34AD36CA32AB6 /* Pods-WordPressAuthenticator.release-alpha.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-WordPressAuthenticator.release-alpha.xcconfig"; path = "Pods/Target Support Files/Pods-WordPressAuthenticator/Pods-WordPressAuthenticator.release-alpha.xcconfig"; sourceTree = "<group>"; };
144146
33FEF45B466FF8EAAE5F3923 /* Pods-WordPressAuthenticator.release.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-WordPressAuthenticator.release.xcconfig"; path = "Pods/Target Support Files/Pods-WordPressAuthenticator/Pods-WordPressAuthenticator.release.xcconfig"; sourceTree = "<group>"; };
@@ -443,6 +445,7 @@
443445
B56090FC208A54F700399AE4 /* WordPressComBlogService.swift */,
444446
B56090FD208A54F700399AE4 /* WordPressComOAuthClientFacade.h */,
445447
B5609101208A54F800399AE4 /* WordPressComOAuthClientFacade.m */,
448+
1A21EE9722832BC200C940C6 /* WordPressComOAuthClientFacade+Swift.swift */,
446449
B5609106208A54F800399AE4 /* WordPressXMLRPCAPIFacade.h */,
447450
B5609102208A54F800399AE4 /* WordPressXMLRPCAPIFacade.m */,
448451
);
@@ -864,6 +867,7 @@
864867
B5609119208A555600399AE4 /* SiteInfoHeaderView.swift in Sources */,
865868
B560913E208A563800399AE4 /* SigninEditingState.swift in Sources */,
866869
B56090CF208A4F5400399AE4 /* NUXCollectionViewController.swift in Sources */,
870+
1A21EE9822832BC300C940C6 /* WordPressComOAuthClientFacade+Swift.swift in Sources */,
867871
B5ED7920207E993E00A8FD8C /* WPAuthenticatorLogging.m in Sources */,
868872
B5609138208A563800399AE4 /* LoginSiteAddressViewController.swift in Sources */,
869873
B560910B208A54F800399AE4 /* LoginFacade.m in Sources */,

WordPressAuthenticator/Authenticator/WordPressAuthenticatorConfiguration.swift

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
import GoogleSignIn
2+
import WordPressKit
23

34
// MARK: - WordPressAuthenticator Configuration
45
//
@@ -19,6 +20,14 @@ public struct WordPressAuthenticatorConfiguration {
1920
/// WordPress.com Terms of Service URL
2021
///
2122
let wpcomTermsOfServiceURL: String
23+
24+
/// WordPress.com Base URL for OAuth
25+
///
26+
let wpcomBaseURL: String
27+
28+
/// WordPress.com API Base URL
29+
///
30+
let wpcomAPIBaseURL: String
2231

2332
/// GoogleLogin Client ID
2433
///
@@ -42,6 +51,8 @@ public struct WordPressAuthenticatorConfiguration {
4251
wpcomSecret: String,
4352
wpcomScheme: String,
4453
wpcomTermsOfServiceURL: String,
54+
wpcomBaseURL: String = WordPressComOAuthClient.WordPressComOAuthDefaultBaseUrl,
55+
wpcomAPIBaseURL: String = WordPressComOAuthClient.WordPressComOAuthDefaultApiBaseUrl,
4556
googleLoginClientId: String,
4657
googleLoginServerClientId: String,
4758
googleLoginScheme: String,
@@ -51,6 +62,8 @@ public struct WordPressAuthenticatorConfiguration {
5162
self.wpcomSecret = wpcomSecret
5263
self.wpcomScheme = wpcomScheme
5364
self.wpcomTermsOfServiceURL = wpcomTermsOfServiceURL
65+
self.wpcomBaseURL = wpcomBaseURL
66+
self.wpcomAPIBaseURL = wpcomAPIBaseURL
5467
self.googleLoginClientId = googleLoginClientId
5568
self.googleLoginServerClientId = googleLoginServerClientId
5669
self.googleLoginScheme = googleLoginScheme
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
import Foundation
2+
import WordPressKit
3+
4+
// MARK: - This extension is needed because WordPressComOAuthClientFacade cannot access the WordPressAuthenticatorConfiguration struct.
5+
//
6+
extension WordPressComOAuthClientFacade {
7+
@objc public static func initializeOAuthClient(clientID: String, secret: String) -> WordPressComOAuthClient {
8+
return WordPressComOAuthClient(clientID: clientID,
9+
secret: secret,
10+
wordPressComBaseUrl: WordPressAuthenticator.shared.configuration.wpcomBaseURL,
11+
wordPressComApiBaseUrl: WordPressAuthenticator.shared.configuration.wpcomAPIBaseURL)
12+
}
13+
}

WordPressAuthenticator/Services/WordPressComOAuthClientFacade.m

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ - (instancetype)initWithClient:(NSString *)client secret:(NSString *)secret
2121
NSParameterAssert(secret);
2222
self = [super init];
2323
if (self) {
24-
self.client = [WordPressComOAuthClient clientWithClientID:client secret:secret];
24+
self.client = [WordPressComOAuthClientFacade initializeOAuthClientWithClientID:client secret:secret];
2525
}
2626

2727
return self;

0 commit comments

Comments
 (0)