Code Monkey home page Code Monkey logo

milky-green's Introduction

GitHub release (latest by date) Build

Milky Green Logo

Milky Green

Milky Green is a simple OpenID Connect provider that supports Sign-In with Ethereum (EIP-4361).

Milky Green bridges the gap between web2 and web3, allowing Ethereum accounts to authenticate to off-chain services that support OpenID Connect. Off-chain services can offer Sign-In with Ethereum as a comfortable authentication method without any implementation effort. Web3 users can easily authenticate to web2 providers without username/password using only their wallet.

Quickstart

The easiest way to try Milky Green is via Docker Compose. The project contains a Docker Compose file where everything is preconfigured to test the IdP locally.

  1. Start the IdP
docker-compose \
  --project-name milkygreen \
  --file test/docker-compose.yml \
  up --detach
  1. Create an OAuth client

The client has to be configured via the API. You can either use the following cURL command or use SwaggerUI which is available at http://127.0.0.1:8080/api.

curl -X POST \
  http://127.0.0.1:8080/api/clients \
  --header 'X-Api-Key: OvyC8erWtrHEC77y' \
  --header 'Content-Type: application/json' \
  --data "@test/test_client.json"
  1. Authorize the OAuth client and retrieve OAuth tokens

Open your browser and enter the following URL to start the authorization.

http://127.0.0.1:8080/oauth2/authorize?client_id=test&response_type=code&scope=openid%20profile%20email&state=12345&redirect_uri=http%3A%2F%2F127.0.0.1%3A8081%2Fauthorized

You will be asked to sign-in and grant permissions to the client to retrieve account information.

Once you granted the permissions, your browser will open the client's callback URL. Copy the authorization code from the URL and use it to complete the authorization. You can do this with the following cURL command or your favorite HTTP API client.

curl -X POST \
  http://127.0.0.1:8080/oauth2/token \
  --header 'Authorization: Basic dGVzdDp0ZXN0' \
  --header 'Content-Type: application/x-www-form-urlencoded' \
  --data 'grant_type=authorization_code&code=[CODE]&redirect_uri=http%3A%2F%2F127.0.0.1%3A8081%2Fauthorized'

As response, you should have received an access token, refresh token, and identity token.

  1. Query account information

You can query account information with following cURL command or โ€” as before โ€” your favorite HTTP API client.

curl -X GET \
  http://127.0.0.1:8080/userinfo \
  --header 'Authorization: Bearer [ACCESS_TOKEN]'

Here, the returned data only contains your account address. See OIDC Functionalities for more information.

Installation

Prerequisites

MariaDB is used to store application data like OAuth client configuration. You need a MariaDB database with version >= 5.5.

Configuration

Basic configuration

Basic configuration of e.g. database connection parameters is done via environment variables. The project contains a template environment file with all available environment variables.

See: Template environment file

Before starting the IdP, copy the template environment file and adjust it accordingly.

Client & user configuration

Currently, there is no UI to configure clients and users. Once you have started the IdP, you have to use the API. SwaggerUI is available at http(s)://[DOMAIN]/api.

Starting the IdP

The Docker image is available at ghcr.io/moonstoneid/milky-green:1.0.0.

Here is an example usage:

docker run \
  --name milkygreen \
  --env-file .env \
  --publish 8080:8080 \
   ghcr.io/moonstoneid/milky-green:1.0.0

OIDC Functionalities

Currently, the returned account information is very basic.

By default, only following information is available.

  • sub: Ethereum account address
  • preferred_username: Ethereum account address

Once an Ethereum API URL (e.g. using Alchemy or Infura) is configured, additional account information is retrieved from ENS and then following information is also available.

  • name: Name (ENS key: name)
  • email: Email address (ENS key: email)
  • website: Website URL (ENS key: url)

Contributing

Please use the issue tracker to report any bugs.

If you would like to contribute code, fork the repository and send a pull request. When submitting code, please make every effort to follow existing conventions and style in order to keep the code as readable as possible.

Disclaimer

This project has not undergone any formal security audit.

Credits

Thanks to @wyc and Spruce Systems, Inc. for pushing EIP-4361 forward.

License

This project is distributed under the Apache License, Version 2.0 (see LICENSE file).

By submitting a pull request to this project, you agree to license your contribution under the Apache License, Version 2.0.

milky-green's People

Contributors

michaelnetter avatar mkellnhofer avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  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.