當前位置: 首頁>>代碼示例>>TypeScript>>正文


TypeScript angular-oauth2-oidc.OAuthService類代碼示例

本文整理匯總了TypeScript中angular-oauth2-oidc.OAuthService的典型用法代碼示例。如果您正苦於以下問題:TypeScript OAuthService類的具體用法?TypeScript OAuthService怎麽用?TypeScript OAuthService使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。


在下文中一共展示了OAuthService類的9個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的TypeScript代碼示例。

示例1: constructor

 constructor(
   private _router: Router, private _http: Http, private oauthService: OAuthService){
       this.oauthService.loginUrl = 'http://localhost:8081/spring-security-oauth-server/oauth/authorize'; 
       this.oauthService.redirectUri = 'http://localhost:8086/';
       this.oauthService.clientId = "sampleClientId";
       this.oauthService.scope = "read write foo bar";    
       this.oauthService.setStorage(sessionStorage);
       this.oauthService.oidc=false;
       this.oauthService.tryLogin({});      
   }
開發者ID:ikane,項目名稱:spring-security-oauth-1,代碼行數:10,代碼來源:app.service.ts

示例2: constructor

 constructor(
   private _router: Router, private _http: HttpClient, private oauthService: OAuthService){
       this.oauthService.configure({
           loginUrl: 'http://localhost:8081/spring-security-oauth-server/oauth/authorize',
           redirectUri: 'http://localhost:8086/',
           clientId: 'sampleClientId',
           scope: 'read write foo bar',
           oidc: false
       })
       this.oauthService.setStorage(sessionStorage);
       this.oauthService.tryLogin({});      
   }
開發者ID:eugenp,項目名稱:spring-security-oauth,代碼行數:12,代碼來源:app.service.ts

示例3: constructor

    constructor(private oauthService: OAuthService) {
        // URL of the SPA to redirect the user to after login
        this.oauthService.redirectUri = window.location.origin/* + '/index.html'*/;

        // The SPA's id. The SPA is registerd with this id at the auth-server
        this.oauthService.clientId = 'spa-client';

        // set the scope for the permissions the client should request
        // The first three are defined by OIDC. The 4th is a usecase-specific one
        this.oauthService.scope = 'openid profile email';

        // set to true, to receive also an id_token via OpenId Connect (OIDC) in addition to the
        // OAuth2-based access_token
        this.oauthService.oidc = true;

        // Use setStorage to use sessionStorage or another implementation of the TS-type Storage
        // instead of localStorage
        this.oauthService.setStorage(sessionStorage);

        this.oauthService.issuer = 'https://his-auth.azurewebsites.net';

        // Set a dummy secret
        // Please note that the auth-server used here demand the client to transmit a client secret, although
        // the standard explicitly cites that the password flow can also be used without it. Using a client secret
        // does not make sense for a SPA that runs in the browser. That's why the property is called dummyClientSecret
        // Using such a dummy secreat is as safe as using no secret.
        this.oauthService.dummyClientSecret = 'geheim';

        this.oauthService.options = {
            _service: oauthService,
            onTokenReceived(params: any) {
                let promise: Promise<any> = this._service.loadUserProfile();
                promise.catch(function(err){console.error(err); });
            }
        };

        // Load Discovery Document and then try to login the user
        this.oauthService.loadDiscoveryDocument().then(() => {

            // This method just tries to parse the token(s) within the url when
            // the auth-server redirects the user back to the web-app
            // It dosn't send the user the the login page
            this.oauthService.tryLogin(this.oauthService.options);
        });
    }
開發者ID:Fanuer,項目名稱:HIS,代碼行數:45,代碼來源:app.component.ts

示例4: isLoggedIn

  isLoggedIn(){
console.log(this.oauthService.getAccessToken());  
    if (this.oauthService.getAccessToken() === null){
       return false;
    }
    return true;
  } 
開發者ID:eugenp,項目名稱:spring-security-oauth,代碼行數:7,代碼來源:app.service.ts

示例5: reject

 oauthService.tryLogin().then(() => {
     if (!oauthService.hasValidAccessToken()) {
         oauthService.initImplicitFlow();
         reject();
     }
     resolve(true);
 });
開發者ID:andrask,項目名稱:CloudFlow,代碼行數:7,代碼來源:auth.init.ts

示例6:

        this.oauthService.loadDiscoveryDocument().then(() => {

            // This method just tries to parse the token(s) within the url when
            // the auth-server redirects the user back to the web-app
            // It dosn't send the user the the login page
            this.oauthService.tryLogin(this.oauthService.options);
        });
開發者ID:Fanuer,項目名稱:HIS,代碼行數:7,代碼來源:app.component.ts

示例7: canActivate

  canActivate(route: ActivatedRouteSnapshot, state: RouterStateSnapshot): boolean {
    if (this.oauthService.hasValidIdToken()) {
      return true;
    }

    this.router.navigate(['/cadastro-usuario']);
    return false;
  }
開發者ID:andreiaacs,項目名稱:desafioSpringAngular,代碼行數:8,代碼來源:auth.service.ts

示例8: configureWithNewConfigApi

    // This api will come in the next version
    private configureWithNewConfigApi() {

      this.oauthService.configure(authConfig);
      this.oauthService.tokenValidationHandler = new JwksValidationHandler();
      this.oauthService.loadDiscoveryDocumentAndTryLogin();

      // Optional
      this.oauthService.setupAutomaticSilentRefresh();

      this.oauthService.events.subscribe(e => {
        console.debug('oauth/oidc event', e);
      });

      this.oauthService.events.filter(e => e.type === 'session_terminated').subscribe(e => {
        console.debug('Your session has been terminated!');
      });
      
      this.oauthService.events.filter(e => e.type === 'token_received').subscribe(e => {
        // this.oauthService.loadUserProfile();
      });

    }
開發者ID:bokzor,項目名稱:angular-oauth2-oidc,代碼行數:23,代碼來源:app.component.ts

示例9: configureAuth

  private configureAuth() {
    
    //
    // This method demonstrated the old API; see configureWithNewConfigApi for new one
    //

    // URL of the SPA to redirect the user to after login
    this.oauthService.redirectUri = window.location.origin + "/index.html";

    // URL of the SPA to redirect the user after silent refresh
    this.oauthService.silentRefreshRedirectUri = window.location.origin + "/silent-refresh.html";

    // The SPA's id. The SPA is registerd with this id at the auth-server
    this.oauthService.clientId = "spa-demo";

    // set the scope for the permissions the client should request
    // The first three are defined by OIDC. The 4th is a usecase-specific one
    this.oauthService.scope = "openid profile email voucher";

    // Url of the Identity Provider
    this.oauthService.issuer = 'https://steyer-identity-server.azurewebsites.net/identity';

    this.oauthService.tokenValidationHandler = new JwksValidationHandler();

    this.oauthService.events.subscribe(e => {
      console.debug('oauth/oidc event', e);
    });

    // Load Discovery Document and then try to login the user
    this.oauthService.loadDiscoveryDocument().then((doc) => {
      this.oauthService.tryLogin();
    });

    this
      .oauthService
      .events
      .filter(e => e.type == 'token_expires')
      .subscribe(e => {
        console.debug('received token_expires event', e);
        this.oauthService.silentRefresh();
      });
  }
開發者ID:bokzor,項目名稱:angular-oauth2-oidc,代碼行數:42,代碼來源:app.component.ts


注:本文中的angular-oauth2-oidc.OAuthService類示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。