Skip to content

Commit

Permalink
Allow TokenCredentials to be passed in (supporting Managed Identities…
Browse files Browse the repository at this point in the history
… instead of Shared Access Keys)
  • Loading branch information
MatthewSteeples committed Nov 30, 2022
1 parent bc4ba07 commit 7c4cd4b
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 0 deletions.
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
// MIT License Copyright 2020 (c) David Melendez. All rights reserved. See License.txt in the project root for license information.


using Azure.Core;

namespace ElCamino.AspNetCore.Identity.AzureTable.Model
{
public class IdentityConfiguration
Expand All @@ -15,5 +17,7 @@ public class IdentityConfiguration

public string RoleTableName { get; set; }

public TokenCredential TokenCredential { get; set; }

}
}
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,12 @@ protected virtual void Initialize(IdentityConfiguration config)
_config = config;
_client = new TableServiceClient(_config.StorageConnectionString);

if (config.TokenCredential != null)
{
var tableUriBuilder = new Uri(string.Format("https://{0}.table.core.windows.net/", _client.AccountName));
_client = new TableServiceClient(tableUriBuilder, config.TokenCredential);
}

_indexTable = _client.GetTableClient(FormatTableNameWithPrefix(!string.IsNullOrWhiteSpace(_config.IndexTableName) ? _config.IndexTableName : TableConstants.TableNames.IndexTable));
_roleTable = _client.GetTableClient(FormatTableNameWithPrefix(!string.IsNullOrWhiteSpace(_config.RoleTableName) ? _config.RoleTableName : TableConstants.TableNames.RolesTable));
_userTable = _client.GetTableClient(FormatTableNameWithPrefix(!string.IsNullOrWhiteSpace(_config.UserTableName) ? _config.UserTableName : TableConstants.TableNames.UsersTable));
Expand Down

0 comments on commit 7c4cd4b

Please sign in to comment.