This will eventually be the home of the refactored and de-spaghettified security utils, but for now it just has a single string constant for the `REQUIRE_AUTH_HEADER` since I needed somewhere to put it and didn't want to import the entire security library just for one constant.
This entrypoint contains cross-cutting security functionality that is independent of any actual auth
implementation. Where we need to interact with a specific auth implementation (@psu/security, @psu/msal-oidc, etc.),
this entrypoint exposes class interfaces and dependency injection helpers for the implementor.
## Class Interfaces
This library makes use of class interfaces for dependency injection of vendor-specific authentication functionality.
External libraries such as @psu/msal-oidc will provide implementation of these interfaces.
### AuthService
`AuthService` defines methods to log a user into a system and get user information such as userName (ideally from
something like an ID token using OIDC).
### TokenService
`TokenService` defines methods to acquire tokens during HTTP flows.
### Providers
This library exports a couple of helper functions to allow you to provide implementations for these class interfaces -
`provideAuthService()` and `provideTokenService()`.
```
providers: [
...,
VendorAuthService,
provideAuthService(VendorAuthService),
VendorTokenService,
provideVendorTokenService(VendorTokenService),
]
```
## Interceptors
### AuthInterceptor
`AuthInterceptor` provides an implementation-agnostic way to attach `Bearer` tokens to outgoing HTTP requests.
It leverages the existing `REQUIRE_AUTH_HEADER` constant that our apis library already uses. It should be a drop-in
replacement for the implementation from @psu/security, with the exception that we no longer support the legacy
`protectedUrls` configuration parameter (though it could be re-added if needed).
The interceptor injects `TokenService`, which is a class interface. This library does not provide an implementation
for this service, instead it should be implemented by vendor-specific libraries like @psu/msal-oidc. The TokenService
is used to acquire a token.
### UseridRequestTracingInterceptor
`UseridRequestTracingInterceptor` provides an implementation-agnostic way to set custom `x-request-id` headers that
include the username of the currently logged in user. It is a drop-in replacement for the version in @psu/security.
The interceptor injects `AuthService`, which is a class interface. This library does not provide an implementation
for this service, instead it should be implemented by vendor-specific libraries like @psu/msal-oidc. The AuthService
is used to determine if a user is currently logged in.
## Models
The `User` interface defines an authenticated user. Its only field is a `userName` at this point. Your implementation
will likely have additional fields such as identity claims.
## Guards
### AlreadyLoggedInGuard
The `AlreadyLoggedInGuard` can be used to redirect users away from anonymous resources like a login screen, if they are
currently authenticated. It injects `AuthService`, see above.