Coder Social home page Coder Social logo

etimo / etimo-id Goto Github PK

View Code? Open in Web Editor NEW
0.0 2.0 0.0 943 KB

A dotnet implementation of OAuth2.

Home Page: https://etimo.se

License: MIT License

C# 97.89% HTML 1.36% Shell 0.15% CSS 0.60%
dotnet5 oauth2 single-sign-on etimo aspnet-core-5 docker

etimo-id's Introduction

Build Tests codecov License: MIT

Etimo ID

Etimo ID is a basic implementation of OAuth2, without all the bloat.

At a later stage, OpenID Connect will also be implemented.

See the Development wiki page for information on how to contribute to development.

etimo-id's People

Contributors

niclaslindstedt avatar r0tenur avatar

Watchers

 avatar  avatar

etimo-id's Issues

Add swagger page

It should have pretty good descriptions of all the inputs and outputs of the system.

Add cleanup worker

Add a worker that cleans up expired authorization codes, refresh tokens and access tokens.

  • Access tokens with used refresh tokens.
  • Used refresh tokens.
  • Authorization codes that belong to expired access tokens.

Add AuditLog

Add an AuditLog controller and log events here, e.g. successful/failed authentications.

A user should be able to fetch his/her own logs.

  • RequestAddress - caller IP
  • UserId - the account affected by the audit log
  • Type - info/warning
  • Message - a description of the event
  • Body - event data as a json structure
  • CreatedDateTime - when the event occurred

Make ReSharper in Visual Studio respect the .editorconfig

When opening the solution in Visual Studio 2019 with ReSharper, there are a lot of errors regarding code style.

We want ReSharper to respect the .editorconfig file. Is it missing settings or can ReSharper be configured to respect it fully?

Add support for multiple RedirectUris

An Application should be able to have more than one RedirectUri.

  1. If the Application has more than 1 RedirectUri, it needs to specify which one to use in the /authorize call
  2. When making an /authorize call, the redirect_uri should be validated against the existing RedirectUris.
  3. The chosen RedirectUri should be saved in AuthorizationCode and RefreshToken tables.

Add asymmetric key authentication

Allow a client to generate a certificate with a public and private key instead of using a client secret.

Only keep the public key on the server, and return the private key in the response.

Also allow the client itself to upload just a public key for a pre-generated certificate (in case the client does not trust us to generate a certificate).

Make /authorize endpoint accept OIDC arguments

When logging in with Blazor, this url gets called:

https://localhost:5011/oauth2/authorize?client_id=11111111-1111-1111-11111111111111111
  &redirect_uri=https%3A%2F%2Flocalhost%3A5012%2Fauthentication%2Flogin-callback
  &response_type=code
  &scope=openid%20profile
  &state=4189f1c5eb134962ab3998ae3e882abd
  &code_challenge=dJBLgGeU1VJt0R55orSTpYhkAl8IIMvSRnDBZrtPLuA
  &code_challenge_method=S256
  &prompt=none
  &response_mode=query

It returns 400 today. Make it work.

Stop users from brute forcing single users

While the rate limiter will stop the worst brute forcing, it will still allow an intruder to brute force a single user's account.

Add a "FailedAttempts" field to the user that increments when someone fails to login to that user account.

If the login fails more than X times (according to appsettings.json setting), ban that user from logging into that account for Y minutes (appsettings.json).

Store the banned ip (with the target userId) in distributed memory, and stop the user from logging in early in the request pipeline.

Add prompt support

Add support for prompt parameter on GET /authorize request.

none

The Authorization Server MUST NOT display any authentication or consent user interface pages.

An error is returned if:

  • an End-User is not already authenticated or
  • the Client does not have pre-configured consent for the requested Claims or
  • the Client does not fulfill other conditions for processing the request.

The error code will typically be login_required, interaction_required, or another code defined in Section 3.1.2.6. This can be used as a method to check for existing authentication and/or consent.

login

The Authorization Server SHOULD prompt the End-User for reauthentication. If it cannot reauthenticate the End-User, it MUST return an error, typically login_required.

consent

The Authorization Server SHOULD prompt the End-User for consent before returning information to the Client. If it cannot obtain consent, it MUST return an error, typically consent_required.

select_account

The Authorization Server SHOULD prompt the End-User to select a user account. This enables an End-User who has multiple accounts at the Authorization Server to select amongst the multiple accounts that they might have current sessions for. If it cannot obtain an account selection choice made by the End-User, it MUST return an error, typically account_selection_required.

Add GitHub Actions

Add CI workflow with GitHub Actions.

  • Run tests (requires #10 to be finished).
  • Build Docker image (requires #11 to be finished) on Docker Hub.

Don't let "admin" override scopes

Remove the if-statement in controllers where the "admin" role overrides the scopes.

Since roles will not grant access to the appropriate scopes, admins will have the scopes necessary to administer the resources.

Add Roles

We should be able to add roles.

User N-N Role

Roles should be used when issuing JWT tokens.

Built-in roles:
Admin -> admin: scopes
User -> read: + write: scopes

Add new RequiredAttribute that returns errors as query parameters

As per https://tools.ietf.org/html/rfc6749#section-4.1.2.1

When using authorization code flow, the client needs to be informed about errors by way of query parameters instead of using exceptions and json responses.

Create a new Required attribute called "OAuthRequiredAttribute" that takes a parameter "ErrorInQueryComponent = true".

If true, we will not throw a 400 bad request if the parameter is missing, but instead return the error as part of the query component.

Wiki pages that describe how to use the api

  • Create a user
  • Create an application
    • Create roles
    • Create scopes
    • Enable/disable authorization grant flows
  • Generate application secret
  • Create access tokens using the different flows
    • Authorization code flow
    • Refresh token flow
    • Client credentials flow
    • Resource owner password credentials flow
    • Implicit flow

Use PlantUML images for the flow pages.

ReSharper doesn't respect .editorconfig for its warnings

When opening the solution in Visual Studio 2019 with ReSharper, there are a lot of errors regarding code style.

We want ReSharper to respect the .editorconfig file. Is it missing settings or can ReSharper be configured to respect it fully?

Add Scopes

Add Scope support to Applications.

Asking for a specific Scope in an auth request should validate against the Application.

The asked for Scope should be saved in the AuthorizationCode and the RefreshToken.

Always return scope in token response

Currently, we only return the scope if the scope was specified.

Always return the scope that was granted. It is extractable from the access token itself, so we should include the information in the response as well.

Restructure project

We want to restructure the project into the following:

./
  certs/       # development certificates
  components/  # our nuget packages
  docs/        # documentation files
    uml/       # uml diagrams
  samples/     # samples / examples
  scripts/     # helper scripts for developing / running
  src/         # source code for main project
  test/        # test projects

Make scopes more unique

The scopes must be unique to etimo-id.

Otherwise, if "admin:user" is also used by a client, we could potentially create problems.

The update-database script doesn't update the database if run clean

After cloning the project (i.e. no artifacts folder), you run the update-database.csx script.

It won't work.

You have to do the following:

dotnet build
dotnet ef database update -v -p src/Etimo.Id.Data -s src/Etimo.Id.Api --msbuildprojectextensionspath artifacts/obj/Etimo.Id.Data
dotnet ef database update -v -p src/Etimo.Id.Data -s src/Etimo.Id.Api --msbuildprojectextensionspath artifacts/obj/Etimo.Id.Api

The first update will fail, the second will succeed. Then you only need to run the second one for it to succeed.

Add pagination & filters

In the case of the Application resource, create ApplicationQueryOptions that inherits from QueryOptions.

QueryOptions should contain information about pagination (skip, take).

ApplicationQueryOptions should contain filtering information that is specific to the Application entity.

There might not be any filtering options for Applications right now, but there might be later and best to keep it consequential.

Do this for all resources.

Add endpoint to unlock user

If a user gets locked, it should be possible for an admin (or the user itself, with a valid token) to unlock it.

PUT /users/{id}/unlock

It should be PUT since we are updating a state, and the call is idempotent.

Improve look of login page

  • Add basic css to make it look ok.
  • Use application logo.
  • Add descriptions of what scopes the client is asking for.

Add endpoints for fetching audit logs

GET /auditlogs

Should return a list of all auditlogs (if admin), or a list of all auditlogs belonging to the caller (user), if the caller is missing the admin scope.

GET /users/<id>/auditlogs

Should return a list of all the auditlogs related to that user.

GET /applications/<id>/auditlogs

Should return a list of all auditlogs for the application.

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.