Code Monkey home page Code Monkey logo

ory / kratos Goto Github PK

View Code? Open in Web Editor NEW
10.6K 10.6K 929.0 85.88 MB

Next-gen identity server replacing your Auth0, Okta, Firebase with hardened security and PassKeys, SMS, OIDC, Social Sign In, MFA, FIDO, TOTP and OTP, WebAuthn, passwordless and much more. Golang, headless, API-first. Available as a worry-free SaaS with the fairest pricing on the market!

Home Page: https://www.ory.sh/kratos/?utm_source=github&utm_medium=banner&utm_campaign=kratos

License: Apache License 2.0

Makefile 0.18% Go 87.17% Shell 0.76% JavaScript 0.32% Jsonnet 0.10% Mustache 2.12% TypeScript 9.34% Dockerfile 0.01%
hacktoberfest identity identity-management login profile-management registration user user-management user-profile user-profiles users

kratos's Introduction

Ory Kratos - Cloud native Identity and User Management


CI Tasks for Ory Kratos CII Best Practices

Ory Kratos is the developer-friendly, security-hardened and battle-tested Identity, User Management and Authentication system for the Cloud. Finally, it is no longer necessary to implement User Login for the umpteenth time!

Ory Kratos on the Ory Network

The Ory Network is the fastest, most secure and worry-free way to use Ory's Services. Ory Identities is powered by the Ory Kratos open source identity server, and it's fully API-compatible.

The Ory Network provides the infrastructure for modern end-to-end security:

  • Identity & credential management scaling to billions of users and devices
  • Registration, Login and Account management flows for passkey, biometric, social, SSO and multi-factor authentication
  • Pre-built login, registration and account management pages and components
  • OAuth2 and OpenID provider for single sign on, API access and machine-to-machine authorization
  • Low-latency permission checks based on Google's Zanzibar model and with built-in support for the Ory Permission Language

It's fully managed, highly available, developer & compliance-friendly!

  • GDPR-friendly secure storage with data locality
  • Cloud-native APIs, compatible with Ory's Open Source servers
  • Comprehensive admin tools with the web-based Ory Console and the Ory Command Line Interface (CLI)
  • Extensive documentation, straightforward examples and easy-to-follow guides
  • Fair, usage-based pricing

Sign up for a free developer account today!

Ory Network Hybrid Support Plan

Ory offers a support plan for Ory Network Hybrid, including Ory on private cloud deployments. If you have a self-hosted solution and would like help, consider a support plan! The team at Ory has years of experience in cloud computing. Ory's offering is the only official program for qualified support from the maintainers. For more information see the website or book a meeting!

Quickstart

Install the Ory CLI and create a new project to get started with Ory Identities right away:

# If you don't have Ory CLI installed yet:
bash <(curl https://raw.githubusercontent.com/ory/meta/master/install.sh) -b . ory
sudo mv ./ory /usr/local/bin/

# Sign up
ory auth

# Create project
ory create project

Table of Contents

What is Ory Kratos?

Ory Kratos is an API-first Identity and User Management system that is built according to cloud architecture best practices. It implements core use cases that almost every software application needs to deal with:

  • Self-service Login and Registration: Allow end-users to create and sign into accounts (we call them identities) using Username / Email and password combinations, Social Sign In ("Sign in with Google, GitHub"), Passwordless flows, and others.
  • Multi-Factor Authentication (MFA/2FA): Support protocols such as TOTP (RFC 6238 and IETF RFC 4226 - better known as Google Authenticator)
  • Account Verification: Verify that an E-Mail address, phone number, or physical address actually belong to that identity.
  • Account Recovery: Recover access using "Forgot Password" flows, Security Codes (in case of MFA device loss), and others.
  • Profile and Account Management: Update passwords, personal details, email addresses, linked social profiles using secure flows.
  • Admin APIs: Import, update, delete identities.

We highly recommend reading the Ory Kratos introduction docs to learn more about Ory Krato's background, feature set, and differentiation from other products.

Who is using it?

The Ory community stands on the shoulders of individuals, companies, and maintainers. The Ory team thanks everyone involved - from submitting bug reports and feature requests, to contributing patches and documentation. The Ory community counts more than 33.000 members and is growing rapidly. The Ory stack protects 60.000.000.000+ API requests every month with over 400.000+ active service nodes. None of this would have been possible without each and everyone of you!

The following list represents companies that have accompanied us along the way and that have made outstanding contributions to our ecosystem. If you think that your company deserves a spot here, reach out to [email protected] now!

Type Name Logo Website
Adopter * Raspberry PI Foundation Raspberry PI Foundation raspberrypi.org
Adopter * Kyma Project Kyma Project kyma-project.io
Adopter * Tulip Tulip Retail tulip.com
Adopter * Cashdeck / All My Funds All My Funds cashdeck.com.au
Adopter * Hootsuite Hootsuite hootsuite.com
Adopter * Segment Segment segment.com
Adopter * Arduino Arduino arduino.cc
Adopter * DataDetect Datadetect unifiedglobalarchiving.com/data-detect/
Adopter * Sainsbury's Sainsbury's sainsburys.co.uk
Adopter * Contraste Contraste contraste.com
Adopter * Reyah Reyah reyah.eu
Adopter * Zero Project Zero by Commit getzero.dev
Adopter * Padis Padis padis.io
Adopter * Cloudbear Cloudbear cloudbear.eu
Adopter * Security Onion Solutions Security Onion Solutions securityonionsolutions.com
Adopter * Factly Factly factlylabs.com
Adopter * Nortal Nortal nortal.com
Adopter * OrderMyGear OrderMyGear ordermygear.com
Adopter * Spiri.bo Spiri.bo spiri.bo
Adopter * Strivacity Spiri.bo strivacity.com
Adopter * Hanko Hanko hanko.io
Adopter * Rabbit Rabbit rabbit.co.th
Adopter * inMusic InMusic inmusicbrands.com
Adopter * Buhta Buhta buhta.com
Adopter * Connctd Connctd connctd.com
Adopter * Paralus Paralus paralus.io
Adopter * TIER IV TIER IV tier4.jp
Adopter * R2Devops R2Devops r2devops.io
Adopter * LunaSec LunaSec lunasec.io
Adopter * Serlo Serlo serlo.org
Adopter * dyrector.io dyrector.io dyrector.io
Adopter * Stackspin stackspin.net stackspin.net
Adopter * Amplitude amplitude.com amplitude.com
Adopter * Pinniped pinniped.dev pinniped.dev
Adopter * Pvotal pvotal.tech pvotal.tech

Many thanks to all individual contributors

* Uses one of Ory's major projects in production.

Getting Started

To get started with some easy examples, head over to the Get Started Documentation.

Installation

Head over to the Ory Developer Documentation to learn how to install Ory Kratos on Linux, macOS, Windows, and Docker and how to build Ory Kratos from source.

Ecosystem

We build Ory on several guiding principles when it comes to our architecture design:

  • Minimal dependencies
  • Runs everywhere
  • Scales without effort
  • Minimize room for human and network errors

Ory's architecture is designed to run best on a Container Orchestration system such as Kubernetes, CloudFoundry, OpenShift, and similar projects. Binaries are small (5-15MB) and available for all popular processor types (ARM, AMD64, i386) and operating systems (FreeBSD, Linux, macOS, Windows) without system dependencies (Java, Node, Ruby, libxml, ...).

Ory Kratos: Identity and User Infrastructure and Management

Ory Kratos is an API-first Identity and User Management system that is built according to cloud architecture best practices. It implements core use cases that almost every software application needs to deal with: Self-service Login and Registration, Multi-Factor Authentication (MFA/2FA), Account Recovery and Verification, Profile, and Account Management.

Ory Hydra: OAuth2 & OpenID Connect Server

Ory Hydra is an OpenID Certified™ OAuth2 and OpenID Connect Provider which easily connects to any existing identity system by writing a tiny "bridge" application. It gives absolute control over the user interface and user experience flows.

Ory Oathkeeper: Identity & Access Proxy

Ory Oathkeeper is a BeyondCorp/Zero Trust Identity & Access Proxy (IAP) with configurable authentication, authorization, and request mutation rules for your web services: Authenticate JWT, Access Tokens, API Keys, mTLS; Check if the contained subject is allowed to perform the request; Encode resulting content into custom headers (X-User-ID), JSON Web Tokens and more!

Ory Keto: Access Control Policies as a Server

Ory Keto is a policy decision point. It uses a set of access control policies, similar to AWS IAM Policies, in order to determine whether a subject (user, application, service, car, ...) is authorized to perform a certain action on a resource.

Security

Running identity infrastructure requires attention and knowledge of threat models.

Disclosing vulnerabilities

If you think you found a security vulnerability, please refrain from posting it publicly on the forums, the chat, or GitHub. You can find all info for responsible disclosure in our security.txt.

Telemetry

Ory's services collect summarized, anonymized data that can optionally be turned off. Click here to learn more.

Documentation

Guide

The Guide is available here.

HTTP API documentation

The HTTP API is documented here.

Upgrading and Changelog

New releases might introduce breaking changes. To help you identify and incorporate those changes, we document these changes in the CHANGELOG.md. For upgrading, please visit the upgrade guide.

Command line documentation

Run kratos -h or kratos help.

Develop

We encourage all contributions and encourage you to read our contribution guidelines

Dependencies

You need Go 1.16+ and (for the test suites):

  • Docker and Docker Compose
  • Makefile
  • NodeJS / npm

It is possible to develop Ory Kratos on Windows, but please be aware that all guides assume a Unix shell like bash or zsh.

Install from source

make install

Formatting Code

You can format all code using make format. Our CI checks if your code is properly formatted.

Running Tests

There are three types of tests you can run:

  • Short tests (do not require a SQL database like PostgreSQL)
  • Regular tests (do require PostgreSQL, MySQL, CockroachDB)
  • End to end tests (do require databases and will use a test browser)
Short Tests

Short tests run fairly quickly. You can either test all of the code at once

go test -short -tags sqlite ./...

or test just a specific module:

cd client; go test -tags sqlite -short .
Regular Tests

Regular tests require a database set up. Our test suite is able to work with docker directly (using ory/dockertest) but we encourage to use the Makefile instead. Using dockertest can bloat the number of Docker Images on your system and are quite slow. Instead we recommend doing:

make test

Please be aware that make test recreates the databases every time you run make test. This can be annoying if you are trying to fix something very specific and need the database tests all the time. In that case we suggest that you initialize the databases with:

make test-resetdb
export TEST_DATABASE_MYSQL='mysql://root:secret@(127.0.0.1:3444)/mysql?parseTime=true'
export TEST_DATABASE_POSTGRESQL='postgres://postgres:[email protected]:3445/kratos?sslmode=disable'
export TEST_DATABASE_COCKROACHDB='cockroach://[email protected]:3446/defaultdb?sslmode=disable'

Then you can run go test as often as you'd like:

go test -tags sqlite ./...

# or in a module:
cd client; go test  -tags sqlite  .
Updating Test Fixtures

Some tests use fixtures. If payloads change, you can update them with:

make test-update-snapshots

This will only update the snapshots of the short tests. To update all snapshots, run:

UPDATE_SNAPSHOTS=true go test -p 4 -tags sqlite ./...

You can also run this command from a sub folder.

End-to-End Tests

We use Cypress to run our e2e tests.

⚠️ To run Cypress on ARM based Mac's, at the moment it is necessary to install Rosetta 2. To install, use the command - softwareupdate --install-rosetta --agree-to-license

The simplest way to develop e2e tests is:

./test/e2e/run.sh --dev sqlite

You can run all tests (with databases) using:

make test-e2e

For more details, run:

./test/e2e/run.sh

Run only a singular test

Add .only to the test you would like to run.

For example:

it.only('invalid remote recovery email template', () => {
    ...
})

Run a subset of tests

This will require editing the cypress.json file located in the test/e2e/ folder.

Add the testFiles option and specify the test to run inside the cypress/integration folder. As an example we will add only the network tests.

"testFiles": ["profiles/network/*"],

Now start the tests again using the run script or makefile.

Build Docker

You can build a development Docker Image using:

make docker

Preview API documentation

  • update the SDK including the OpenAPI specification: make sdk
  • run preview server for API documentation: make docs/api
  • run preview server for swagger documentation: make docs/swagger

kratos's People

Contributors

abador avatar aeneasr avatar alnr avatar beetix avatar brahmlower avatar captainstandby avatar dadrus avatar demonsthere avatar dependabot[bot] avatar emrahcom avatar erolkskn avatar harnash avatar hperl avatar icyphox avatar jfcurran avatar jonas-jonas avatar kevgo avatar kszafran avatar martinei avatar mattbonnell avatar mitar avatar nickufer avatar oleksiireshetnik avatar ory-bot avatar sawadashota avatar seremenko-wish avatar tricky42 avatar vinckr avatar zepatrik avatar znerol avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

kratos's Issues

Gracefully handle CSRF errors

Describe the bug

Right now, CSRF errors end in an ugly JSON view that shows some error info. No real use will be able to deal with that.

Reproducing the bug

Perform a login/registration flow with an empty/changed CSRF value (e.g. copy the /login?request=... to an incognito browser).

Expected behavior

I would expect to either be redirect to the /login page with an error message telling me that I have to redo the flow due to security reasons (potential CSRF attack) or end up at /?error although the former is better UX.

Environment

  • Version: all

Rough feature-ideas (wip)

these are just random notes, for now

  • Abstraction layer for login
    • username+password
    • passwordless
    • SSO
    • OIDC
    • LDAP...maybe?
  • Abstraction layer for registration
  • Should support captchas
  • 2FA strategies
    • sms
    • google authenticator?
  • storing meta data and also oidc compliant data

  • Configuration endpoint
    • Fallback to environment variables
    • Multiple emails per account
  • Anomaly Detection
    • Brute-force Protection
    • Breached-password Detection
    • Login patterns
  • Authentication
    • Client-side -> pass by ref? pass by val? if by-val then how to revoke/refresh?
    • Server-side -> easy, just send "ok"
  • Pools, should allow plugin infrastructure
    • Database
      • There should be some type of password policy
        • Password history (remember last X passwords)
        • Password dictionary
        • Personal data (disallow data from metadata, username, etc)
        • Check with troyhunt's password database
        • Password Strength (minimum length, complexity)
    • Social
      • We probably need to enrich the profile data, this could be done with a trigger. Alternatively we could have default implementation / default enrichment strategies here.
      • How do we deal with the redirect URL? how do we transmit the auth data on the back channel?
    • Enterprise (LDAP, ...)
    • Passwordless < requires transactional api
    • API to list all of the auth methods to show the proper buttons etc
  • MFA
    • Using push notifications (requires app)
    • Using duo security
    • Using Google AuthN
    • Using SMS
  • Notifications
    • Add an ory:// provider that works together with sparkpost
    • Add support for smtp:// providers
    • Templates with i18n are required for this - or maybe just a trigger?
  • Callbacks/Triggers/Event Manager (should be implementable with HTTP, NATS, ...)
    • Triggers when registering a user (pre/post) - for example enriching data from SSO providers?
    • Triggers when authenticating a user - for example block authentication?
  • User Management
    • Ban/Block
    • We could have two types of metadata, app (not writeable by user) and user (writeable by user)
  • Multi-tenant, realms
  • Searching users
    • ... could be a remote api maybe?

Link and unlink profiles with social sign in providers

It should be possible to (un-)link delegated identities (e.g. from Google) to existing identities in the system.

  • Document account enumeration
  • The delegated identity must not have a profile yet. If a profile exists, that profile must be merged or removed first using the REST API
  • If the email (or any other identifier?) exists already for some other identity we should disallow sign up and ask to log in, then link the accounts. Anything else might lead to account impersonation or unexpectededly having 2 accounts which later need to be merged.

Implement Account Recovery

Included

Excluded

  • I want to set up one or more security questions for account recovery: Security questions have often been abused in social engineering attacks (e.g. Celebrity Leaks) because their answers ("What's your mother's maiden name?") are often easy to discover using OSINT attacks. Needs docs.
  • I want to recover my account using SMS or phone calls: SMS for credential exchange isn't particularly secure (source, source). The problem with account recovery is that a single TOTP can switch ownership of an entire account. While with 2FA, both credentials (password) and TOTP are required, account recovery really has only one credential which can be eavesdropped using sim swapping and similar. Maybe something like IMSI can help though but that needs further investigation. Needs docs.

Auto-register OAuth2 Clients for popular services

Providing a tool to automatically register OAuth2 Clients (using OIDC Dynamic Client Registration) would be super helpful when setting up Social Sign In.

  • GitHub: It is unfortunately not possible to programmatically create an OAuth2 Client because no such API endpoint exists.
  • Google: apparently not supported
  • LinkedIn: unknown

Introduce prevent extension in Identity JSON schema

The prevent extension would:

  • always prevent the user from writing to this field in a selfservice mannger (registration, profile update, ...)
  • prevent the user from reading in a selfservice manner (e.g. ``) the field if a config option is set

e.g.

{
 "hive": {
    "protected": {
       "readable": true // just an example
     }
  }
}

This field could still be modified/read when accessing the identity API through the admin port.

Alternatively, the identity model would get a privileged field that acts similar to traits and that is only writable through the admin port. It would be difficult to decide about the readability here. Other companies allow reads but no writes here.

Implement form-based, self-service login and registration

(End-)Users should be able to sign up and sign in using form-based flows. Signing up usually requires form fields:

  • username or email
  • password
  • csrf
  • additional metadata such as "accept ToS", "first name", ...

Signing in requires form fields:

  • username or email
  • password
  • csrf

Generally, username and email should be ambivalent. It should be possible to sign up/in with either one of those depending on domain policy (force username sign in, force email sign in).

Additional required features:

  • This feature must be protected against spam. The most obvious course of action is adding a CAPTCHA challenge to either sign up or sign in. The CAPTCHA should be activated after X attempts of signing in, or after creating Y accounts on the system.
  • It should be possible to completely disallow registration. Then, users could only be registered by using the administrative API. This is possible by the sign-up page to show an error message or redirect the browser to another api endpoint. Alternatively the sign up endpoint could be firewalled.
  • It should be possible to require a token (e.g. invite system) when signing up: The sign-up endpoint can implement that check. We might have an API for generating such tokens but that's optional.
  • It should be possible to require account activation. This only works with out-of-band communication via e.g. email or phone. I guess this could be a hook?
  • It should be possible to issue a session after sign up. It should also be possible to not issue a session after sign up. This really depends on domain logic.

Rebrand hooks to workflow(s)

Hooks (selfservice.login.(before|after)) determine how hive should behave when a login or registration was completed without an error state. They do not modify the actual data of the identity and/or session. Therefore, they should be called "workflow" and "workflow step/handler/runner/part/item" from now on.

Example: Password Registration

In this example, we want the user to be immediately signed in and redirected to our home page after registering a new account using email/password.

Configuration:

selfservice:
  registration:
    after:
      password:
      - run: session
      - run: redirect
        config:
          default_redirect_url: http://example.com/welcome
          allow_user_defined_redirect: true # Allows "return_to" feature

image

Example: Password Registration with (Email/Phone) Verification before login

In this example, we want the user to activate his/her account (by verifying the email or phone) before being able to sign in to our platform using email/password.

Configuration:

selfservice:
  registration:
    after:
      password:
      - run: verify
      - run: redirect
        config:
          default_redirect_url: http://example.com/please-active-account.html
          allow_user_defined_redirect: false
  login:
    after:
      password:
      - run: verify # enforce that at least one email or phone is verified
      - run: session
      - run: redirect
        config:
          default_redirect_url: http://example.com/welcome

Flow:
image

Example: Password Registration with (Email/Phone) Verification and immediate Login

Alternatively, we could want our new users to be signed in immediately after registration, but still require email verification. The welcome page would then, for example, show a red notification bar with "please verify your email"

Configuration:

selfservice:
  registration:
    after:
      - run: verify
      - run: session
      - run: redirect
        config:
          default_redirect_url: http://example.com/welcome.html
          allow_user_defined_redirect: true

Example: Password Registration with JSON Response

In this example, we would expect a application/json response. This could be used for native apps for example.

Configuration:

selfservice:
  registration:
    after:
      password:
      - run: json

Example: Disallow Registration during Weekdays

We might want to disallow registration during weekdays:

selfservice:
  registration:
    before:
      password:
      - run: json-rpc
         url: http://api.example.com/workflows/before-registration

before-registration.js

const route = (r, w) => {
  if (isWeekDay) {
    w.send(403)
    return
  }
}

Example: Disallow Registration based on external service

Assuming we want to forbid registration because some upstream system (e.g. CRM) says "no" to the identity data

selfservice:
  registration:
    after:
      password:
      - run: json-rpc
         url: http://api.example.com/workflows/after-registration

after-registration.js

const route = (r, w) => {
  if (checkIfAllowedByCRM(r.body.identity)) {
    w.send(403) // this will tell hive to delete the identity
    return
  }
}

Example: Create user at Stripe after Login / Registration

selfservice:
  login:
    after:
      password:
      - run: json-rpc
         url: http://api.example.com/workflows/stripe
  registration:
    after:
      password:
      - run: json-rpc
         url: http://api.example.com/workflows/stripe

stripe.js

const route = (r, w) => {
  const user = r.body.identity.id
  const stripeData = createUserAtStripe(user)

  w.json({ traits: { stripe: stripeData } })
}

Example: enforced 2FA

Here we're using the built-in 2fa module:

selfservice:
  login:
    after:
      password:
      - run: 2fa
  registration:
    after:
      password:
      - run: 2fa

hive/2fa.go

if hasExecuted2FA(ctx.Request) {
  session.Enhance("I am now 2fa yay")
  return nil
} else if has2faEnabled(ctx.Request) {
   return ErrorRedirect("https://example.org/2fa-login")
} else !has2faEnabled(ctx.Request) {
   return ErrorRedirect("https://example.org/2fa-setup")
}

Example: contextual 2FA (e.g. based on source ip)

Assuming there is some context for our 2fa like a non-internal network ip

selfservice:
  login:
    after:
      password:
      - run: json-rpc
         url: http://api.example.com/workflows/2fa
  registration:
    after:
      password:
      - run: json-rpc
         url: http://api.example.com/workflows/2fa

2fa.js

if (ipRange !== "192.168.0.0/24") {
  if hive.is2faEnabled(r.query.request)
    send({ redirect_to: "https://example.org/2fa-setup" })
  else if hive.is2faEnabled(r.query.request)
    send({ redirect_to: "https://example.org/2fa-login" })
  else
    send(200)
}

Prevent credentials from being filled in without validation

Assuming we have strategy "password" and "google-oidc" enabled. Assuming [email protected] has a registered account at hive using the password strategy. If another user with "google-oidc" signs up, and also has [email protected] as email, this should not be allowed. This should work with all strategies.

Instead, the user should be requested to "combine" his/her accounts by linking them.

We need to make sure that our validator checks for this usecase and rejects any requests not compliant with this policy.

  • Disallow oidc strategy sign up for identities that already have the email registered (form error)
  • Disallow password strategy sign up for identities that already have the email registered (form error)
  • Write test for oidc strategy
    • Test double sign up with existing identifier from password strategy
    • Test double sign up with existing identifier from oidc strategy
  • Write test for password strategy
    • Test double sign up with existing identifier from password strategy
    • Test double sign up with existing identifier from oidc strategy

Document how the form parser works

The registration form parser supports:

  • numbers (float64)
  • boolean
  • string

It also supports json paths for traits in the form of traits[foo.bar.baz] using sjson.

Examples

  • Include examples from sjson docs or build our own

Limitations

Nested Items

The way json schema works is that required propagates to deeper levels. If key baz of foo.bar.baz is always required, foo and bar must also be required.

When using form fields, this is very challenging to automate for us at the moment (explain here that go json schema is limited). Basically, the form payload would need to send {foo:{bar:{}}}, otherwise the only error you will see is that foo is required, which can then not be properly assigned to the actual <input name="traits[foo.bar.baz]"> because the keys do not match.

Workaround:

How To: Nested elements

Assuming a traits model:

{
  "$schema": "http://json-schema.org/draft-07/schema#",
  "type": "object",
  "properties": {
    "name": {
      "type": "object",
      "properties": {
        "first": {
          "type": "string"
        },
        "last": {
          "type": "string"
        }
      }
    }
  }
}

You could address name.first this with a form name of:

<input type=checkbox" value="true" name="traits[path.to.my.boolean]"
  • Document limitations, see #45

How To: Checkbox to boolean:

If it's not checked:

<input type=checkbox" value="true" name="traits[path.to.my.boolean]" />

If the checkbox is checked:

<input type=checkbox" value="true" name="traits[path.to.my.boolean]" checked />

If the checkbox should be toggled based on the form value (e.g. when form validation fails):

<input type=checkbox" value="true" name="traits[path.to.my.boolean]" checked={{ this.value===true }} />

How To: Array elements

  • Todo: Add array element docs

Implement JSON Schema Caching

Right now the JSON Schema is being re-loaded/compiled on every validation request. This is because the internal structure is written in such a way that it's not possible to create a copy of the JSON Schema Go Struct as the internal referencing get's messed up. This has to do with hooks and so on.

Deleting user does not delete sessions

Describe the bug

When an user is deleted it's sessions are still valid and contain all the user information.

Expected behavior

Sessions should be deleted along with user data.

Support JSON body in registration

Some clients may want to choose to send JSON payload instead of form encoded. To make this work we have to obviously support JSON decoding and be able to return form errors properly - plus redirect hook should send redirect_to as a JSON response when the content-type is json!

Support RISC

It would be nice if we could support RISC (e.g. via Hydra)

GitHub provider fails with 401 on email when scope is missing

Describe the bug

The GitHub provider fails with a 401 error, the user is redirected to the system error page. Instead,

Reproducing the bug

Most likely configure the github provider without the email scope, then login, then update config, then login again.

Document how oidc providers normalize data

We're normalizing data from OIDC providers to fit the general OpenID Connect Claim model. This is normally working as expected for OIDC certified providers, but non-oidc certified providers like GitHub need some more magic. Any type of enrichment (e.g. "how many repos does the user have?" should be done via an RPC).

We should document what the results of these providers look like. We also need to address that some providers only share a subset of resources, e.g.:

  • GitHub does not provider family name, first name, etc, nor address and so on

Implement administrative identity management

We need administrative APIs to manage (CRUD) identities. The following use cases are relevant:

  • Resetting a password to a temporary one
  • Creating a new account with a temporary password

pool: Comparing email addresses properly

  • Should email addresses be compared case-sensitively or not?
  • Should domains from email addresses be compared case-sensitively or not?
  • Are there potential problems with UTF-8 shinanigans? ("In modern DNS, we now have Internationalized Domain Names (IDN) which allows Unicode characters. The problem is that defining upper- and lowercase can be tricky in languages and character sets outside of ASCII. The intent of domain names is to be case-insensitive, but there may be complications with particular characters. So there is no simple YES or NO answer to your question.")

Allow users to decide if they want to stay signed in on this device

"Keep me signed in on this device" tells the browser (when using the session issuer) to set a TTL on the browser cookie (e.g. 90 days). If the browser's cookie policy allows remembering cookies in such a way, the user will have his session for that period of time and will have to log in again once the TTL expires.

As an alternative, the TTL is not sent, telling the browser to delete the cookie when closing the window (or the browser, depends on the implementation).

The difficulty is adding this to the form field during sign in and combining that with the session hook.

Another question is how this should be handled for Social Providers.

Another question is how this should be dealt with after registration.

Implement Verification

There should be a verification API that allows to verify email addresses and phone numbers:

  • email: Uses the mail configuration to send out a TOTP to that email address
  • phone: Uses sms configuration to sound out a TOTP to that phone number

The request is initialized by sending the browser to /verification/phone|email. For email, a link will be sent. For SMS, a code will be sent (needs UI to show a form where the number can be entered).

Internally, the system keeps a record of the emails and phones that have been verified:

identifier type is_verified
[email protected] phone true
4321 email false

All errors should be treated as system errors

OpenID Connect errors (especially with validation) should not longer be form errors with the oidc strategy. the user can not do anything. instead, this should be treated as a misconfig.

This should only be implemented if we decide to go for a "registration completion" flow.

Write tests for selfservice.ErrorHandler

selfservice.ErrorHandler's only source of test coverage comes from integration tests of oidc and password strategies. Instead, it should be tested on its own.

Implement Broadcasting

We want to broadcast events in an asynchronous fashion. For example:

Here, we would send three events, depending on the sign in state. The payloads would be different depending on the event type and would need to be documented somewhere.

This feature allows to, for example, synchronize users from hive with a thrid-party service (e.g. mailchimp).

Broadcasting is asynchronous and fire-and-forget. Hive will not wait for a result.

Broadcasting should be compatible with different message buses:

-� v0.0.1 release

  • HTTP (default): Easiest to implement on the client-side
  • Later release

Dealing with missing data when using 3rd-party registration

Right now, we provide a way to normalize data from e.g. GitHub using JSON Schema. Unfortunately, this can not cover all of the use cases, including:

  • Adding required user profile info such as date of birth
  • Asking for consent regarding Terms of Service and marketing emails

Other solutions offload this to the UI and e.g. grey out the button "sign up with ..." when the consent box is not ticked. I'm not sure how well that works with "sign in with ..." when no account exists. This is obviously not a great system because the validation should be done server side so that it stays consistent across UI implementations.

One possibility would be to have a "profile completion" page or handler or whatever that can deal with this. Maybe this is a hook?

Support object stubs in form payloads

We need to be able to send object stubs in form payloads for nested keys to properly work:

<input type="hidden" name="traits[theobjectpath]" value="__object__" />
  • Implementation
  • Documentation

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.