Git Product home page Git Product 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

shoogn avatar

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.