question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

OauthService.logOut(true) not logging out of the identity server.

See original GitHub issue

We have a requirement where we are required to logout the user on some pages, like if the user goes to FAQ question after having a logged in session we want to explicitly terminate the session and require user to login again to go to any page.

On ngOnit of this page(faq page) we are calling this.oauthService.logOut(true) so that the user should be logged. What i have observed so far is that i did cleans up the localstorage and cookies associated with it but did’t call the logout for the identity server as the result the user is able to go back to dashboard page without logging again.

Below i am providing the minimal sample code of the component

import { Component, OnInit, ViewChild, ElementRef } from '@angular/core';
import { CookieService } from 'ngx-cookie-service';
import { OAuthService } from 'angular-oauth2-oidc';
import { Title } from '@angular/platform-browser';
import { NgxSpinnerService } from 'ngx-spinner';
import * as $ from 'jquery';


@Component({
  selector: 'app-register',
  templateUrl: './register.component.html',
  styleUrls: ['./register.component.css']
})
export class RegisterComponent implements OnInit {
  modalOptions: NgbModalOptions;

  registerForm; otpForm; captureIncomeForm; captureIncomeModelRef;
  constructor(
    private cookieService: CookieService,
    private oauthService: OAuthService,
    private titleService: Title
  ) {
    this.modalOptions = {
      backdrop: 'static',
      backdropClass: 'customBackdrop'
    };
    location.onPopState(() => this.modalService.dismissAll());
    this.titleService.setTitle('*************************');
  }

  ngOnInit() {
    localStorage.removeItem('tempToken');
    this.logOut();
  }
  
  logOut() {
    console.log("logout calling");
    this.cookieService.delete('submissionId', '/');
    this.cookieService.delete('uType', '/');
    this.oauthService.logOut(true);
    this.cookieService.delete('submissionId', '/');
    console.log("oauthService logout called");
    return false;
  }

  azureAdlogin(message) {
    localStorage.removeItem('tempToken');
    let submissionId = '';
    if (this.cookieService.get('submissionId')) {
      submissionId = this.cookieService.get('submissionId');
    }
    this.oauthService.initLoginFlow('', {
      submissionId, ccAppUrl: window.location.origin,
      instrumentationKey: environment.appInsights.instrumentationKey, message
    });
  }
}

using angular-oauth2-oidc 8.0.4 I have also read few issues regarding this but to no help. Any suggestion/help will be appreciated.

Issue Analytics

  • State:closed
  • Created 3 years ago
  • Comments:9

github_iconTop GitHub Comments

1reaction
ajays1991commented, Aug 12, 2020

I have found a workaround it. Closing this issue and very thanks for info

1reaction
ajays1991commented, Aug 11, 2020

yes, thanks for the info

Read more comments on GitHub >

github_iconTop Results From Across the Web

angular-auth-oidc-client logout not working - Stack Overflow
I am using angular-auth-oidc-client lib for authenticating my app with keycloak as the identity server.i am able to login into the app ...
Read more >
Session Checks - angular-oauth2-oidc
Session Checks. Beginning with version 2.1, you can receive a notification when the user signs out with the identity provider.
Read more >
Log Users Out of Identity Providers - Auth0
The Auth0 Logout endpoint logs you out from Auth0 and, optionally, from your identity provider. It does not log you out of your...
Read more >
Logging out in Xamarin Forms with Open Identity Connect ...
Who would have thought that logging out of your Xamarin Forms app using Open Identity Connect (OIDC) and OAuth would deserve its own...
Read more >
Single log-out for OpenID Connect with AD FS | Microsoft Learn
end_session_endpoint: this is the OAuth logout URI that the client can use to initiate logout on the server. AD FS server configuration. The...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found