diff --git a/.gitmodules b/.gitmodules index 00119eb2..eb454ac8 100644 --- a/.gitmodules +++ b/.gitmodules @@ -1,4 +1,5 @@ [submodule "ios-sdk"] path = ios-sdk - #url = https://github.com/opencloud-eu/ios-sdk.git - url = ../ios-sdk.git + url = https://github.com/gpongelli/opencloud-ios-sdk.git + #url = ../ios-sdk.git + branch = custom-claim \ No newline at end of file diff --git a/OpenCloud/Bookmarks/Composer/BookmarkComposer.swift b/OpenCloud/Bookmarks/Composer/BookmarkComposer.swift index df97b568..63757c31 100644 --- a/OpenCloud/Bookmarks/Composer/BookmarkComposer.swift +++ b/OpenCloud/Bookmarks/Composer/BookmarkComposer.swift @@ -77,6 +77,9 @@ class BookmarkComposer: NSObject { } func instantiateConnection(for bmark: OCBookmark) -> OCConnection { + let customScopes = (OCAppIdentity.shared.userDefaults! as UserDefaults).object(forKey:"oidc-custom-scopes") + bmark.customOIDCScopes = customScopes as? String + let connection = OCConnection(bookmark: bmark) connection.hostSimulator = OCHostSimulatorManager.shared.hostSimulator(forLocation: .accountSetup, for: self) diff --git a/OpenCloud/Resources/Localizable.xcstrings b/OpenCloud/Resources/Localizable.xcstrings index bcd6027d..9d78f4dd 100644 --- a/OpenCloud/Resources/Localizable.xcstrings +++ b/OpenCloud/Resources/Localizable.xcstrings @@ -510,6 +510,9 @@ }, "Credentials" : { + }, + "Custom OIDC scopes to be appended to fixed ones." : { + }, "Cut" : { @@ -1240,6 +1243,12 @@ }, "Offline files use" : { + }, + "OIDC Scopes" : { + + }, + "OIDC settings" : { + }, "OK" : { diff --git a/OpenCloud/Settings/OIDCSettingsSection.swift b/OpenCloud/Settings/OIDCSettingsSection.swift new file mode 100644 index 00000000..f4ed9b19 --- /dev/null +++ b/OpenCloud/Settings/OIDCSettingsSection.swift @@ -0,0 +1,39 @@ +// +// OIDCSettingsSection.swift +// OpenCloud +// +// Created by Gabriele Pongelli on 26.12.2025. +// +// + +/* + * Copyright (C) 2025, Gabriele Pongelli. + * + * This code is covered by the GNU Public License Version 3. + * + * For distribution utilizing Apple mechanisms please see https://opencloud.eu/contribute/iOS-license-exception/ + * You should have received a copy of this license along with this program. If not, see . + * + */ + +import UIKit +import OpenCloudSDK +import OpenCloudApp +import OpenCloudAppShared + +class OIDCSettingsSection: SettingsSection { + override init(userDefaults: UserDefaults) { + super.init(userDefaults: userDefaults) + + self.headerTitle = OCLocalizedString("OIDC settings", nil) + + self.add(row: StaticTableViewRow(rowWithAction: { (_, _) in + }, title: OCLocalizedString("OIDC Scopes", nil), subtitle: OCLocalizedString("Custom OIDC scopes to be appended to fixed ones.", nil))) + + self.add(row: StaticTableViewRow(textFieldWithAction: { (row, _, _) in + if let oidcScopes = row.value as? String { + DisplaySettings.shared.oidcCustomScopes = oidcScopes as NSString + } + }, placeholder: "Custom OIDC scopes", value: DisplaySettings.shared.oidcCustomScopes as String, autocorrectionType: UITextAutocorrectionType.no, identifier: "oidc-string")) + } +} diff --git a/OpenCloud/Settings/SettingsViewController.swift b/OpenCloud/Settings/SettingsViewController.swift index eb0f1369..9266a3eb 100644 --- a/OpenCloud/Settings/SettingsViewController.swift +++ b/OpenCloud/Settings/SettingsViewController.swift @@ -47,6 +47,7 @@ class SettingsViewController: StaticTableViewController { self.addSection(UserInterfaceSettingsSection(userDefaults: userDefaults)) self.addSection(DataSettingsSection(userDefaults: userDefaults)) self.addSection(DisplaySettingsSection(userDefaults: userDefaults)) + self.addSection(OIDCSettingsSection(userDefaults: userDefaults)) self.addSection(MediaFilesSettingsSection(userDefaults: userDefaults)) #if !DISABLE_APPSTORE_LICENSING diff --git a/OpenCloudAppFramework/Display Settings/DisplaySettings.h b/OpenCloudAppFramework/Display Settings/DisplaySettings.h index 3d2819d4..87ecb8e3 100644 --- a/OpenCloudAppFramework/Display Settings/DisplaySettings.h +++ b/OpenCloudAppFramework/Display Settings/DisplaySettings.h @@ -35,6 +35,9 @@ NS_ASSUME_NONNULL_BEGIN #pragma mark - Drag files @property(assign,nonatomic) BOOL preventDraggingFiles; +#pragma mark - OIDC Scopes +@property(assign,nonatomic) NSString *oidcCustomScopes; + #pragma mark - Query condition @property(nonatomic,readonly,nullable) OCQueryCondition *queryConditionForDisplaySettings; @@ -46,6 +49,7 @@ NS_ASSUME_NONNULL_BEGIN extern NSString *DisplaySettingsShowHiddenFilesPrefsKey; //!< The UserDefaults Key containing the BOOL value for .showHiddenFiles extern NSString *DisplaySettingsSortFoldersFirstPrefsKey; //!< The UserDefaults Key containing the BOOL value for .sortFoldersFirst extern NSString *DisplaySettingsPreventDraggingFilesPrefsKey; //!< The UserDefaults Key containing the BOOL value for .preventDraggingFiles +extern NSString *DisplaySettingsOIDCCustomScopesPrefsKey; //!< The UserDefaults Key containing the BOOL value for .oidcCustomScopes extern OCIPCNotificationName OCIPCNotificationNameDisplaySettingsChanged; //!< Posted when display settings changed (internal use only) extern NSNotificationName DisplaySettingsChanged; //!< Posted when display settings changed (for use by app + File Provider) @@ -54,5 +58,6 @@ extern OCClassSettingsIdentifier OCClassSettingsIdentifierDisplay; //!< The cl extern OCClassSettingsKey OCClassSettingsKeyDisplayShowHiddenFiles; //!< The class settings key for Show Hidden Files extern OCClassSettingsKey OCClassSettingsKeyDisplaySortFoldersFirst; //!< The class settings key for sorting folders first extern OCClassSettingsKey OCClassSettingsKeyDisplayPreventDraggingFiles; //!< The class settings key if Drag Files is enabled +extern OCClassSettingsKey OCClassSettingsKeyCustomOidcScopes; //!< The class settings key for custom OIDC scopes NS_ASSUME_NONNULL_END diff --git a/OpenCloudAppFramework/Display Settings/DisplaySettings.m b/OpenCloudAppFramework/Display Settings/DisplaySettings.m index ef2903b2..91f881be 100644 --- a/OpenCloudAppFramework/Display Settings/DisplaySettings.m +++ b/OpenCloudAppFramework/Display Settings/DisplaySettings.m @@ -89,6 +89,7 @@ - (instancetype)init _showHiddenFiles = [self _showHiddenFilesValue]; _sortFoldersFirst = [self _sortFoldersFirst]; _preventDraggingFiles = [self _preventDraggingFilesValue]; + _oidcCustomScopes = [self _oidcCustomScopesValue]; } return (self); @@ -114,6 +115,10 @@ - (void)_handleDisplaySettingsChanged _preventDraggingFiles = [self _preventDraggingFilesValue]; [self didChangeValueForKey:@"preventDraggingFiles"]; + [self willChangeValueForKey:@"oidcCustomScopes"]; + _oidcCustomScopes = [self _oidcCustomScopesValue]; + [self didChangeValueForKey:@"oidcCustomScopes"]; + [[NSNotificationCenter defaultCenter] postNotificationName:DisplaySettingsChanged object:self]; } @@ -189,6 +194,29 @@ - (void)setPreventDraggingFiles:(BOOL)preventDraggingFiles [self postChangeNotifications]; } + +#pragma mark - OIDC Custom Scopes +- (NSString*)_oidcCustomScopesValue +{ + NSString *oidcScopes; + + if ((oidcScopes = [OCAppIdentity.sharedAppIdentity.userDefaults objectForKey:DisplaySettingsOIDCCustomScopesPrefsKey]) != nil) + { + return oidcScopes; + } + + return ([self classSettingForOCClassSettingsKey:OCClassSettingsKeyCustomOidcScopes]); +} + +- (void)setOidcCustomScopes:(NSString*)oidcCustomScopes +{ + _oidcCustomScopes = oidcCustomScopes; + + [OCAppIdentity.sharedAppIdentity.userDefaults setValue:oidcCustomScopes forKey:DisplaySettingsOIDCCustomScopesPrefsKey]; + + [self postChangeNotifications]; +} + #pragma mark - Query updating - (void)updateQueryWithDisplaySettings:(OCQuery *)query { @@ -243,6 +271,7 @@ - (BOOL)query:(OCQuery *)query shouldIncludeItem:(OCItem *)item NSString *DisplaySettingsShowHiddenFilesPrefsKey = @"display-show-hidden-files"; NSString *DisplaySettingsSortFoldersFirstPrefsKey = @"display-sort-folders-first"; NSString *DisplaySettingsPreventDraggingFilesPrefsKey = @"display-prevent-dragging-files"; +NSString *DisplaySettingsOIDCCustomScopesPrefsKey = @"oidc-custom-scopes"; OCIPCNotificationName OCIPCNotificationNameDisplaySettingsChanged = @"org.opencloud.display-settings-changed"; @@ -252,3 +281,4 @@ - (BOOL)query:(OCQuery *)query shouldIncludeItem:(OCItem *)item OCClassSettingsKey OCClassSettingsKeyDisplayShowHiddenFiles = @"show-hidden-files"; OCClassSettingsKey OCClassSettingsKeyDisplaySortFoldersFirst = @"sort-folders-first"; OCClassSettingsKey OCClassSettingsKeyDisplayPreventDraggingFiles = @"prevent-dragging-files"; +OCClassSettingsKey OCClassSettingsKeyCustomOidcScopes = @"custom-scopes";