Skip to content

Commit

Permalink
feat(auth): add Entra ID identity provider integration
Browse files Browse the repository at this point in the history
Introduces Entra ID (former Azure AD) authentication support with multiple authentication flows
and automated token lifecycle management.

Key additions:
- Add EntraIdCredentialsProvider for handling Entra ID authentication flows
- Implement MSALIdentityProvider to integrate with MSAL/EntraID authentication library
- Add support for multiple authentication methods:
  - Managed identities (system and user-assigned)
  - Client credentials with certificate
  - Client credentials with secret
  - Authorization Code flow with PKCE
- Add factory class with builder methods for each authentication flow
- Include sample Express server implementation for Authorization Code flow
- Export core auth types from client package for reuse
- Add comprehensive configuration options for authority and token management

Package exports (@redis/client):
- Added package.json "exports" field to enable auth folder barrel exports
- Included additional export paths ("./index" and "./dist/*") to maintain
  compatibility with existing deep imports across the monorepo packages

This change enables Azure-based authentication flows while maintaining consistent
token lifecycle management patterns established in the core authentication system.
  • Loading branch information
bobymicroby committed Dec 5, 2024
1 parent 0d78fb0 commit 6302566
Show file tree
Hide file tree
Showing 12 changed files with 1,762 additions and 43 deletions.
1,044 changes: 1,020 additions & 24 deletions package-lock.json

Large diffs are not rendered by default.

13 changes: 13 additions & 0 deletions packages/client/lib/client/authx/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
import { TokenManager, TokenManagerConfig, TokenStreamListener, RetryPolicy, IDPError } from './token-manager';
export { TokenManager, TokenManagerConfig, TokenStreamListener, RetryPolicy, IDPError };
import { Disposable } from './types';
export { Disposable };

import { CredentialsProvider, StreamingCredentialsProvider, UnableToObtainNewCredentialsError, CredentialsError, StreamingCredentialsListener, AsyncCredentialsProvider, ReAuthenticationError, BasicAuth } from './credentials-provider';
export { CredentialsProvider, StreamingCredentialsProvider, UnableToObtainNewCredentialsError, CredentialsError, StreamingCredentialsListener, AsyncCredentialsProvider, ReAuthenticationError, BasicAuth };

import { Token } from './token';
export { Token };

import { IdentityProvider, TokenResponse } from './identity-provider';
export { IdentityProvider, TokenResponse };
3 changes: 1 addition & 2 deletions packages/client/lib/client/index.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
import COMMANDS from '../commands';
import { BasicAuth, CredentialsError, CredentialsProvider, StreamingCredentialsProvider, UnableToObtainNewCredentialsError } from './authx/credentials-provider';
import {Disposable} from './authx/types';
import { BasicAuth, CredentialsError, CredentialsProvider, StreamingCredentialsProvider, UnableToObtainNewCredentialsError, Disposable } from './authx/';
import RedisSocket, { RedisSocketOptions } from './socket';
import RedisCommandsQueue, { CommandOptions } from './commands-queue';
import { EventEmitter } from 'node:events';
Expand Down
26 changes: 26 additions & 0 deletions packages/client/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,32 @@
"license": "MIT",
"main": "./dist/index.js",
"types": "./dist/index.d.ts",
"exports": {
".": {
"types": "./dist/index.d.ts",
"default": "./dist/index.js"
},
"./index": {
"types": "./dist/index.d.ts",
"default": "./dist/index.js"
},
"./authx": {
"types": "./dist/lib/client/authx/index.d.ts",
"default": "./dist/lib/client/authx/index.js"
},
"./lib/commands/generic-transformers": {
"types": "./dist/lib/commands/generic-transformers.d.ts",
"default": "./dist/lib/commands/generic-transformers.js"
},
"./dist/*": {
"types": "./dist/*.d.ts",
"default": "./dist/*.js"
},
"./lib/errors": {
"types": "./dist/lib/errors.d.ts",
"default": "./dist/lib/errors.js"
}
},
"files": [
"dist/",
"!dist/tsconfig.tsbuildinfo"
Expand Down
Empty file added packages/entraid/README.md
Empty file.
Loading

0 comments on commit 6302566

Please sign in to comment.