-
Notifications
You must be signed in to change notification settings - Fork 117
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feature: Add generator for initializer
- Loading branch information
Showing
2 changed files
with
52 additions
and
0 deletions.
There are no files selected for viewing
11 changes: 11 additions & 0 deletions
11
lib/generators/doorkeeper/openid_connect/install_generator.rb
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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
41
lib/generators/doorkeeper/openid_connect/templates/initializer.rb
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 | ||
|