Click here to Skip to main content
15,885,141 members
Home / Discussions / ASP.NET
   

ASP.NET

 
GeneralRe: ASP .NET sql database network connection string Pin
F-ES Sitecore1-Aug-20 1:20
professionalF-ES Sitecore1-Aug-20 1:20 
GeneralRe: ASP .NET sql database network connection string Pin
Steve Naidamast16-Aug-20 7:44
professionalSteve Naidamast16-Aug-20 7:44 
QuestionIndividual Accounts in webapi project vs2017 Pin
ganesh.dks28-Jul-20 21:44
ganesh.dks28-Jul-20 21:44 
QuestionUsing Authorize(Roles) in my API controller Pin
jkirkerx20-Jul-20 6:36
professionaljkirkerx20-Jul-20 6:36 
AnswerRe: Using Authorize(Roles) in my API controller Pin
jkirkerx21-Jul-20 6:01
professionaljkirkerx21-Jul-20 6:01 
AnswerWell after another failed day to figure it out ... Pin
jkirkerx21-Jul-20 12:53
professionaljkirkerx21-Jul-20 12:53 
AnswerThink I figured it out Pin
jkirkerx22-Jul-20 12:51
professionaljkirkerx22-Jul-20 12:51 
AnswerHead scratcher here Pin
jkirkerx23-Jul-20 10:33
professionaljkirkerx23-Jul-20 10:33 
Got it to work by accident.

I figured out the JWT Token 3 segment 5 segment issue after reading tons of material. That was an issue with a null token value being passed by Angular V7. The answer was to change the key from "authToken" to just "Token" in localStorage. Go Figure.

I didn't fixed the SignIn, it still fails after redirect to the overview page. But at least I know that it's the client side passing a null token.

Got my Authentication schemes straightened out. So now I'm just down to the policies.
This works ...
I went through each claim one at a time, and only the jti works, in which jti has to be a unique GUID value. Well that is not proven yet.
public static AuthorizationPolicy AdminPolicy()
{
    return new AuthorizationPolicyBuilder()
        .AddAuthenticationSchemes("Bearer")
        .RequireAuthenticatedUser()
        .RequireRole(Admin)                
        .RequireClaim("jti") 
        //.RequireClaim("bsonId")
        //.RequireClaim("role")
        //.RequireClaim("idpId")
        .Build();
}
This doesn't work ... Trying to add all the claims compiles, but doesn't authenticate.
Of course I need to test a token from the another role to validate that it really works.
public static AuthorizationPolicy AccountPolicy()
{
    return new AuthorizationPolicyBuilder()
        .AddAuthenticationSchemes("Bearer")
        .RequireAuthenticatedUser()
        .RequireRole(Account)
        .RequireClaim("jti", "sub", "unique_name", "role", "bsonId", "idpId")
        .Build();
}
What is interesting is that I read that "Roles" will no longer be supported, and that "Claims" will replace it. Of course you can place a "Role" inside a "Claim".

Now to test the policies with other account tokens.

What sucks is that so many people copied the same examples of how it works and claimed them as their own writings polluting the internet with trash on the subject. And the pollution of so many examples and descriptions of every .Net Core Version makes it confusing as well. And then add Views, Context, Razor, Blazer, API into the mix, plus Azure support as well. Then Auth0 vs OpenIdConnect, and trying to build Authorization that works for all in Startup, plus your policies.

But overall in the end so far, what I thought was going to be a huge Authorization build just ended up being a cleanup and rework of my current design.
If it ain't broke don't fix it
Discover my world at jkirkerx.com


modified 23-Jul-20 16:50pm.

AnswerDid the rewrite on both the server and client side, works great now Pin
jkirkerx27-Jul-20 7:48
professionaljkirkerx27-Jul-20 7:48 
QuestionUpgrading from .Net Core 2.2 to 3.1, SSL and Docker .net core images Pin
jkirkerx17-Jul-20 7:20
professionaljkirkerx17-Jul-20 7:20 
AnswerRe: Upgrading from .Net Core 2.2 to 3.1, SSL and Docker .net core images Pin
jkirkerx17-Jul-20 11:31
professionaljkirkerx17-Jul-20 11:31 
GeneralRe: Upgrading from .Net Core 2.2 to 3.1, SSL and Docker .net core images Pin
jkirkerx17-Jul-20 11:46
professionaljkirkerx17-Jul-20 11:46 
GeneralRe: Upgrading from .Net Core 2.2 to 3.1, SSL and Docker .net core images Pin
jkirkerx17-Jul-20 12:36
professionaljkirkerx17-Jul-20 12:36 
QuestionGenerating unique user ID Pin
Otekpo Emmanuel7-Jul-20 7:29
Otekpo Emmanuel7-Jul-20 7:29 
AnswerRe: Generating unique user ID Pin
Richard Deeming7-Jul-20 7:47
mveRichard Deeming7-Jul-20 7:47 
GeneralRe: Generating unique user ID Pin
Otekpo Emmanuel8-Jul-20 3:06
Otekpo Emmanuel8-Jul-20 3:06 
GeneralRe: Generating unique user ID Pin
Richard Deeming8-Jul-20 3:42
mveRichard Deeming8-Jul-20 3:42 
GeneralRe: Generating unique user ID Pin
Mycroft Holmes8-Jul-20 12:46
professionalMycroft Holmes8-Jul-20 12:46 
AnswerRe: Generating unique user ID Pin
David Mujica10-Jul-20 2:47
David Mujica10-Jul-20 2:47 
GeneralRe: Generating unique user ID Pin
jkirkerx13-Jul-20 11:25
professionaljkirkerx13-Jul-20 11:25 
GeneralRe: Generating unique user ID Pin
DerekT-P17-Jul-20 10:44
professionalDerekT-P17-Jul-20 10:44 
QuestionMessage Removed Pin
6-Jul-20 23:46
umeshamin6-Jul-20 23:46 
AnswerMessage Removed Pin
13-Jul-20 11:39
professionaljkirkerx13-Jul-20 11:39 
Questionpls help Pin
Member 148797912-Jul-20 21:44
Member 148797912-Jul-20 21:44 
SuggestionRe: pls help Pin
Richard MacCutchan2-Jul-20 21:48
mveRichard MacCutchan2-Jul-20 21:48 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.