mirror of
https://github.com/bitwarden/directory-connector
synced 2025-12-05 23:53:21 +00:00
Add Azure Identity Authority Selector (#176)
* New AzureSettings to select the Identity Authority * Add fallback for existing customers * Throw error if Identity Authority is set to invalid value
This commit is contained in:
committed by
GitHub
parent
660ee538ce
commit
abc68e8ef9
@@ -134,6 +134,14 @@
|
||||
</div>
|
||||
</div>
|
||||
<div [hidden]="directory != directoryType.AzureActiveDirectory">
|
||||
<div class="form-group">
|
||||
<label for="identityAuthority">{{'identityAuthority' | i18n}}</label>
|
||||
<select class="form-control" id="identityAuthority" name="IdentityAuthority"
|
||||
[(ngModel)]="azure.identityAuthority">
|
||||
<option value="login.microsoftonline.com">Azure AD Public</option>
|
||||
<option value="login.microsoftonline.us">Azure AD Government</option>
|
||||
</select>
|
||||
</div>
|
||||
<div class="form-group">
|
||||
<label for="tenant">{{'tenant' | i18n}}</label>
|
||||
<input type="text" class="form-control" id="tenant" name="Tenant" [(ngModel)]="azure.tenant">
|
||||
|
||||
@@ -354,6 +354,9 @@
|
||||
"rootPath": {
|
||||
"message": "Root Path"
|
||||
},
|
||||
"identityAuthority": {
|
||||
"message": "Identity Authority"
|
||||
},
|
||||
"tenant": {
|
||||
"message": "Tenant"
|
||||
},
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
export class AzureConfiguration {
|
||||
identityAuthority: string;
|
||||
tenant: string;
|
||||
applicationId: string;
|
||||
key: string;
|
||||
|
||||
@@ -17,6 +17,9 @@ import { IDirectoryService } from './directory.service';
|
||||
import { I18nService } from 'jslib-common/abstractions/i18n.service';
|
||||
import { LogService } from 'jslib-common/abstractions/log.service';
|
||||
|
||||
const AzurePublicIdentityAuhtority = 'login.microsoftonline.com';
|
||||
const AzureGovermentIdentityAuhtority = 'login.microsoftonline.us';
|
||||
|
||||
const NextLink = '@odata.nextLink';
|
||||
const DeltaLink = '@odata.deltaLink';
|
||||
const ObjectType = '@odata.type';
|
||||
@@ -390,6 +393,12 @@ export class AzureDirectoryService extends BaseDirectoryService implements IDire
|
||||
return;
|
||||
}
|
||||
|
||||
const identityAuthority = this.dirConfig.identityAuthority != null ? this.dirConfig.identityAuthority : AzurePublicIdentityAuhtority;
|
||||
if (identityAuthority !== AzurePublicIdentityAuhtority && identityAuthority !== AzureGovermentIdentityAuhtority) {
|
||||
done(new Error(this.i18nService.t('dirConfigIncomplete')), null);
|
||||
return;
|
||||
}
|
||||
|
||||
if (!this.accessTokenIsExpired()) {
|
||||
done(null, this.accessToken);
|
||||
return;
|
||||
@@ -406,7 +415,7 @@ export class AzureDirectoryService extends BaseDirectoryService implements IDire
|
||||
});
|
||||
|
||||
const req = https.request({
|
||||
host: 'login.microsoftonline.com',
|
||||
host: identityAuthority,
|
||||
path: '/' + this.dirConfig.tenant + '/oauth2/v2.0/token',
|
||||
method: 'POST',
|
||||
headers: {
|
||||
|
||||
Reference in New Issue
Block a user