Simple Single sign-on Authorization using oidc-client and Identity Server /ავტორიზაცია oidc-client-ის გამოყენებით
angular 6
Benefits:
- Built in APP_INITILIZER, when angular application starts, It checks auhtorization.
- After authorization redirects to start URL. for example: If you aren't authorized and enter to this route http://localhost:4200/test , after authorization redirects same URL
- Interseptor which checks errors 401 from backend.
- Automaticaly attach bearer token each request
- Flexible to use main oidc-client funtions
- Authomatic SigneOut, when user signe out one site all site which use this library authomiaticaly SigneOut
- Easy Config management
Library contains/ბიბლიოთეკას მოყვება:
a. AuthorizationInterceptor - build in auhtorization interseptor, which checks error code 401 /ეს თვითონ მოდულშია ჩაშებული, ამოწმებს 401-ზე და არედირექტებს Identity-ს URL-ზე, რომელიც კონფიგში იქნება გაწერილი.
b. AuthorizationGuardService - Route guard / პროექტში უნდა route-ებში უნდა გაიწეროს ეს Guard-ი.
c. AuthorizationService - Usable oidc-client library and custom functions / აქ არის მეთოდები რომელსაც იყენებს მოდული.
Usage/მოხმარების წესი:
- Import Library and pass config file. install oidc-client /დააიმპორტეთ ბიბლიოთეკა და გადაეცით კონფიგი, დააინსტალირეთ oidc-client-ი
;//OR; @ {}
- Config example /კონფიგი (config.json) უნდა გამოიყურებოდეს ასე:
-
assets folder must contains this .js file with name - "oidc-client.js" /assets უნდა ეგდოს .js ფაილი "oidc-client.js" - რომელიც შეგიძლიათ წამოიღოთ: https://cdnjs.cloudflare.com/ajax/libs/oidc-client/1.5.2/oidc-client.js
-
assets folder must contains 2 HTML files /assets ფოლდერში (ან შეგიძლიათ შეცვალოთ კონფიგში ფოლდერის სახელი - "htmlFilePath") უნდა არსებობდეს 2 ცალი HTML ფაილი:
a. signin-callback.html
b. silent-callback.html