Skip to content

Commit

Permalink
feature: Add generator for initializer
Browse files Browse the repository at this point in the history
  • Loading branch information
toupeira committed Nov 2, 2016
1 parent d28ca8c commit 80399fd
Show file tree
Hide file tree
Showing 2 changed files with 52 additions and 0 deletions.
11 changes: 11 additions & 0 deletions lib/generators/doorkeeper/openid_connect/install_generator.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
class Doorkeeper::OpenidConnect::InstallGenerator < ::Rails::Generators::Base
include Rails::Generators::Migration
source_root File.expand_path('../templates', __FILE__)
desc 'Installs Doorkeeper OpenID Connect.'

def install
template 'initializer.rb', 'config/initializers/doorkeeper_openid_connect.rb'
copy_file File.expand_path('../../../../../config/locales/en.yml', __FILE__), 'config/locales/doorkeeper_openid_connect.en.yml'
route 'use_doorkeeper_openid_connect'
end
end
41 changes: 41 additions & 0 deletions lib/generators/doorkeeper/openid_connect/templates/initializer.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
Doorkeeper::OpenidConnect.configure do

issuer 'issuer string'

jws_private_key <<-EOL
-----BEGIN RSA PRIVATE KEY-----
....
-----END RSA PRIVATE KEY-----
EOL

jws_public_key <<-EOL
-----BEGIN RSA PUBLIC KEY-----
....
-----END RSA PUBLIC KEY-----
EOL

resource_owner_from_access_token do |access_token|
# Example implementation:
# User.find_by(id: access_token.resource_owner_id)
end

subject do |resource_owner|
# Example implementation:
# resource_owner.key
end

# Expiration time on or after which the ID Token MUST NOT be accepted for processing. (default 120 seconds).
# expiration 600

# Example claims:
# claims do
# normal_claim :_foo_ do |resource_owner|
# resource_owner.foo
# end

# normal_claim :_bar_ do |resource_owner|
# resource_owner.bar
# end
# end
end

0 comments on commit 80399fd

Please sign in to comment.