Skip to content

Commit

Permalink
Merge branch 'develop' into main
Browse files Browse the repository at this point in the history
  • Loading branch information
sagishm committed May 3, 2023
2 parents 8ff0c4c + 5fd5508 commit 8d81563
Show file tree
Hide file tree
Showing 4 changed files with 19 additions and 6 deletions.
14 changes: 11 additions & 3 deletions GigyaSwift/Global/Providers/WebLogin/SsoLoginWrapper.swift
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ final class SsoLoginWrapper: NSObject, ProviderWrapperProtocol {
private var navigationController: UINavigationController?

private var completionHandler: ((_ jsonData: [String: Any]?, _ error: String?) -> Void)? = nil

private var pkceCode: PKCEHelper?

static let callbackURLScheme = "gsapi"
Expand Down Expand Up @@ -59,7 +59,7 @@ final class SsoLoginWrapper: NSObject, ProviderWrapperProtocol {

func login(params: [String: Any]?, viewController: UIViewController?,
completion: @escaping (_ jsonData: [String: Any]?, _ error: String?) -> Void) {

loadProvider(params: params ?? [:])

completionHandler = completion
Expand Down Expand Up @@ -87,7 +87,15 @@ final class SsoLoginWrapper: NSObject, ProviderWrapperProtocol {
requestParams["scope"] = "device_sso"
requestParams["code_challenge"] = pkceCode?.challenge ?? ""
requestParams["code_challenge_method"] = "S256"
requestParams.merge(params) { _, new in new }

let paramsMapAsJson = params.mapValues {
if let p = $0 as? [String: Any] {
return p.asJson
}
return String(describing: $0)
}

requestParams.merge(paramsMapAsJson) { _, new in new }
requestParams.removeValue(forKey: "secret")

let dataURL = URL(string: "\(urlString)?\(requestParams.asURI)")!
Expand Down
6 changes: 5 additions & 1 deletion GigyaSwift/Global/WebAuthn/OauthService.swift
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ import Foundation

class OauthService {
let businessApiService: BusinessApiServiceProtocol
var params: [String: Any] = [:]

init(businessApiService: BusinessApiServiceProtocol) {
self.businessApiService = businessApiService
Expand Down Expand Up @@ -45,7 +46,10 @@ class OauthService {

@available(iOS 13.0.0, *)
private func token<T: Codable>(continuation: CheckedContinuation<GigyaLoginResult<T>, Never>, code: String) {
self.businessApiService.send(dataType: T.self, api: GigyaDefinitions.Oauth.token, params: ["grant_type": "authorization_code", "code": code]) { [weak self] res in
var params: [String: Any] = ["grant_type": "authorization_code", "code": code]
params.merge(self.params) { _, new in new }

self.businessApiService.send(dataType: T.self, api: GigyaDefinitions.Oauth.token, params: params) { [weak self] res in
guard let self = self else { return }

switch res {
Expand Down
3 changes: 2 additions & 1 deletion GigyaSwift/Global/WebAuthn/WebAuthnService.swift
Original file line number Diff line number Diff line change
Expand Up @@ -137,11 +137,12 @@ public class WebAuthnService<T: GigyaAccountProtocol> {
// MARK: Login flow

@available(iOS 16.0.0, *)
public func login(viewController: UIViewController) async -> GigyaLoginResult<T> {
public func login(viewController: UIViewController, params: [String: Any] = [:]) async -> GigyaLoginResult<T> {
if isActiveContinuation {
return .failure(.init(error: .providerError(data: "cancelled")))
}
isActiveContinuation.toggle()
oauthService.params = params

let assertionOptions = await getAssertionOptions()

Expand Down
2 changes: 1 addition & 1 deletion GigyaSwift/Storage/Models/KeychainPasscode.swift
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ internal enum KeychainMode {
case .biometric:
return kSecAttrAccessibleWhenUnlocked
case .regular:
return kSecAttrAccessibleAlwaysThisDeviceOnly
return kSecAttrAccessibleAfterFirstUnlockThisDeviceOnly
}
}

Expand Down

0 comments on commit 8d81563

Please sign in to comment.