{"id":21089416,"url":"https://github.com/id1945/angular12-wso2-is-sso","last_synced_at":"2026-05-19T01:38:17.307Z","repository":{"id":102416924,"uuid":"404009140","full_name":"id1945/angular12-wso2-is-sso","owner":"id1945","description":"Single Sign-on (SSO) Auth0 Angular 2+","archived":false,"fork":false,"pushed_at":"2021-09-07T14:54:40.000Z","size":1841,"stargazers_count":1,"open_issues_count":0,"forks_count":0,"subscribers_count":3,"default_branch":"master","last_synced_at":"2025-01-21T00:50:23.964Z","etag":null,"topics":["angular","login","openid","single-sign-on","sso","token"],"latest_commit_sha":null,"homepage":"","language":"TypeScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/id1945.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2021-09-07T14:27:27.000Z","updated_at":"2023-11-01T01:25:28.000Z","dependencies_parsed_at":null,"dependency_job_id":"9d784465-9099-478e-aefd-83164809b7a5","html_url":"https://github.com/id1945/angular12-wso2-is-sso","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/id1945%2Fangular12-wso2-is-sso","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/id1945%2Fangular12-wso2-is-sso/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/id1945%2Fangular12-wso2-is-sso/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/id1945%2Fangular12-wso2-is-sso/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/id1945","download_url":"https://codeload.github.com/id1945/angular12-wso2-is-sso/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":243532564,"owners_count":20306157,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["angular","login","openid","single-sign-on","sso","token"],"created_at":"2024-11-19T21:28:49.825Z","updated_at":"2026-05-19T01:38:17.265Z","avatar_url":"https://github.com/id1945.png","language":"TypeScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Ví dụ về Single Sign-on (SSO) Auth0\n\n## Cài đặt\n\nCài đặt thư viện [angular-oauth2-oidc](https://www.npmjs.com/package/angular-oauth2-oidc)\n\n```bash\nnpm install angular-oauth2-oidc --save\n```\n\n## Structure\n\n```tree\n├───app\n│   └───home\n├───assets\n└───environments\n```\n\n## AppModule\n\n```typescript\nimport { OAuthModule } from 'angular-oauth2-oidc';\n\n@NgModule({\n  declarations: [\n    AppComponent,\n    HomeComponent\n  ],\n  imports: [\n    ...\n    OAuthModule.forRoot() // Import SSO\n  ],\n  providers: [], // Providers SSO\n  bootstrap: [AppComponent]\n})\nexport class AppModule { }\n```\n\n## Environment\n\n```json \nexport const environment = {\n  production: false,\n  sso: {\n    \"clientId\": \"nPzsAOuuadNBF4sZUC4YAre43nca\",\n    \"issuer\": \"https://sso.tcmotor.vn/oauth2/token\", \n    \"redirectUri\": \"http://localhost:4200/callback\",\n    \"loginUrl\":  \"https://sso.tcmotor.vn/oauth2/authorize\",\n    \"tokenEndpoint\": \"https://sso.tcmotor.vn/oauth2/token\",\n    \"userinfoEndpoint\":  \"https://sso.tcmotor.vn/oauth2/userinfo\",\n    \"requireHttps\": false,\n    \"requestAccessToken\": true,\n    \"disableAtHashCheck\": false,\n    \"showDebugInformation\": true,\n    \"scope\": \"openid\",\n    \"responseType\": \"id_token token\"\n  }\n};\n```\n\n## AppConponent\n\n```typescript\nexport class AppComponent {\n\n  constructor(public sso: OAuthService) {\n    this.configSSO();\n  }\n\n  /**\n   * Configuring Single Sign-On\n   */\n  private configSSO(): void {\n    this.sso.configure(ssoConfig);\n\n    /** enable below validation only if jwks object is defined as part of oauthconfig obj */\n    // this.sso.tokenValidationHandler = new JwksValidationHandler();\n    this.sso.setStorage(sessionStorage);\n\n    /** commented below because below resource is protected by some identity server ex: wso2 */\n    // this.sso.loadDiscoveryDocumentAndTryLogin();\n\n    this.sso.tryLogin();\n  }\n}\n```\n## HomeComponent\n\n```typescript\nexport class HomeComponent implements OnInit {\n\n  constructor(public sso: OAuthService) { }\n\n  /**\n   * Init component\n   */\n  ngOnInit(): void {\n    // sessionStorage\n    console.log('sessionStorageExpiresAt: ', sessionStorage.getItem('expires_at'));\n    console.log('sessionStorageAccessToken: ', sessionStorage.getItem('access_token'));\n    // Form service\n    console.log('getAccessToken: ', this.sso.getAccessToken())\n    console.log('hasValidAccessToken: ', this.sso.hasValidAccessToken())\n  }\n\n}\n```\n\n## HomeComponent - html\n\n```xml\n\u003cdiv style=\"text-align: center;\"\u003e\n    \u003ch1\u003eAuthor: DaiDH\u003c/h1\u003e\n\n    \u003chr\u003e\n    \u003cbutton (click)=\"sso.initImplicitFlow()\" *ngIf=\"!sso.hasValidAccessToken()\"\u003eLogin\u003c/button\u003e\n    \u003cbutton (click)=\"sso.logOut()\" *ngIf=\"sso.hasValidAccessToken()\"\u003eLogout\u003c/button\u003e\n    \u003chr\u003e\n    \n    \u003cimg [src]=\"sso.hasValidAccessToken() ? 'https://i.ytimg.com/vi/AcuzemsJfxA/maxresdefault.jpg': 'https://hocwordpress.vn/wp-content/uploads/2020/04/login-custom-2.jpg'\" alt=\"sso\"\u003e\n\n    \u003ch4\u003eExpiration Time: {{sso.getAccessTokenExpiration() | date: 'dd-MM-yyyy HH:mm:ss'}}\u003c/h4\u003e\n\n    \u003ch4\u003eAccessToken:\u003c/h4\u003e\n    \u003ctextarea cols=\"30\" rows=\"10\" style=\"width: 40%;\"\u003e\n        {{sso.getAccessToken() | json}}\n    \u003c/textarea\u003e\n\u003c/div\u003e\n```\n\n![Screenshot](https://raw.githubusercontent.com/id1945/angular12-wso2-is-sso/master/login.PNG)\n\n![Screenshot](https://raw.githubusercontent.com/id1945/angular12-wso2-is-sso/master/logout.PNG)\n## License\n[MIT](https://choosealicense.com/licenses/mit/)","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fid1945%2Fangular12-wso2-is-sso","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fid1945%2Fangular12-wso2-is-sso","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fid1945%2Fangular12-wso2-is-sso/lists"}