Comments (2)
OK, issue seems to be that the claims "tid" and "oid" were missing from by dummy auth token. These should probably be validated as part of the token validation.
For reference here is a TokenCredential which works:
namespace My.Test.Framework;
using System;
using System.IdentityModel.Tokens.Jwt;
using System.Security.Claims;
using System.Security.Cryptography;
using System.Threading;
using System.Threading.Tasks;
using Azure.Core;
using Microsoft.IdentityModel.Tokens;
public class SelfSignedTokenCredential : TokenCredential
{
private readonly TimeSpan _expiration = TimeSpan.FromHours(1);
private readonly string _tenant = "aaaaaaaa-aaaa-aaaa-0000-aaaaaaaaaaaa";
private readonly string _issuer = $"https://sts.windows.net/aaaaaaaa-aaaa-aaaa-0000-aaaaaaaaaaaa/";
private readonly byte[] _secret = RandomNumberGenerator.GetBytes(32);
public override async ValueTask<AccessToken> GetTokenAsync(
TokenRequestContext requestContext,
CancellationToken cancellationToken)
{
return GetToken(requestContext, cancellationToken);
}
public override AccessToken GetToken(TokenRequestContext requestContext, CancellationToken cancellationToken)
{
var audience = requestContext.Scopes.Length > 0 ? requestContext.Scopes[0] : "default-audience";
audience = audience.Replace("//.default", "/");
var expires = DateTimeOffset.UtcNow + _expiration;
var token = GenerateJwtToken(audience, DateTime.UtcNow - TimeSpan.FromMinutes(5), expires.UtcDateTime);
return new AccessToken(token, expires);
}
private string GenerateJwtToken(string audience, DateTime notBefore, DateTime? expires)
{
var securityKey = new SymmetricSecurityKey(_secret);
var credentials = new SigningCredentials(securityKey, SecurityAlgorithms.HmacSha256);
return new JwtSecurityTokenHandler().CreateEncodedJwt(
issuer: _issuer,
audience: audience,
subject: new ClaimsIdentity(new []
{
new Claim("oid", "c0ffee00-c0ff-eeee-0000-c0ffee000000"),
new Claim("tid", _tenant),
}),
notBefore: notBefore,
expires: expires,
issuedAt: null,
signingCredentials: credentials);
}
}
from azurite.
Would you please help to look at this issue?
from azurite.
Related Issues (20)
- Copy Blob From URL (Sync) does not support `x-ms-copy-source-tag-option` HOT 1
- SQL Server 2022 Polybase with Azurite - file in use?
- VS Code "azurite.blobHost" config doesn't seem to work HOT 3
- Blob Tag Support HOT 2
- Upload From Url API is not implement yet? HOT 5
- Is there a web portal to check the received objects? HOT 2
- Azurite cannot handle encoded blob names HOT 5
- Generating blob SAS tokens is failing with the NuGet package of version 12.20.0 and Azurite 3.30.0 HOT 25
- Cannot create a blob container from Azure Java client 12.26.0 HOT 3
- Cannot Create/Delete a table with Azurite and WindowsAzure.Storage SDK HOT 3
- XStore C++ tests are failing because Azurite returns wrong md5 HOT 16
- Azurite doesn't match Azure when downloading byte range from empty blob HOT 2
- SAS download returns 403 HOT 7
- Batch blob requests fail when multipart boundary contains '=' HOT 4
- Update mysql2 version HOT 5
- Metadata Vanishing HOT 12
- Azurite HTTP Interface Impossible to Use from the Command Line. HOT 1
- BeginCopyAsync is throwing wrong exception when source blob is not found. HOT 1
- Upload from URL not working with a SAS URL HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from azurite.