Giter Site home page Giter Site logo

Comments (26)

kevinchalet avatar kevinchalet commented on May 31, 2024 14

@verdie-g @vlapoec here we go: https://kevinchalet.com/2020/02/18/creating-an-openid-connect-server-proxy-with-openiddict-3-0-s-degraded-mode/ πŸ˜„

from aspnet.security.openid.providers.

kevinchalet avatar kevinchalet commented on May 31, 2024 4

The JWT middleware can't be used for issuing JWT tokens: its only mission is to validate them, which is why you get an exception when trying to use it as the DefaultSignInScheme.

The scenario you describe is usually achieved by adding an OpenID Connect server (OIDC):

Client (e.g a SPA or a mobile app) -> your OIDC server embedded in your ASP.NET Core app -> Steam (OpenID 2.0 dance) -> your OIDC server -> client.

Projects like IdentityServer (developed by Thinktecture) or OpenIddict (that I develop and maintain) can help you with that.

from aspnet.security.openid.providers.

kinosang avatar kinosang commented on May 31, 2024 1

@vlapoec IdentityServer or other OpenID Connect servers (ASOS, OpenIddict, and etc) are works well with 3rd party login, such as OAuth and OpenID.

Please refer to Asp.Net Core Identity docs and IdentityServer docs for more information.

Simply you can just add services.AddAuthentication().AddSteam() and app.UseAuthentication() (for IdentityServer it's replaced by app.UseIdentityServer())

from aspnet.security.openid.providers.

kevinchalet avatar kevinchalet commented on May 31, 2024 1

To be honest, it's not the first time I hear someone trying to implement a custom protocol instead of using a battle-tested standard like OIDC (and well-known implementations like IdSrv or OpenIddict).

I'm considering writing a blog post introducing OpenIddict 3.0's degraded mode, which allows using OpenIddict's server without any database. It's a perfect use case for a tiny proxy between a single client and a remote identity provider (Steam in this case). Would you be interested?

from aspnet.security.openid.providers.

volvoplz avatar volvoplz commented on May 31, 2024

Did you find a way to resolve this issue ?

from aspnet.security.openid.providers.

jacobmstein avatar jacobmstein commented on May 31, 2024

Unfortunately not, I ended up switching to Node for better control over the call back.

from aspnet.security.openid.providers.

volvoplz avatar volvoplz commented on May 31, 2024

Thanks a lot @PinpointTownes

That sounds exactly like what I need but I don't really understand.

If I'm hosting an IdentityServer, I'm the one who authenticates my users. Will they still be able to log into my website with their steam accounts ? And I will be able to identify their steam info ?

from aspnet.security.openid.providers.

volvoplz avatar volvoplz commented on May 31, 2024

Thank you I will dig into that

from aspnet.security.openid.providers.

verdie-g avatar verdie-g commented on May 31, 2024

I have found another solution which is handling the redirection yourself in SteamAuthenticationOptions.Events.OnTicketReceived and passing the jwt in a query parameter. See https://stackoverflow.com/questions/59734317/return-a-jwt-after-authenticating-via-open-id.

from aspnet.security.openid.providers.

kevinchalet avatar kevinchalet commented on May 31, 2024

@verdie-g looks like a super dangerous solution: your RedirectUri endpoint accepts a token parameter in the query string without any additional anti-forgery validation.

The lack of CSRF countermeasures in a callback endpoint typically results in a session fixation vulnerability: nothing prevents a bad guy from authenticating with his own account, extracting the JWT associated to his account and forging a URL he'll be able to send to a victim, that will be logged in as the attacker once clicking on the link.

There's really a reason if we suggest opting for battle-tested options: these threats are clearly identified in standard protocols.

from aspnet.security.openid.providers.

verdie-g avatar verdie-g commented on May 31, 2024

Indeed, in my case I'm forbidding CORS which I think, mitigates this security issue (?). Anyway, I should dig more into OIDC servers but it feels so overkill for the size of my project.

from aspnet.security.openid.providers.

kevinchalet avatar kevinchalet commented on May 31, 2024

Indeed, in my case I'm forbidding CORS which I think, mitigates this security issue (?).

Nope, neither the same-origin policy nor same-site cookies will mitigate that, as the victim directly visits the vulnerable callback endpoint in the attack I described.

from aspnet.security.openid.providers.

verdie-g avatar verdie-g commented on May 31, 2024

I misread your scenario. In my case, you have nothing to gain by allowing someone else to log in your account. But my solution is really dirty anyway.

from aspnet.security.openid.providers.

kevinchalet avatar kevinchalet commented on May 31, 2024

In my case, you have nothing to gain by allowing someone else to log in your account.

Information theft is the main risk with this attack: if your website allows the user to send personal data, you're at risk, as the data will be attached to the attacker's account.

from aspnet.security.openid.providers.

verdie-g avatar verdie-g commented on May 31, 2024

I understand. Thanks for pointing this issue.

from aspnet.security.openid.providers.

verdie-g avatar verdie-g commented on May 31, 2024

I would be very interested! I have started reading OpenIddict doc which is way more clearer than IdentityServer's one, no magic everywhere. But if I have implemented my custom protocol it is mostly by pure laziness because I didn't find the article matching my use case.

from aspnet.security.openid.providers.

volvoplz avatar volvoplz commented on May 31, 2024

from aspnet.security.openid.providers.

verdie-g avatar verdie-g commented on May 31, 2024

That was fast thanks! I'll read that as soon as a I can.

from aspnet.security.openid.providers.

kevinchalet avatar kevinchalet commented on May 31, 2024

@verdie-g my pleasure πŸ˜„

from aspnet.security.openid.providers.

kevinchalet avatar kevinchalet commented on May 31, 2024

Closing, as I believe my blog post answered the original question. If not, please add a comment and I'll give it a look.

from aspnet.security.openid.providers.

Gameghostify avatar Gameghostify commented on May 31, 2024

The Cookie authentication scheme here works without having to add something as heavy as asp net core identity or even identity server to your project

On that note: Does that mean we could create a custom auth scheme that implements SignInAsync?

from aspnet.security.openid.providers.

Gameghostify avatar Gameghostify commented on May 31, 2024

I'd love to use steam authentication but keep using my own user system, without having to switch to one given by ASP.NET Core Identity/IdentityServer or implementing something like OpenIddict

from aspnet.security.openid.providers.

kevinchalet avatar kevinchalet commented on May 31, 2024

@Gameghostify nothing prevents you from doing that. As you figured out, you can use the cookies authentication handler alone and build your own membership mechanism on top of that.

from aspnet.security.openid.providers.

Gameghostify avatar Gameghostify commented on May 31, 2024

from aspnet.security.openid.providers.

vshlmahalingam avatar vshlmahalingam commented on May 31, 2024

@kevinchalet Need to Use E2E encryption in Openiddict 3.0 instead of using a default Password hashing....Is there is a way to do it?

from aspnet.security.openid.providers.

jacobmstein avatar jacobmstein commented on May 31, 2024

https://kevinchalet.com/2020/02/18/creating-an-openid-connect-server-proxy-with-openiddict-3-0-s-degraded-mode/

I ended up revisiting this a while later, and I really appreciate the blog post. Thank you!

I would like to just allow users to login using a SPA, and if authenticated properly, store the info in a databse, and redirect back to my SPA and display a success message. That's it, in which case I don't need to use JWTs. In that case would it be safe to override OnTicketReceived, as long as I ensure the RedirectUri is not foreign? Using a connect server seems overkill if I don't need to issue JWTs.

from aspnet.security.openid.providers.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    πŸ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo 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.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❀️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.