Code Monkey home page Code Monkey logo

identity-schemas's Introduction

Identity Schemas

Schemas for the HCC x-rh-identity header.

Getting Started

There are multiple x-rh-identity header shapes based on the type of authentication being used. This project is meant to be a source of truth for what the myriad identities look like, for testing, enforcement and building clients.

Usage

To run schema validation against the various types of identities, we have fixtures for each. These fixtures are static, but should be recreated whenever a change to the identity header is proposed or made.

Schemas can also be used to construct valid objects/structs for consuming the x-rh-identity.

Validation

To run schema validation, simply run:

$ go run main.go

You will see output similar to:

*** Running schema validation against sample 3scale identities ***
Validating basic.json...
Error(s) found in validation:
- identity.internal.cross_access: Invalid type. Expected: number, given: boolean

*** Running schema validation against sample turnpike identities ***
Validating turnpike_saml.json...
Validating turnpike_x509.json...

Schema consumption

You can use the schema to help validate and enforce valid identity objects to work with in your project. Here are a few examples, though you can use whatever you'd like:

Go:

# https://github.com/a-h/generate
$ go get -u github.com/a-h/generate/...
$ schema-generate ./turnpike/schema.json

Python:

# https://github.com/bcwaldon/warlock
$ pip install warlock
$ python3
>>> import warlock, json
>>> file = open("turnpike/schema.json")
>>> schema = json.loads(file.read())
>>> Identity = warlock.model_factory(schema)
>>> turnpike_identity = Identity(key="val")

Java:

https://github.com/joelittlejohn/jsonschema2pojo

identity-schemas's People

Contributors

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