@eac-arch/infrastructure-security
v1.0.6
Published
Angular security library based on OAuth2/OIDC with guards, interceptor, and callback flow.
Readme
@eac-arch/infrastructure-security
Angular security library based on OAuth2/OIDC with guards, interceptor, and callback flow.
Purpose
@eac-arch/infrastructure-security encapsulates authentication and authorization concerns:
- OIDC bootstrap via APP_INITIALIZER
- token lifecycle and profile resolution
- route guards for authentication and authorization
- automatic bearer token injection for configured API endpoints
- callback component/state utilities for code flow redirects
Main Capabilities
provideSecurity(): Registers OAuth client,SecurityService, and startup initializer.SecurityService: Exposes auth status, token, roles/scopes checks, profile, login/logout.authGuard: Blocks unauthenticated routes and triggers login flow.authzGuard: Evaluates route-level role/scope requirements.authInterceptor: Adds bearer token for URLs configured throughSECURITY.SECURE_API_KEYSin runtime config.OidcCallback: Handles post-login callback and safe redirect restore.- OAuth state utilities
:
stateEncode,stateDecode,stateDecodeFromUrlParam,safeRel.
Public API
export type { IdpConfig, UserProfile, SecurityConfig };
export { SecurityService, provideSecurity };
export { authGuard, authzGuard, authInterceptor };
export { OidcCallback };
export { stateEncode, stateDecode, stateDecodeFromUrlParam, safeRel };Runtime Config Requirements
Expected config keys include:
IDP(issuer, client id, redirect URIs, scopes)SECURITY.SECURE_API_KEYS(list of keys that resolve to secure API base URLs)
Dependencies
@eac-arch/infrastructure-configangular-oauth2-oidc- Angular core/common/router
tslib
Development
From eac-arch-infrastructure-security:
npm install
npm run build
npm testCreated By
Erick Arostegui Cunza
Enterprise Solutions Architect
Professional Profile:
- LinkedIn: https://www.linkedin.com/in/erick-arostegui-cunza/
Articles:
- Medium: https://medium.com/@scorpius86
Channels and Media:
- Facebook: https://www.facebook.com/Erick.Arostegui.Cunza
- TikTok: https://www.tiktok.com/@erick_arostegui_cunza
- Instagram: https://www.instagram.com/erickarosteguicunza/
- Spotify: https://open.spotify.com/show/2JQxlxcRg7k7cJ1hB52Ge5
Created by Erick Arostegui Cunza.
