Commit 93a8ebb
Changed files (7)
app
models
config
db
app/models/client.rb
@@ -5,7 +5,7 @@ class Client < ApplicationRecord
audited
has_secure_password
has_many :authorizations
-
+ attribute :redirect_uris, :string, array: true
validates :name, presence: true
validates :redirect_uri, presence: true, format: { with: URI_REGEX }
validates :uuid, presence: true, format: { with: UUID }
@@ -15,10 +15,6 @@ class Client < ApplicationRecord
self.password = SecureRandom.base58(24) unless password_digest
end
- def redirect_uris
- [redirect_uri]
- end
-
def grant_types
[:authorization_code, :refresh_token, :client_credentials, :password, 'urn:ietf:params:oauth:grant-type:saml2-bearer']
end
config/database.yml
@@ -1,16 +1,16 @@
default: &default
- adapter: sqlite3
+ adapter: postgresql
+ encoding: unicode
pool: <%= ENV.fetch("RAILS_MAX_THREADS") { 5 } %>
- timeout: 5000
development:
<<: *default
- database: db/development.sqlite3
+ database: proof
test:
<<: *default
- database: db/test.sqlite3
+ database: proof_test
production:
<<: *default
- database: db/production.sqlite3
+ url: <%= ENV['DATABASE_URL'] %>
db/migrate/20181020161349_change_clients.rb
@@ -0,0 +1,9 @@
+class ChangeClients < ActiveRecord::Migration[5.2]
+ def change
+ add_column :clients, :redirect_uris, :text, array: true, default: [], null: false
+ add_column :clients, :token_endpoint_auth_method, :integer, default: 0, null: false
+ add_column :clients, :logo_uri, :string
+ add_column :clients, :jwks_uri, :string
+ remove_column :clients, :redirect_uri
+ end
+end
db/schema.rb
@@ -10,7 +10,10 @@
#
# It's strongly recommended that you check this file into your version control system.
-ActiveRecord::Schema.define(version: 2018_09_23_234502) do
+ActiveRecord::Schema.define(version: 2018_10_20_161349) do
+
+ # These are extensions that must be enabled in order to support this database
+ enable_extension "plpgsql"
create_table "audits", force: :cascade do |t|
t.integer "auditable_id"
@@ -35,8 +38,8 @@ ActiveRecord::Schema.define(version: 2018_09_23_234502) do
end
create_table "authorizations", force: :cascade do |t|
- t.integer "user_id"
- t.integer "client_id"
+ t.bigint "user_id"
+ t.bigint "client_id"
t.string "code", null: false
t.string "challenge"
t.integer "challenge_method", default: 0
@@ -53,9 +56,12 @@ ActiveRecord::Schema.define(version: 2018_09_23_234502) do
t.string "uuid", null: false
t.string "name", null: false
t.string "password_digest", null: false
- t.string "redirect_uri", null: false
t.datetime "created_at", null: false
t.datetime "updated_at", null: false
+ t.text "redirect_uris", default: [], null: false, array: true
+ t.integer "token_endpoint_auth_method", default: 0, null: false
+ t.string "logo_uri"
+ t.string "jwks_uri"
t.index ["uuid"], name: "index_clients_on_uuid"
end
@@ -75,7 +81,7 @@ ActiveRecord::Schema.define(version: 2018_09_23_234502) do
t.index ["feature_key", "key", "value"], name: "index_flipper_gates_on_feature_key_and_key_and_value", unique: true
end
- create_table "sessions", force: :cascade do |t|
+ create_table "sessions", id: :serial, force: :cascade do |t|
t.string "session_id", null: false
t.text "data"
t.datetime "created_at"
@@ -86,11 +92,11 @@ ActiveRecord::Schema.define(version: 2018_09_23_234502) do
create_table "tokens", force: :cascade do |t|
t.string "uuid"
- t.integer "authorization_id"
+ t.bigint "authorization_id"
t.string "subject_type"
- t.integer "subject_id"
+ t.bigint "subject_id"
t.string "audience_type"
- t.integer "audience_id"
+ t.bigint "audience_id"
t.integer "token_type", default: 0
t.datetime "expired_at"
t.datetime "revoked_at"
@@ -103,7 +109,7 @@ ActiveRecord::Schema.define(version: 2018_09_23_234502) do
end
create_table "user_sessions", force: :cascade do |t|
- t.integer "user_id"
+ t.bigint "user_id"
t.string "key"
t.string "ip"
t.text "user_agent"
@@ -122,11 +128,14 @@ ActiveRecord::Schema.define(version: 2018_09_23_234502) do
t.string "password_digest"
t.datetime "created_at", null: false
t.datetime "updated_at", null: false
- t.integer "lock_version", default: 0, null: false
+ t.bigint "lock_version", default: 0, null: false
t.string "mfa_secret", limit: 16
t.string "locale", default: "en", null: false
t.string "timezone", default: "Etc/UTC", null: false
t.index ["uuid"], name: "index_users_on_uuid"
end
+ add_foreign_key "authorizations", "clients"
+ add_foreign_key "authorizations", "users"
+ add_foreign_key "user_sessions", "users"
end
Dockerfile
@@ -2,7 +2,7 @@ FROM ruby:2.5.3-alpine
ENV RAILS_ENV production
ENV RAILS_LOG_TO_STDOUT true
ENV RAILS_SERVE_STATIC_FILES true
-ENV PACKAGES build-base sqlite-dev libxml2-dev tzdata postgresql-dev
+ENV PACKAGES build-base libxml2-dev tzdata postgresql-dev
RUN apk update && apk upgrade && apk add $PACKAGES && rm -fr /var/cache/apk/*
ADD *.tar.gz .
RUN ln -s /proof-* /app
Gemfile
@@ -16,6 +16,7 @@ gem 'foreman', '~> 0.85'
gem 'jbuilder', '~> 2.5'
gem 'jwt', '~> 2.1'
gem 'local_time', '~> 2.1'
+gem 'pg'
gem 'puma', '~> 3.11'
gem 'rails', '~> 5.2.0'
gem 'rotp', '~> 3.3'
@@ -40,7 +41,6 @@ group :development, :test do
gem 'byebug', platforms: [:mri, :mingw, :x64_mingw]
gem 'i18n-tasks', '~> 0.9.24'
gem 'rspec-rails', '~> 3.8'
- gem 'sqlite3'
end
group :test do
gem 'capybara', '~> 3.6'
@@ -52,6 +52,5 @@ group :test do
gem 'webmock', '~> 3.4'
end
group :production do
- gem 'pg'
gem 'rails_12factor', '~> 0.0'
end
Gemfile.lock
@@ -281,7 +281,6 @@ GEM
actionpack (>= 4.0)
activesupport (>= 4.0)
sprockets (>= 3.0.0)
- sqlite3 (1.3.13)
terminal-table (1.8.0)
unicode-display_width (~> 1.1, >= 1.1.1)
thor (0.19.4)
@@ -359,7 +358,6 @@ DEPENDENCIES
scim-shady (~> 0.2)
selenium-webdriver (~> 3.14)
spank (~> 1.0)
- sqlite3
turbolinks (~> 5)
web-console (>= 3.3.0)
webmock (~> 3.4)