okta / okta-oidc-xamarin

Okta OIDC SDK for Xamarin
https://github.com/okta/okta-oidc-xamarin
Apache License 2.0
10 stars 11 forks source link

iOS SignOutAsync() doesn't close Safari window or trigger Logout event #72

Closed kensykora closed 2 years ago

kensykora commented 3 years ago

In attempting to work around #71 I downloaded the sample app (https://github.com/okta/samples-xamarin) and did the following changes:

After doing this, I was able to get the app to compile and run on a simulator (After adding my own bundle ID and Okta plist).

Current behavior

When trying to logout with the Okta.Xamarin.ViewModels.SignOutCommand I noticed that the web view doesn't ever close. There is a close button that can manually be tapped, but doing so doesn't trigger the OktaContext.Current.SignOutCompleted event, so sign outs don't occur.

public Command Logout => new Okta.Xamarin.ViewModels.SignOutCommand();

Trying to work around this by calling signout directly produces the exact same behavior

public Command Logout => new Command(async () => await SignOut()); //new SignOutCommand();

private async Task SignOut()
{
    await OktaContext.Current.SignOutAsync();
}

I am also able to reproduce this in my own app.

Expected behavior

Safari web view is automatically closed and the sign out event is triggered

Minimal reproduction of the problem with instructions

See https://github.com/kensykora/samples-xamarin/commit/be88dea49f1e6656aa2ad591559bae845db50e62

2021-11-03 18 03 46

Environment

Nuget Packages:

macOS Big Sur 11.4, Mac Mini, M1 2020 XCode 13.1

Experienced on iOS SImulator iPhone 13 running iOS 15.0

Build Environment

Visual Studio Community 2019 for Mac
Version 8.10.12 (build 16)
Installation UUID: d226ec8f-b62a-43bd-b2f0-ee1f4f6a79a5
    GTK+ 2.24.23 (Raleigh theme)
    Xamarin.Mac 6.18.0.23 (d16-6 / 088c73638)

    Package version: 612000140

Mono Framework MDK
Runtime:
    Mono 6.12.0.140 (2020-02/51d876a041e) (64-bit)
    Package version: 612000140

Roslyn (Language Service)
3.10.0-4.21269.26+029847714208ebe49668667c60ea5b0a294e0fcb

NuGet
Version: 5.9.0.7134

.NET Core SDK
SDK: /usr/local/share/dotnet/sdk/5.0.402/Sdks
SDK Versions:
    5.0.402
    3.1.414
MSBuild SDKs: /Applications/Visual Studio.app/Contents/Resources/lib/monodevelop/bin/MSBuild/Current/bin/Sdks

.NET Core Runtime
Runtime: /usr/local/share/dotnet/dotnet
Runtime Versions:
    5.0.11
    3.1.20

.NET Core 3.1 SDK
SDK: 3.1.414

Xamarin.Profiler
Version: 1.6.15.68
Location: /Applications/Xamarin Profiler.app/Contents/MacOS/Xamarin Profiler

Updater
Version: 11

Apple Developer Tools
Xcode 13.1 (19466)
Build 13A1030d

Xamarin Designer
Version: 16.11.0.39
Hash: cd672761d
Branch: remotes/origin/d16-11
Build date: 2021-10-06 20:09:18 UTC

Xamarin.Mac
Xamarin.Mac not installed. Can't find /Library/Frameworks/Xamarin.Mac.framework/Versions/Current/Version.

Xamarin.iOS
Version: 15.2.0.1 (Visual Studio Community)
Hash: 8fd9e6289
Branch: xcode13.1
Build date: 2021-10-26 10:13:56-0400

Xamarin.Android
Version: 12.0.0.3 (Visual Studio Community)
Commit: xamarin-android/d16-11/f0e3c2d
Android SDK: /Users/kensykora/Library/Developer/Xamarin/android-sdk-macosx
    Supported Android versions:
        None installed

SDK Tools Version: 26.1.1
SDK Platform Tools Version: 30.0.4
SDK Build Tools Version: 30.0.2

Build Information: 
Mono: c633fe9
Java.Interop: xamarin/java.interop/d16-11@476bb5b
ProGuard: Guardsquare/proguard/v7.0.1@912d149
SQLite: xamarin/sqlite/3.35.4@85460d3
Xamarin.Android Tools: xamarin/xamarin-android-tools/d16-11@87af37b

Eclipse Temurin JDK
Java SDK: /Library/Java/JavaVirtualMachines/temurin-8.jdk/Contents/Home
1.8.0_302
Android Designer EPL code available here:
https://github.com/xamarin/AndroidDesigner.EPL

Android SDK Manager
Version: 16.10.0.13
Hash: 1b81df5
Branch: remotes/origin/d16-10
Build date: 2021-09-28 20:47:12 UTC

Android Device Manager
Version: 16.10.0.15
Hash: 89dcc0b
Branch: remotes/origin/d16-10
Build date: 2021-09-28 20:47:30 UTC

Build Information
Release ID: 810120016
Git revision: e4f3f43ac50d8e0f83a71dbcb666bb1611a661d7
Build date: 2021-10-28 12:10:44-04
Build branch: release-8.10

Operating System
Mac OS X 10.16.0
Darwin 20.5.0 Darwin Kernel Version 20.5.0
    Sat May  8 05:10:31 PDT 2021
    root:xnu-7195.121.3~9/RELEASE_ARM64_T8101 x86_64
andriizhegurov-okta commented 3 years ago

Added this to the OKTA-443938 ticket

bryanapellanes-okta commented 2 years ago

This is fixed in the latest release: https://github.com/okta/okta-oidc-xamarin/releases/tag/v3.0.1