Code Monkey home page Code Monkey logo

user-management's Introduction

user-management

sample application using Ory open source projects

Ory

Requirements

  • docker and docker-compose

Installation

  • docker and docker-compose
 docker-compose build

Start

  • start services:
    • user-management
    • db-user-management
docker-compose up

Start services Ory (Hydra OauthKeeper Keto)

2 - start services hydra oauthkeeper and keto

docker-compose -f docker-compose-hydra.yaml build
docker-compose -f docker-compose-hydra.yaml up

example usage

3 - create client hydra

docker-compose -f docker-compose-hydra.yaml exec hydra \
    hydra clients create \
    --endpoint http://127.0.0.1:4445 \
    --id auth-code-client \
    --secret secret \
    --grant-types client_credentials,authorization_code,refresh_token \
    --response-types code,id_token \
    --scope openid,offline \
    --callbacks http://localhost:9090/api-user-management/auth-callback

4 - register user

    admin
    
    curl --location --request POST 'http://localhost:9090/api-user-management/register' \
    --header 'Content-Type: application/json' \
    --data-raw '{
    	"name": "admin",
    	"email": "[email protected]",
    	"password": "123"
    }'
    
    user
            
    curl --location --request POST 'http://localhost:9090/api-user-management/register' \
    --header 'Content-Type: application/json' \
    --data-raw '{
        "name": "user",
        "email": "[email protected]",
        "password": "123"
    }'

5 - create policies

admin

curl --location --request POST 'http://localhost:9090/api-user-management/keto/policies' \
--header 'Content-Type: application/json' \
--data-raw '{
  "description": "policy admin",
  "subjects": ["admin"],
  "effect": "allow",
  "resources": [
      "user-management:user"
  ],
  "actions": ["get", "post", "put", "delete"],
  "conditions": null
}'

user 

curl --location --request POST 'http://localhost:9090/api-user-management/keto/policies' \
--header 'Content-Type: application/json' \
--data-raw '{
  "description": "policy user",
  "subjects": ["user"],
  "effect": "allow",
  "resources": [
      "user-management:user"
  ],
  "actions": ["get"],
  "conditions": null
}'

6 - create role

admin

curl --location --request POST 'http://localhost:9090/api-user-management/keto/roles' \
--header 'Content-Type: application/json' \
--data-raw '{
  "id":"admin",
  "members": [
    "[email protected]"
  ]
}'

user

curl --location --request POST 'http://localhost:9090/api-user-management/keto/roles' \
--header 'Content-Type: application/json' \
--data-raw '{
  "id":"user",
  "members": [
    "[email protected]"
  ]
}'

Usage

  1. login
http://localhost:9090/api-user-management/authorize

email: [email protected]
email: [email protected]

password: 123
curl --location --request GET 'http://localhost:4455/api-user-management/users' \
--header 'Authorization: Bearer {token}' \

user-management's People

Contributors

lucascoelhosilva avatar

Stargazers

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