AppAuth-iOS icon indicating copy to clipboard operation
AppAuth-iOS copied to clipboard

Logout Flow - AlertView saying SIGN IN

Open gemmaGC92 opened this issue 4 years ago • 20 comments

Hi, I implemented the login flow using the library and now I need to implement the log out also using the same library. I've seen the feature is under development but it's possible to implement it in the apps. The only main problem I have is that the user is prompted with the same alert as in login and the texts says SIGN IN, which is confusing for the user. Is there any way to make this alert configurable? To show it / don't show it or to customize the text appearing.

I'm using the request as OIDEndSessionRequest and an agent using OIDExternalUserAgentIOS and then using the flow as

presentEndSessionRequest:(OIDEndSessionRequest *)request
       externalUserAgent:(id<OIDExternalUserAgent>)externalUserAgent
       callback:(OIDEndSessionCallback)callback;

I know there's a branch for logout under development but I cannot use a development version in the app.

Any tip will be appreciated!

gemmaGC92 avatar Jun 17 '21 10:06 gemmaGC92

Sorry I forgot to add a screenshot for the alert presented:

Logout_alert

gemmaGC92 avatar Jun 17 '21 11:06 gemmaGC92

QUESTION:

After further investigations, I discovered this alert is the Single Sign On Consent Alert from the system. This is possible to be disabled but it needs to be set up insisde the library. Any chance to have this config available? Is there any way to call ASWebAuthenticationSession with prefersEphemeralWebBrowserSession:True?

gemmaGC92 avatar Jun 23 '21 10:06 gemmaGC92

Having the same issue. It says "Sign in". @gemmaGC92 Did you find anything to name it corretly to sth like "Sign out"?

smiLLe avatar Jul 12 '21 09:07 smiLLe

Hi @smiLLe, nope, it seems is an Apple system alert and it can not be overriden (as far as I could investigate). The only way to remove it is to launch the authentication session with prefersEphemeralWebBrowserSession. This way it does not appear but sadly I could not find any way to pass this setting to the library.

gemmaGC92 avatar Aug 10 '21 11:08 gemmaGC92

Any update to this would be much appreciated, we are facing same problem when logging out, showing that alert.

adsherpa avatar Oct 07 '21 17:10 adsherpa

Any update ?

sajjadsarkoobi avatar Dec 01 '21 21:12 sajjadsarkoobi

Any update ?

EvGen94 avatar Dec 10 '21 12:12 EvGen94

Any update regarding this??

IKTANIM avatar Apr 10 '22 10:04 IKTANIM

There's a open PR for it at https://github.com/openid/AppAuth-iOS/pull/706 or https://github.com/openid/AppAuth-iOS/pull/679

maamjadi avatar May 23 '22 07:05 maamjadi

Any update on it because PR is still open. I am facing same issue. @gemmaGC92 can we disable system POP-UP in iOS at perform logout ?

saurabh297 avatar Jun 27 '22 09:06 saurabh297

@gemmaGC92 can you try forking your podfile to see if it works for you? I had to implement it because once logged in it stayed in a loop and redirected to the login to enter the credentials.

ruben-ml avatar Jun 30 '22 08:06 ruben-ml

Any update on this?

spenceralderson avatar Jul 19 '22 14:07 spenceralderson

Hi, Any updates?

paritosh-yadav avatar Aug 23 '22 05:08 paritosh-yadav

With #645 you'll have the option of avoiding this prompt that's being displayed by ASWebAuthenticationSession. However, be aware that when using an ephemeral web session, any existing browser state that your OIDEndSessionRequest may rely on will not be present.

petea avatar Aug 23 '22 22:08 petea

You can pass prefersEphemeralSession to an agent with a Convenience initializer. When Signing Out Pass this prefersEphemeralSession = true to get rid of consent which is thrown by safari

Signing Out: -

let idToken = self.authState?.lastTokenResponse?.idToken ?? ""

let request = OIDEndSessionRequest(configuration:authState!.lastAuthorizationResponse.request.configuration, idTokenHint: idToken, postLogoutRedirectURL: URL(string:kRedirectURI)!, additionalParameters: nil)

if #available(iOS 13, *) { guard let agent = OIDExternalUserAgentIOS(presenting: self,prefersEphemeralSession: true) else {

                    return
                }
                 OIDAuthorizationService.present(request, externalUserAgent: agent,
                                                                                       callback: { (response, error) in
                    if let response = response {
                        //delete cookies just in case
                        HTTPCookieStorage.shared.cookies?.forEach { cookie in
                            HTTPCookieStorage.shared.deleteCookie(cookie)
                        }
                        // successfully logout
                    }
                    if let err = error {
                        // print Error
                        print("")
                    }
                })
            } else {
                // Fallback on earlier versions
            }
            
 }

jamisyed786 avatar Mar 09 '23 12:03 jamisyed786

You can pass prefersEphemeralSession to an agent with a Convenience initializer. When Signing Out Pass this prefersEphemeralSession = true to get rid of consent which is thrown by safari

Signing Out: -

let idToken = self.authState?.lastTokenResponse?.idToken ?? ""

let request = OIDEndSessionRequest(configuration:authState!.lastAuthorizationResponse.request.configuration, idTokenHint: idToken, postLogoutRedirectURL: URL(string:kRedirectURI)!, additionalParameters: nil)

if #available(iOS 13, *) { guard let agent = OIDExternalUserAgentIOS(presenting: self,prefersEphemeralSession: true) else {

                    return
                }
                 OIDAuthorizationService.present(request, externalUserAgent: agent,
                                                                                       callback: { (response, error) in
                    if let response = response {
                        //delete cookies just in case
                        HTTPCookieStorage.shared.cookies?.forEach { cookie in
                            HTTPCookieStorage.shared.deleteCookie(cookie)
                        }
                        // successfully logout
                    }
                    if let err = error {
                        // print Error
                        print("")
                    }
                })
            } else {
                // Fallback on earlier versions
            }
            
 }

It is works for me.

Thanks @jamisyed786

Corgizzz avatar Jun 12 '23 03:06 Corgizzz

@hupendraaplite please see my comment here on a related question. Unfortunately, you cannot modify this alert.

mdmathias avatar Aug 21 '23 16:08 mdmathias

@mdmathias @Corgizzz @jamisyed786 @gemmaGC92 Is there a way to change the alert verbiage or hide this alert itself ? please help. @interface OIDEndSessionRequest : NSObject <NSCopying, NSSecureCoding, OIDExternalUserAgentRequest>

AlokRently avatar Feb 03 '24 17:02 AlokRently

I am using prefersEphemeralSession which solved the issue

smiLLe avatar Feb 04 '24 10:02 smiLLe