Doorman is an authorization (micro)service.
Перейти к файлу
Mathieu Leplatre 6f3964b0a6
Update vendors
2017-11-03 12:44:19 +01:00
doorman Add dedicated logger for request authorizations 2017-11-03 12:10:15 +01:00
utilities Update documentation 2017-10-05 16:17:30 +02:00
.gitignore Leverage glide to fill vendor folder 2017-10-04 14:55:43 +02:00
.travis.yml Add dedicated test-coverage make target 2017-09-22 18:08:25 +02:00
Dockerfile Load configuration from multiple files 2017-10-31 14:54:40 +01:00
LICENSE Initial commit 2017-09-18 13:12:41 +02:00
Makefile Rename warden to doorman 2017-10-04 14:55:43 +02:00
README.md Remove information about matching policy 2017-10-31 15:53:53 +01:00
glide.lock Update vendors 2017-11-03 12:44:19 +01:00
glide.yaml Update vendors 2017-11-03 12:44:19 +01:00
logger.go Move logging initialization to logger.go 2017-11-03 12:44:14 +01:00
logger_test.go Move logging initialization to logger.go 2017-11-03 12:44:14 +01:00
main.go Move logging initialization to logger.go 2017-11-03 12:44:14 +01:00
main_test.go Move logging initialization to logger.go 2017-11-03 12:44:14 +01:00
sample.yaml Load configuration from multiple files 2017-10-31 14:54:40 +01:00
version.json Initial commit 2017-09-18 13:12:41 +02:00

README.md

IAM

Build Status Coverage Status Go Report

IAM is an authorization micro-service that allows to checks if an arbitrary subject is allowed to perform an action on a resource, based on a set of rules (policies). It is inspired by AWS IAM Policies.

Policies

Policies are defined in YAML file (default ./policies.yaml) as follow:

  audience: https://service.stage.net
  policies:
    -
      description: One policy to rule them all.
      subjects:
        - maria
        - <[peter|ken]>
        - group:admin
      actions:
        - delete
        - <[create|update]>
      resources:
        - resources:articles:<.*>
        - resources:printer
      conditions:
        remoteIP:
          type: CIDRCondition
          options:
            cidr: 192.168.0.1/16
      effect: allow

Use effect: deny to deny explicitly.

Otherwise, requests that don't match any rule are denied.

Regular expressions begin with < and end with >.

Conditions

The conditions are optional and are used to match field values from the requested context. There are several types of conditions:

Field comparison

  • type: StringEqualCondition

For example, match request.context["country"] == "catalunya":

conditions:
  country:
    type: StringEqualCondition
    options:
      equals: catalunya

Field pattern

  • type: StringMatchCondition

For example, match request.context["bucket"] ~= "blocklists-.*":

conditions:
  bucket:
    type: StringMatchCondition
    options:
      matches: blocklists-.*

Subject comparison

  • type: EqualsSubjectCondition

For example, allow requests where request.context["owner"] == request.subject:

conditions:
  owner:
    type: EqualsSubjectCondition

IP/Range

  • type: CIDRCondition

For example, match request.context["clientIP"] with CIDR notation:

conditions:
  clientIP:
    type: CIDRCondition
    options:
      # mask 255.255.0.0
      cidr: 192.168.0.1/16

API

POST /allowed

Is this subject allowed to perform this action on this resource in this context?

Requires authentication

A valid JSON Web Token (JWT) must be provided in the Authorization request header. The JWT subject is used to match the policies.

The JWT claimed audience will be checked against the Origin request header. The specified value must match one of the known audience from the policies files.

Request:

POST /allowed HTTP/1.1
Content-Type: application/json
Authorization: Bearer eyJ0eXAiOiJKV1QiLCJhbG...9USXpOalEzUXpV

{
  "action" : "delete",
  "resource": "resource:articles:ladon-introduction",
  "context": {
    "remoteIP": "192.168.0.5"
  }
}

Response:

HTTP/1.1 200 OK
Content-Type: application/json

{
  "allowed": true,
  "user": {
    "id": "google-auth|2664978978"
  }
}

More

Configuration

Via environment variables:

  • PORT: listen (default: 8080)
  • GIN_MODE: server mode (release or default debug)
  • LOG_LEVEL: logging level (fatal|error|warn|info|debug, default: info with GIN_MODE=release else debug)
  • VERSION_FILE: location of JSON file with version information (default: ./version.json)
  • POLICIES_FILES: locations of YAML files with policies (default: ./policies.yaml)
  • JWT_ISSUER: issuer of the JWT tokens to match. For JWTs issued by Auth0, use the domain with a https:// prefix and a trailing / (eg. https://auth.mozilla.auth0.com/)

Note: the Dockerfile contains different default values, suited for production.

Run locally

make serve

Or with JWT verification enabled:

make serve -e JWT_ISSUER=https://minimal-demo-iam.auth0.com/

Run tests

make test

License

  • MPLv2.0