Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Cookies #2985

Merged
merged 2 commits into from
Jul 19, 2024
Merged

Cookies #2985

Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion Brand/NCBrand.swift
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ let userAgent: String = {
var folderDefaultAutoUpload: String = "Photos"

// Capabilities Group
var capabilitiesGroups: String = "group.it.twsweb.Crypto-Cloud"
var capabilitiesGroup: String = "group.it.twsweb.Crypto-Cloud"
var capabilitiesGroupApps: String = "group.com.nextcloud.apps"

// BRAND ONLY
Expand Down
4 changes: 2 additions & 2 deletions File Provider Extension/FileProviderData.swift
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@ class fileProviderData: NSObject {
homeServerUrl = utilityFileSystem.getHomeServer(urlBase: activeAccount.urlBase, userId: activeAccount.userId)

NCManageDatabase.shared.setCapabilities(account: account)
NextcloudKit.shared.setup(account: activeAccount.account, user: activeAccount.user, userId: activeAccount.userId, password: NCKeychain().getPassword(account: activeAccount.account), urlBase: activeAccount.urlBase, userAgent: userAgent, nextcloudVersion: NCGlobal.shared.capabilityServerVersionMajor, delegate: NCNetworking.shared)
NextcloudKit.shared.setup(account: activeAccount.account, user: activeAccount.user, userId: activeAccount.userId, password: NCKeychain().getPassword(account: activeAccount.account), urlBase: activeAccount.urlBase, userAgent: userAgent, nextcloudVersion: NCGlobal.shared.capabilityServerVersionMajor, groupIdentifier: NCBrandOptions.shared.capabilitiesGroup, delegate: NCNetworking.shared)
NCNetworking.shared.delegate = providerExtension as? NCNetworkingDelegate

return tableAccount.init(value: activeAccount)
Expand All @@ -108,7 +108,7 @@ class fileProviderData: NSObject {

NCManageDatabase.shared.setCapabilities(account: account)

NextcloudKit.shared.setup(account: activeAccount.account, user: activeAccount.user, userId: activeAccount.userId, password: NCKeychain().getPassword(account: activeAccount.account), urlBase: activeAccount.urlBase, userAgent: userAgent, nextcloudVersion: NCGlobal.shared.capabilityServerVersionMajor, delegate: NCNetworking.shared)
NextcloudKit.shared.setup(account: activeAccount.account, user: activeAccount.user, userId: activeAccount.userId, password: NCKeychain().getPassword(account: activeAccount.account), urlBase: activeAccount.urlBase, userAgent: userAgent, nextcloudVersion: NCGlobal.shared.capabilityServerVersionMajor, groupIdentifier: NCBrandOptions.shared.capabilitiesGroup, delegate: NCNetworking.shared)
NCNetworking.shared.delegate = providerExtension as? NCNetworkingDelegate

return tableAccount.init(value: activeAccount)
Expand Down
4 changes: 2 additions & 2 deletions Nextcloud.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -5754,8 +5754,8 @@
isa = XCRemoteSwiftPackageReference;
repositoryURL = "https://github.com/nextcloud/NextcloudKit";
requirement = {
kind = exactVersion;
version = 4.0.2;
branch = develop;
kind = branch;
};
};
F788ECC5263AAAF900ADC67F /* XCRemoteSwiftPackageReference "MarkdownKit" */ = {
Expand Down
2 changes: 1 addition & 1 deletion Notification Service Extension/NotificationService.swift
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ class NotificationService: UNNotificationServiceExtension {
if var json = try JSONSerialization.jsonObject(with: data) as? [String: AnyObject],
let subject = json["subject"] as? String {
bestAttemptContent.body = subject
if let pref = UserDefaults(suiteName: NCBrandOptions.shared.capabilitiesGroups) {
if let pref = UserDefaults(suiteName: NCBrandOptions.shared.capabilitiesGroup) {
json["account"] = tableAccount.account as AnyObject
pref.set(json, forKey: "NOTIFICATION_DATA")
pref.synchronize()
Expand Down
8 changes: 4 additions & 4 deletions iOSClient/AppDelegate.swift
Original file line number Diff line number Diff line change
Expand Up @@ -111,7 +111,7 @@ class AppDelegate: UIResponder, UIApplicationDelegate, UNUserNotificationCenterD
userId = activeAccount.userId
password = NCKeychain().getPassword(account: account)

NextcloudKit.shared.setup(account: account, user: user, userId: userId, password: password, urlBase: urlBase)
NextcloudKit.shared.setup(account: account, user: user, userId: userId, password: password, urlBase: urlBase, groupIdentifier: NCBrandOptions.shared.capabilitiesGroup)
NCManageDatabase.shared.setCapabilities(account: account)

NCBrandColor.shared.settingThemingColor(account: activeAccount.account)
Expand Down Expand Up @@ -287,7 +287,7 @@ class AppDelegate: UIResponder, UIApplicationDelegate, UNUserNotificationCenterD
}

func userNotificationCenter(_ center: UNUserNotificationCenter, didReceive response: UNNotificationResponse, withCompletionHandler completionHandler: @escaping () -> Void) {
if let pref = UserDefaults(suiteName: NCBrandOptions.shared.capabilitiesGroups),
if let pref = UserDefaults(suiteName: NCBrandOptions.shared.capabilitiesGroup),
let data = pref.object(forKey: "NOTIFICATION_DATA") as? [String: AnyObject] {
nextcloudPushNotificationAction(data: data)
pref.set(nil, forKey: "NOTIFICATION_DATA")
Expand Down Expand Up @@ -474,7 +474,7 @@ class AppDelegate: UIResponder, UIApplicationDelegate, UNUserNotificationCenterD
let account: String = "\(username) \(urlBase)"
let user = username

NextcloudKit.shared.setup(account: account, user: user, userId: user, password: password, urlBase: urlBase)
NextcloudKit.shared.setup(account: account, user: user, userId: user, password: password, urlBase: urlBase, groupIdentifier: NCBrandOptions.shared.capabilitiesGroup)
NextcloudKit.shared.getUserProfile { _, userProfile, _, error in

if error == .success, let userProfile {
Expand Down Expand Up @@ -520,7 +520,7 @@ class AppDelegate: UIResponder, UIApplicationDelegate, UNUserNotificationCenterD
self.userId = tableAccount.userId
self.password = NCKeychain().getPassword(account: tableAccount.account)

NextcloudKit.shared.setup(account: account, user: user, userId: userId, password: password, urlBase: urlBase)
NextcloudKit.shared.setup(account: account, user: user, userId: userId, password: password, urlBase: urlBase, groupIdentifier: NCBrandOptions.shared.capabilitiesGroup)
NCManageDatabase.shared.setCapabilities(account: account)

if let userProfile {
Expand Down
2 changes: 1 addition & 1 deletion iOSClient/Data/NCManageDatabase.swift
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ class NCManageDatabase: NSObject {
let utilityFileSystem = NCUtilityFileSystem()

override init() {
let dirGroup = FileManager.default.containerURL(forSecurityApplicationGroupIdentifier: NCBrandOptions.shared.capabilitiesGroups)
let dirGroup = FileManager.default.containerURL(forSecurityApplicationGroupIdentifier: NCBrandOptions.shared.capabilitiesGroup)
let databaseFileUrlPath = dirGroup?.appendingPathComponent(NCGlobal.shared.appDatabaseNextcloud + "/" + databaseName)

if let databaseFilePath = databaseFileUrlPath?.path {
Expand Down
2 changes: 1 addition & 1 deletion iOSClient/Login/NCLogin.swift
Original file line number Diff line number Diff line change
Expand Up @@ -436,7 +436,7 @@ class NCLogin: UIViewController, UITextFieldDelegate, NCLoginQRCodeDelegate {
let urlBase = url
let account = user + " " + user

NextcloudKit.shared.setup(account: account, user: user, userId: user, password: password, urlBase: urlBase)
NextcloudKit.shared.setup(account: account, user: user, userId: user, password: password, urlBase: urlBase, groupIdentifier: NCBrandOptions.shared.capabilitiesGroup)
NextcloudKit.shared.getUserProfile { _, userProfile, _, error in

if error == .success, let userProfile {
Expand Down
2 changes: 1 addition & 1 deletion iOSClient/Login/NCLoginProvider.swift
Original file line number Diff line number Diff line change
Expand Up @@ -168,7 +168,7 @@ extension NCLoginProvider: WKNavigationDelegate {
let account: String = "\(username) \(urlBase)"
let user = username

NextcloudKit.shared.setup(account: account, user: user, userId: user, password: password, urlBase: urlBase)
NextcloudKit.shared.setup(account: account, user: user, userId: user, password: password, urlBase: urlBase, groupIdentifier: NCBrandOptions.shared.capabilitiesGroup)
NextcloudKit.shared.getUserProfile { _, userProfile, _, error in

if error == .success, let userProfile {
Expand Down
7 changes: 6 additions & 1 deletion iOSClient/Networking/NCNetworking.swift
Original file line number Diff line number Diff line change
Expand Up @@ -109,7 +109,9 @@ class NCNetworking: NSObject, NKCommonDelegate {
configuration.isDiscretionary = false
configuration.httpMaximumConnectionsPerHost = sessionMaximumConnectionsPerHost
configuration.requestCachePolicy = NSURLRequest.CachePolicy.reloadIgnoringLocalCacheData
configuration.httpCookieStorage = HTTPCookieStorage.sharedCookieStorage(forGroupContainerIdentifier: NCBrandOptions.shared.capabilitiesGroup)
let session = URLSession(configuration: configuration, delegate: nkBackground, delegateQueue: OperationQueue.main)

return session
}()

Expand All @@ -120,6 +122,7 @@ class NCNetworking: NSObject, NKCommonDelegate {
configuration.isDiscretionary = false
configuration.httpMaximumConnectionsPerHost = sessionMaximumConnectionsPerHost
configuration.requestCachePolicy = NSURLRequest.CachePolicy.reloadIgnoringLocalCacheData
configuration.httpCookieStorage = HTTPCookieStorage.sharedCookieStorage(forGroupContainerIdentifier: NCBrandOptions.shared.capabilitiesGroup)
let session = URLSession(configuration: configuration, delegate: nkBackground, delegateQueue: OperationQueue.main)
return session
}()
Expand All @@ -131,6 +134,7 @@ class NCNetworking: NSObject, NKCommonDelegate {
configuration.isDiscretionary = false
configuration.httpMaximumConnectionsPerHost = sessionMaximumConnectionsPerHost
configuration.requestCachePolicy = NSURLRequest.CachePolicy.reloadIgnoringLocalCacheData
configuration.httpCookieStorage = HTTPCookieStorage.sharedCookieStorage(forGroupContainerIdentifier: NCBrandOptions.shared.capabilitiesGroup)
let session = URLSession(configuration: configuration, delegate: nkBackground, delegateQueue: OperationQueue.main)
return session
}()
Expand All @@ -142,7 +146,8 @@ class NCNetworking: NSObject, NKCommonDelegate {
configuration.isDiscretionary = false
configuration.httpMaximumConnectionsPerHost = sessionMaximumConnectionsPerHost
configuration.requestCachePolicy = NSURLRequest.CachePolicy.reloadIgnoringLocalCacheData
configuration.sharedContainerIdentifier = NCBrandOptions.shared.capabilitiesGroups
configuration.sharedContainerIdentifier = NCBrandOptions.shared.capabilitiesGroup
configuration.httpCookieStorage = HTTPCookieStorage.sharedCookieStorage(forGroupContainerIdentifier: NCBrandOptions.shared.capabilitiesGroup)
let session = URLSession(configuration: configuration, delegate: nkBackground, delegateQueue: OperationQueue.main)
return session
}()
Expand Down
Binary file modified iOSClient/Supporting Files/sl.lproj/Localizable.strings
Binary file not shown.
12 changes: 6 additions & 6 deletions iOSClient/Utility/NCUtilityFileSystem.swift
Original file line number Diff line number Diff line change
Expand Up @@ -28,13 +28,13 @@ import PhotosUI
class NCUtilityFileSystem: NSObject {
let fileManager = FileManager.default
var directoryGroup: String {
return fileManager.containerURL(forSecurityApplicationGroupIdentifier: NCBrandOptions.shared.capabilitiesGroups)?.path ?? ""
return fileManager.containerURL(forSecurityApplicationGroupIdentifier: NCBrandOptions.shared.capabilitiesGroup)?.path ?? ""
}
var directoryDocuments: String {
return NSSearchPathForDirectoriesInDomains(.documentDirectory, .userDomainMask, true).first ?? ""
}
var directoryCertificates: String {
guard let directoryGroup = fileManager.containerURL(forSecurityApplicationGroupIdentifier: NCBrandOptions.shared.capabilitiesGroups) else { return "" }
guard let directoryGroup = fileManager.containerURL(forSecurityApplicationGroupIdentifier: NCBrandOptions.shared.capabilitiesGroup) else { return "" }
let path = directoryGroup.appendingPathComponent(NCGlobal.shared.appCertificates).path
if !fileManager.fileExists(atPath: path) {
do {
Expand All @@ -44,7 +44,7 @@ class NCUtilityFileSystem: NSObject {
return path
}
var directoryUserData: String {
guard let directoryGroup = fileManager.containerURL(forSecurityApplicationGroupIdentifier: NCBrandOptions.shared.capabilitiesGroups) else { return "" }
guard let directoryGroup = fileManager.containerURL(forSecurityApplicationGroupIdentifier: NCBrandOptions.shared.capabilitiesGroup) else { return "" }
let path = directoryGroup.appendingPathComponent(NCGlobal.shared.appUserData).path
if !fileManager.fileExists(atPath: path) {
do {
Expand All @@ -54,7 +54,7 @@ class NCUtilityFileSystem: NSObject {
return path
}
var directoryScan: String {
guard let directoryGroup = fileManager.containerURL(forSecurityApplicationGroupIdentifier: NCBrandOptions.shared.capabilitiesGroups) else { return "" }
guard let directoryGroup = fileManager.containerURL(forSecurityApplicationGroupIdentifier: NCBrandOptions.shared.capabilitiesGroup) else { return "" }
let path = directoryGroup.appendingPathComponent(NCGlobal.shared.appScan).path
if !fileManager.fileExists(atPath: path) {
do {
Expand All @@ -64,7 +64,7 @@ class NCUtilityFileSystem: NSObject {
return path
}
var directoryProviderStorage: String {
guard let directoryGroup = fileManager.containerURL(forSecurityApplicationGroupIdentifier: NCBrandOptions.shared.capabilitiesGroups) else { return "" }
guard let directoryGroup = fileManager.containerURL(forSecurityApplicationGroupIdentifier: NCBrandOptions.shared.capabilitiesGroup) else { return "" }
let path = directoryGroup.appendingPathComponent(NCGlobal.shared.directoryProviderStorage).path
if !fileManager.fileExists(atPath: path) {
do {
Expand Down Expand Up @@ -151,7 +151,7 @@ class NCUtilityFileSystem: NSObject {
}

func createDirectoryStandard() {
guard let directoryGroup = fileManager.containerURL(forSecurityApplicationGroupIdentifier: NCBrandOptions.shared.capabilitiesGroups)?.path else { return }
guard let directoryGroup = fileManager.containerURL(forSecurityApplicationGroupIdentifier: NCBrandOptions.shared.capabilitiesGroup)?.path else { return }
if !fileManager.fileExists(atPath: directoryDocuments) { try? fileManager.createDirectory(atPath: directoryDocuments, withIntermediateDirectories: true) }
let appDatabaseNextcloud = directoryGroup + "/" + NCGlobal.shared.appDatabaseNextcloud
if !fileManager.fileExists(atPath: appDatabaseNextcloud) { try? fileManager.createDirectory(atPath: appDatabaseNextcloud, withIntermediateDirectories: true) }
Expand Down
Loading