Commit 9d83e5b
authored
feat: support azure entra id service principal authentication (#1133)
## Summary
Added Azure Entra ID (Service Principal) authentication support to the Azure provider, allowing for more secure token-based authentication with automatic token management.
## Fixes
#1019
## Changes
- Implemented Service Principal authentication for Azure using `ClientID`, `ClientSecret`, and `TenantID` credentials
- Added token caching with a sync.Map to avoid repeated authentication requests
- Updated the Azure provider to use a priority-based authentication approach:
1. Service Principal (if credentials provided)
2. Context token (if available)
3. API key (fallback)
- Added new fields to the AzureKeyConfig schema in both Go and UI
- Created database migration for the new Azure authentication fields
- Updated documentation to explain the new authentication options
- Added UI form fields for the new Azure authentication parameters
## Type of change
- [x] Feature
- [x] Documentation
## Affected areas
- [x] Core (Go)
- [x] Transports (HTTP)
- [x] Providers/Integrations
- [x] UI (Next.js)
- [x] Docs
## How to test
1. Configure Azure Service Principal credentials:
```sh
export AZURE_CLIENT_ID="your-client-id"
export AZURE_CLIENT_SECRET="your-client-secret"
export AZURE_TENANT_ID="your-tenant-id"
export AZURE_ENDPOINT="https://your-azure-endpoint.openai.azure.com"
```
2. Use the credentials in your application:
```go
key := schemas.Key{
Models: []string{"gpt-4o"},
AzureKeyConfig: &schemas.AzureKeyConfig{
Endpoint: os.Getenv("AZURE_ENDPOINT"),
ClientID: bifrost.Ptr(os.Getenv("AZURE_CLIENT_ID")),
ClientSecret: bifrost.Ptr(os.Getenv("AZURE_CLIENT_SECRET")),
TenantID: bifrost.Ptr(os.Getenv("AZURE_TENANT_ID")),
Deployments: map[string]string{
"gpt-4o": "gpt-4o-deployment",
},
},
}
```
3. Run tests to verify authentication works:
```sh
go test ./providers/azure/...
```
## Breaking changes
- [x] No
## Related issues
Enhances Azure authentication options for enterprise deployments.
## Security considerations
- Service Principal credentials are sensitive and should be stored securely
- The implementation uses the official Azure SDK for authentication
- Token caching is implemented to reduce authentication requests
- Credentials can be provided via environment variables for better security
## Checklist
- [x] I added/updated tests where appropriate
- [x] I updated documentation where needed
- [x] I verified builds succeed (Go and UI)File tree
21 files changed
+685
-89
lines changed- .github/workflows
- core
- internal/testutil
- providers/azure
- schemas
- docs
- providers/supported-providers
- quickstart
- gateway
- go-sdk
- framework/configstore
- tables
- transports
- bifrost-http
- handlers
- lib
- ui
- app/workspace/providers/fragments
- lib
- schemas
- types
21 files changed
+685
-89
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
100 | 100 | | |
101 | 101 | | |
102 | 102 | | |
| 103 | + | |
| 104 | + | |
| 105 | + | |
103 | 106 | | |
104 | 107 | | |
105 | 108 | | |
| |||
175 | 178 | | |
176 | 179 | | |
177 | 180 | | |
| 181 | + | |
| 182 | + | |
| 183 | + | |
178 | 184 | | |
179 | 185 | | |
180 | 186 | | |
| |||
252 | 258 | | |
253 | 259 | | |
254 | 260 | | |
| 261 | + | |
| 262 | + | |
| 263 | + | |
255 | 264 | | |
256 | 265 | | |
257 | 266 | | |
| |||
341 | 350 | | |
342 | 351 | | |
343 | 352 | | |
| 353 | + | |
| 354 | + | |
| 355 | + | |
344 | 356 | | |
345 | 357 | | |
346 | 358 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1 | 1 | | |
2 | | - | |
| 2 | + | |
| 3 | + | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
3 | 3 | | |
4 | 4 | | |
5 | 5 | | |
| 6 | + | |
| 7 | + | |
6 | 8 | | |
7 | 9 | | |
8 | 10 | | |
| |||
22 | 24 | | |
23 | 25 | | |
24 | 26 | | |
| 27 | + | |
| 28 | + | |
25 | 29 | | |
26 | 30 | | |
27 | 31 | | |
| |||
42 | 46 | | |
43 | 47 | | |
44 | 48 | | |
| 49 | + | |
45 | 50 | | |
46 | 51 | | |
47 | 52 | | |
| 53 | + | |
48 | 54 | | |
49 | 55 | | |
50 | 56 | | |
| 57 | + | |
51 | 58 | | |
52 | 59 | | |
53 | 60 | | |
| |||
56 | 63 | | |
57 | 64 | | |
58 | 65 | | |
| 66 | + | |
59 | 67 | | |
60 | 68 | | |
61 | | - | |
62 | 69 | | |
63 | 70 | | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1 | 1 | | |
2 | 2 | | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
| 6 | + | |
| 7 | + | |
| 8 | + | |
| 9 | + | |
| 10 | + | |
| 11 | + | |
| 12 | + | |
| 13 | + | |
| 14 | + | |
3 | 15 | | |
4 | 16 | | |
5 | 17 | | |
| |||
60 | 72 | | |
61 | 73 | | |
62 | 74 | | |
| 75 | + | |
| 76 | + | |
63 | 77 | | |
64 | 78 | | |
65 | 79 | | |
| |||
69 | 83 | | |
70 | 84 | | |
71 | 85 | | |
| 86 | + | |
| 87 | + | |
72 | 88 | | |
73 | 89 | | |
74 | 90 | | |
75 | 91 | | |
76 | | - | |
77 | 92 | | |
78 | 93 | | |
79 | | - | |
80 | | - | |
81 | 94 | | |
82 | 95 | | |
| 96 | + | |
| 97 | + | |
83 | 98 | | |
84 | 99 | | |
85 | 100 | | |
| |||
91 | 106 | | |
92 | 107 | | |
93 | 108 | | |
| 109 | + | |
| 110 | + | |
94 | 111 | | |
95 | 112 | | |
96 | 113 | | |
| |||
126 | 143 | | |
127 | 144 | | |
128 | 145 | | |
| 146 | + | |
| 147 | + | |
129 | 148 | | |
130 | 149 | | |
131 | 150 | | |
132 | 151 | | |
133 | 152 | | |
134 | 153 | | |
| 154 | + | |
135 | 155 | | |
136 | 156 | | |
137 | 157 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
221 | 221 | | |
222 | 222 | | |
223 | 223 | | |
| 224 | + | |
| 225 | + | |
| 226 | + | |
224 | 227 | | |
225 | 228 | | |
226 | 229 | | |
| |||
0 commit comments