Skip to content

Example extensibility use cases #7

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

Merged
merged 15 commits into from
Apr 23, 2025
27 changes: 0 additions & 27 deletions Resources/Assets.xcassets/AccentColor.colorset/Contents.json
Original file line number Diff line number Diff line change
@@ -1,33 +1,6 @@
{
"colors" : [
{
"color" : {
"color-space" : "srgb",
"components" : {
"alpha" : "1.000",
"blue" : "1.000",
"green" : "1.000",
"red" : "1.000"
}
},
"idiom" : "universal"
},
{
"appearances" : [
{
"appearance" : "luminosity",
"value" : "dark"
}
],
"color" : {
"color-space" : "srgb",
"components" : {
"alpha" : "1.000",
"blue" : "1.000",
"green" : "1.000",
"red" : "1.000"
}
},
"idiom" : "universal"
}
],
Expand Down
40 changes: 39 additions & 1 deletion haapidemo.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,10 @@
objects = {

/* Begin PBXBuildFile section */
2827D6FC2DA3CEAE004E0B43 /* CustomViewControllerFactory.swift in Sources */ = {isa = PBXBuildFile; fileRef = 2827D6FB2DA3CEAA004E0B43 /* CustomViewControllerFactory.swift */; };
2827D6FE2DA3D90C004E0B43 /* CustomDataMapper.swift in Sources */ = {isa = PBXBuildFile; fileRef = 2827D6FD2DA3D904004E0B43 /* CustomDataMapper.swift */; };
2827D7042DA3E6E3004E0B43 /* HtmlFormLoginViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 2827D7032DA3E6DB004E0B43 /* HtmlFormLoginViewController.swift */; };
2827D7062DA3E707004E0B43 /* HtmlFormLoginModel.swift in Sources */ = {isa = PBXBuildFile; fileRef = 2827D7052DA3E707004E0B43 /* HtmlFormLoginModel.swift */; };
282A70EA2A5D694C000AE4FD /* DemoApp.swift in Sources */ = {isa = PBXBuildFile; fileRef = 282A70E92A5D694C000AE4FD /* DemoApp.swift */; };
282A70EC2A5D694C000AE4FD /* UnauthenticatedView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 282A70EB2A5D694C000AE4FD /* UnauthenticatedView.swift */; };
282A70EE2A5D694E000AE4FD /* Assets.xcassets in Resources */ = {isa = PBXBuildFile; fileRef = 282A70ED2A5D694E000AE4FD /* Assets.xcassets */; };
Expand All @@ -28,6 +32,9 @@
28C9FD7E2A65405500902F08 /* ErrorView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 28C9FD7D2A65405500902F08 /* ErrorView.swift */; };
28C9FD842A655ED400902F08 /* ApplicationError.swift in Sources */ = {isa = PBXBuildFile; fileRef = 28C9FD832A655ED400902F08 /* ApplicationError.swift */; };
28C9FD862A657A2700902F08 /* Configuration.swift in Sources */ = {isa = PBXBuildFile; fileRef = 28C9FD852A657A2700902F08 /* Configuration.swift */; };
28FAF29E2DA5451C00A85932 /* AuthenticationSelectionViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 28FAF29D2DA544FF00A85932 /* AuthenticationSelectionViewController.swift */; };
28FAF2A02DA57B0D00A85932 /* AuthenticationSelectorButton.swift in Sources */ = {isa = PBXBuildFile; fileRef = 28FAF29F2DA57B0900A85932 /* AuthenticationSelectorButton.swift */; };
28FAF2A52DA58BE000A85932 /* AuthenticationSelectorLabel.swift in Sources */ = {isa = PBXBuildFile; fileRef = 28FAF2A42DA58BE000A85932 /* AuthenticationSelectorLabel.swift */; };
/* End PBXBuildFile section */

/* Begin PBXCopyFilesBuildPhase section */
Expand All @@ -44,6 +51,10 @@
/* End PBXCopyFilesBuildPhase section */

/* Begin PBXFileReference section */
2827D6FB2DA3CEAA004E0B43 /* CustomViewControllerFactory.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = CustomViewControllerFactory.swift; sourceTree = "<group>"; };
2827D6FD2DA3D904004E0B43 /* CustomDataMapper.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = CustomDataMapper.swift; sourceTree = "<group>"; };
2827D7032DA3E6DB004E0B43 /* HtmlFormLoginViewController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = HtmlFormLoginViewController.swift; sourceTree = "<group>"; };
2827D7052DA3E707004E0B43 /* HtmlFormLoginModel.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = HtmlFormLoginModel.swift; sourceTree = "<group>"; };
282A70E62A5D694C000AE4FD /* haapidemo.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = haapidemo.app; sourceTree = BUILT_PRODUCTS_DIR; };
282A70E92A5D694C000AE4FD /* DemoApp.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = DemoApp.swift; sourceTree = "<group>"; };
282A70EB2A5D694C000AE4FD /* UnauthenticatedView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = UnauthenticatedView.swift; sourceTree = "<group>"; };
Expand All @@ -67,6 +78,9 @@
28C9FD7D2A65405500902F08 /* ErrorView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ErrorView.swift; sourceTree = "<group>"; };
28C9FD832A655ED400902F08 /* ApplicationError.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ApplicationError.swift; sourceTree = "<group>"; };
28C9FD852A657A2700902F08 /* Configuration.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = Configuration.swift; sourceTree = "<group>"; };
28FAF29D2DA544FF00A85932 /* AuthenticationSelectionViewController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = AuthenticationSelectionViewController.swift; sourceTree = "<group>"; };
28FAF29F2DA57B0900A85932 /* AuthenticationSelectorButton.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = AuthenticationSelectorButton.swift; sourceTree = "<group>"; };
28FAF2A42DA58BE000A85932 /* AuthenticationSelectorLabel.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = AuthenticationSelectorLabel.swift; sourceTree = "<group>"; };
/* End PBXFileReference section */

/* Begin PBXFrameworksBuildPhase section */
Expand All @@ -81,6 +95,20 @@
/* End PBXFrameworksBuildPhase section */

/* Begin PBXGroup section */
2827D6FA2DA3CE9B004E0B43 /* Extensibility */ = {
isa = PBXGroup;
children = (
2827D6FD2DA3D904004E0B43 /* CustomDataMapper.swift */,
2827D6FB2DA3CEAA004E0B43 /* CustomViewControllerFactory.swift */,
28FAF29D2DA544FF00A85932 /* AuthenticationSelectionViewController.swift */,
28FAF29F2DA57B0900A85932 /* AuthenticationSelectorButton.swift */,
28FAF2A42DA58BE000A85932 /* AuthenticationSelectorLabel.swift */,
2827D7052DA3E707004E0B43 /* HtmlFormLoginModel.swift */,
2827D7032DA3E6DB004E0B43 /* HtmlFormLoginViewController.swift */,
);
path = Extensibility;
sourceTree = "<group>";
};
282A70DD2A5D694C000AE4FD = {
isa = PBXGroup;
children = (
Expand All @@ -106,6 +134,7 @@
28C9FD852A657A2700902F08 /* Configuration.swift */,
282A70E92A5D694C000AE4FD /* DemoApp.swift */,
282A70F72A5D6A81000AE4FD /* DemoAppDelegate.swift */,
2827D6FA2DA3CE9B004E0B43 /* Extensibility */,
287EE0D62A6AED0100B628F1 /* Models */,
28C9FD632A6526D400902F08 /* Views */,
28C9FD692A65271D00902F08 /* Utilities */,
Expand Down Expand Up @@ -190,7 +219,7 @@
attributes = {
BuildIndependentTargetsInParallel = 1;
LastSwiftUpdateCheck = 1430;
LastUpgradeCheck = 1430;
LastUpgradeCheck = 1630;
TargetAttributes = {
282A70E52A5D694C000AE4FD = {
CreatedOnToolsVersion = 14.3.1;
Expand Down Expand Up @@ -236,6 +265,7 @@
isa = PBXSourcesBuildPhase;
buildActionMask = 2147483647;
files = (
2827D6FE2DA3D90C004E0B43 /* CustomDataMapper.swift in Sources */,
287EE0D12A6AE6F000B628F1 /* UserInfoModel.swift in Sources */,
28C9FD842A655ED400902F08 /* ApplicationError.swift in Sources */,
28C9FD752A65391C00902F08 /* CustomButtonStyle.swift in Sources */,
Expand All @@ -245,12 +275,18 @@
28C9FD6B2A65278800902F08 /* MainView.swift in Sources */,
287EE0D32A6AE6FF00B628F1 /* AccessTokenModel.swift in Sources */,
282A70F82A5D6A81000AE4FD /* DemoAppDelegate.swift in Sources */,
28FAF29E2DA5451C00A85932 /* AuthenticationSelectionViewController.swift in Sources */,
28C9FD7E2A65405500902F08 /* ErrorView.swift in Sources */,
28C9FD712A6537D900902F08 /* TextStyles.swift in Sources */,
287EE0D52A6AE8FE00B628F1 /* UserInfoView.swift in Sources */,
28FAF2A52DA58BE000A85932 /* AuthenticationSelectorLabel.swift in Sources */,
2827D6FC2DA3CEAE004E0B43 /* CustomViewControllerFactory.swift in Sources */,
282A70FD2A5D7664000AE4FD /* TrustAllCertsDelegate.swift in Sources */,
2827D7042DA3E6E3004E0B43 /* HtmlFormLoginViewController.swift in Sources */,
28FAF2A02DA57B0D00A85932 /* AuthenticationSelectorButton.swift in Sources */,
287EE0CB2A6AAE3500B628F1 /* ExpanderView.swift in Sources */,
282A70EC2A5D694C000AE4FD /* UnauthenticatedView.swift in Sources */,
2827D7062DA3E707004E0B43 /* HtmlFormLoginModel.swift in Sources */,
287EE0D82A6AED8B00B628F1 /* AccessTokenView.swift in Sources */,
282A70EA2A5D694C000AE4FD /* DemoApp.swift in Sources */,
);
Expand Down Expand Up @@ -295,6 +331,7 @@
DEBUG_INFORMATION_FORMAT = dwarf;
ENABLE_STRICT_OBJC_MSGSEND = YES;
ENABLE_TESTABILITY = YES;
ENABLE_USER_SCRIPT_SANDBOXING = YES;
GCC_C_LANGUAGE_STANDARD = gnu11;
GCC_DYNAMIC_NO_PIC = NO;
GCC_NO_COMMON_BLOCKS = YES;
Expand Down Expand Up @@ -355,6 +392,7 @@
DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym";
ENABLE_NS_ASSERTIONS = NO;
ENABLE_STRICT_OBJC_MSGSEND = YES;
ENABLE_USER_SCRIPT_SANDBOXING = YES;
GCC_C_LANGUAGE_STANDARD = gnu11;
GCC_NO_COMMON_BLOCKS = YES;
GCC_WARN_64_TO_32_BIT_CONVERSION = YES;
Expand Down
78 changes: 78 additions & 0 deletions haapidemo.xcodeproj/xcshareddata/xcschemes/haapidemo.xcscheme
Original file line number Diff line number Diff line change
@@ -0,0 +1,78 @@
<?xml version="1.0" encoding="UTF-8"?>
<Scheme
LastUpgradeVersion = "1630"
version = "1.7">
<BuildAction
parallelizeBuildables = "YES"
buildImplicitDependencies = "YES"
buildArchitectures = "Automatic">
<BuildActionEntries>
<BuildActionEntry
buildForTesting = "YES"
buildForRunning = "YES"
buildForProfiling = "YES"
buildForArchiving = "YES"
buildForAnalyzing = "YES">
<BuildableReference
BuildableIdentifier = "primary"
BlueprintIdentifier = "282A70E52A5D694C000AE4FD"
BuildableName = "haapidemo.app"
BlueprintName = "haapidemo"
ReferencedContainer = "container:haapidemo.xcodeproj">
</BuildableReference>
</BuildActionEntry>
</BuildActionEntries>
</BuildAction>
<TestAction
buildConfiguration = "Debug"
selectedDebuggerIdentifier = "Xcode.DebuggerFoundation.Debugger.LLDB"
selectedLauncherIdentifier = "Xcode.DebuggerFoundation.Launcher.LLDB"
shouldUseLaunchSchemeArgsEnv = "YES"
shouldAutocreateTestPlan = "YES">
</TestAction>
<LaunchAction
buildConfiguration = "Debug"
selectedDebuggerIdentifier = "Xcode.DebuggerFoundation.Debugger.LLDB"
selectedLauncherIdentifier = "Xcode.DebuggerFoundation.Launcher.LLDB"
launchStyle = "0"
useCustomWorkingDirectory = "NO"
ignoresPersistentStateOnLaunch = "NO"
debugDocumentVersioning = "YES"
debugServiceExtension = "internal"
allowLocationSimulation = "YES">
<BuildableProductRunnable
runnableDebuggingMode = "0">
<BuildableReference
BuildableIdentifier = "primary"
BlueprintIdentifier = "282A70E52A5D694C000AE4FD"
BuildableName = "haapidemo.app"
BlueprintName = "haapidemo"
ReferencedContainer = "container:haapidemo.xcodeproj">
</BuildableReference>
</BuildableProductRunnable>
</LaunchAction>
<ProfileAction
buildConfiguration = "Release"
shouldUseLaunchSchemeArgsEnv = "YES"
savedToolIdentifier = ""
useCustomWorkingDirectory = "NO"
debugDocumentVersioning = "YES">
<BuildableProductRunnable
runnableDebuggingMode = "0">
<BuildableReference
BuildableIdentifier = "primary"
BlueprintIdentifier = "282A70E52A5D694C000AE4FD"
BuildableName = "haapidemo.app"
BlueprintName = "haapidemo"
ReferencedContainer = "container:haapidemo.xcodeproj">
</BuildableReference>
</BuildableProductRunnable>
</ProfileAction>
<AnalyzeAction
buildConfiguration = "Debug">
</AnalyzeAction>
<ArchiveAction
buildConfiguration = "Release"
revealArchiveInOrganizer = "YES">
</ArchiveAction>
</Scheme>
2 changes: 1 addition & 1 deletion info.plist
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
<key>CFBundleTypeRole</key>
<string>Viewer</string>
<key>CFBundleURLName</key>
<string>io.curity.haapi</string>
<string>io.curity.haapidemo</string>
<key>CFBundleURLSchemes</key>
<array>
<string>haapi</string>
Expand Down
16 changes: 16 additions & 0 deletions src/Configuration.swift
Original file line number Diff line number Diff line change
@@ -1,3 +1,19 @@
//
// Copyright (C) 2023 Curity AB.
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
//

import Foundation

struct Configuration {
Expand Down
22 changes: 17 additions & 5 deletions src/DemoAppDelegate.swift
Original file line number Diff line number Diff line change
Expand Up @@ -24,10 +24,10 @@ class DemoAppDelegate: NSObject, UIApplicationDelegate {

func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]?) -> Bool {

HaapiLogger.followUpTags = DriverFollowUpTag.allCases + SdkFollowUpTag.allCases + UIKitFollowUpTag.allCases
// HaapiLogger.followUpTags = DriverFollowUpTag.allCases + SdkFollowUpTag.allCases + UIKitFollowUpTag.allCases

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

commented code... perhaps leftovers from testing

HaapiLogger.isInfoEnabled = true
HaapiLogger.isDebugEnabled = false

// The base configuration
let builder = HaapiUIKitConfigurationBuilder(clientId: Configuration.clientId,
baseUrl: Configuration.baseURL,
tokenEndpointUrl: Configuration.tokenEndpointURL,
Expand All @@ -43,6 +43,7 @@ class DemoAppDelegate: NSObject, UIApplicationDelegate {
.setPresentationMode(mode: PresentationMode.modal)
.setShouldAutoHandleFlowErrorFeedback(value: false)

// If you run into particular iOS devices that do not support attestation you can activate DCR fallback
if Configuration.dcrTemplateClientId != nil {

builder.setClientAuthenticationMethod(method: ClientAuthenticationMethodSecret(secret: Configuration.deviceSecret!))
Expand All @@ -53,10 +54,21 @@ class DemoAppDelegate: NSObject, UIApplicationDelegate {
}

let haapiUIKitConfiguration = builder.build()

// Create extensibility objects to override model data or view logic
let dataMapper = CustomDataMapper()
let viewFactory = CustomViewControllerFactory()
let resolver = ViewControllerFactoryRegistry()
.registerViewControllerFactoryFormModel(factory: viewFactory.createFormViewController)
.registerViewControllerFactorySelectorModel(factory: viewFactory.createSelectorViewController)

self.haapiUIKitApplication = HaapiUIKitApplicationBuilder(haapiUIKitConfiguration: haapiUIKitConfiguration)
.setThemingPlistFileName("CustomTheme")
.build()
// Create the application
try! self.haapiUIKitApplication = HaapiUIKitApplicationBuilder(
haapiUIKitConfiguration: haapiUIKitConfiguration)
.setThemingPlistFileName("CustomTheme")
.setDataMapper(dataMapper)
.setViewControllerFactoryRegistry(registry: resolver)
.buildOrThrow()

self.oauthState = OAuthStateModel()
return true
Expand Down
Loading