Giter Club home page Giter Club logo

oauth20server's Introduction

OAuth20Server

This is OAtuh 2.0 Server and OpenId Connect Provider, this OAuth server is not a complete one, but by using it your users can login and register, also they can obtain access token and Idp token too. If you want to create this project from scratch please read my step by step explained article from here


Get Started

This OAuth server target .NET 6, so clone the project or download it. After that open the downloaded project with your prefere IDE (ex: Visual Studio). In the solution there is a folder named Models, inside this folder there is a class named ClientStore.cs this class accept a list of Clients and Clients here means your applications, or the applications that you would like to intracted with OAuth2 and OpenId Connect protocols.

Here is the signature of the Client object ( you can find it in the Models folder )

    public class Client
    {
        public Client()
        {

        }

        public string ClientName { get; set; }
        public string ClientId { get; set; }

        /// <summary>
        /// Client Password
        /// </summary>
        public string ClientSecret { get; set; }

        public IList<string> GrantType { get; set; }

        /// <summary>
        /// by default false
        /// </summary>
        public bool IsActive { get; set; } = false;
        public IList<string> AllowedScopes { get; set; }

        public string ClientUri { get; set; }
        public string RedirectUri { get; set; }

        public bool UsePkce { get; set; }
    }

How to register your Applications?

As I said in the prevoius step, there is a class named ClientStore and this object has an property named Clients with IEnumerable of Client return type For example, to register one client you should do like so:

 public class ClientStore
   {
       public IEnumerable<Client> Clients = new[]
       {
           new Client
           {
               ClientName = "blazorWasm",
               ClientId = "1",
               ClientSecret = "123456789",
               AllowedScopes = new[]{ "openid", "profile", "blazorWasmapi.readandwrite" },
               GrantType = GrantTypes.Code,
               IsActive = true,
               ClientUri = "https://localhost:7026",
               RedirectUri = "https://localhost:7026/signin-oidc",
               UsePkce = true,
           }
       };
   }

You can add more clients as you need, the one that shown here, is a front-end (ASP.NET Core Application) client and that is very clear from the AllowedScopes property by allowing openid scope which indicate that the OAuth20Server will return Idp token to the registerd application alond side access token.

oauth20server's People

Contributors

knowledgedevelopers avatar shoogn avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar

oauth20server's Issues

Token

hi, great job, at least did you implemented the token response? i see the code and lass, but i didn't see the response anywhere, can yu help me to understand?

i added the following code in the login, but i don't want to duplicate code

`if (loginResult.Succeeded)
{
var tokenHandler = new JwtSecurityTokenHandler();
var key = Encoding.ASCII.GetBytes("ChiaveChiaveChiaveChiaveChiaveChiave");
var tokenDescriptor = new SecurityTokenDescriptor
{
Subject = new ClaimsIdentity(new Claim[]
{
new Claim(ClaimTypes.Name, user.Id)
}),
Expires = DateTime.UtcNow.AddDays(7),
SigningCredentials = new SigningCredentials(new SymmetricSecurityKey(key), SecurityAlgorithms.HmacSha256Signature)
};
var token = tokenHandler.CreateToken(tokenDescriptor);
var tokenString = tokenHandler.WriteToken(token);

            return new LoginResponse { Succeeded = true,Token= tokenString };
        }`

can you help me, to call it by postMan,
where is the endpoint to call and how i should write the request parameters??

Custom OAuth why?

Hi,
Microsoft has a package for identity that covers OpenId / OAuth, I see that you used the tokens one, I'd just like to know the reasoning behind this?

Thanks

AuthorizationRequest

In the AuthorizationRequest class, property is misspelled: code_challenege_method.

Big Thx for Project

RevokeTokenAsync

Hi, i have a Question. Can it be that the revoke flag must be set in the method?

Oauth20

how to call oauth2.0 with from postman or console with client credentials grant

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.