forked from saberma/shopqi
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
change oauth-plugin to oauth2-provider gem.
- Loading branch information
Showing
24 changed files
with
1,109 additions
and
41 deletions.
There are no files selected for viewing
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
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
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
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
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 |
---|---|---|
@@ -1,16 +1,19 @@ | ||
%h1 Authorize access to your account | ||
%h3 Authorize OAuth client | ||
%p | ||
Would you like to authorize | ||
= link_to @token.client_application.name,@token.client_application.url | ||
( | ||
= link_to @token.client_application.url,@token.client_application.url | ||
) to access your account? | ||
- form_tag authorize_url do | ||
= hidden_field_tag "oauth_token", @token.token | ||
- if params[:oauth_callback] | ||
= hidden_field_tag "oauth_callback", params[:oauth_callback] | ||
%p | ||
= check_box_tag 'authorize' | ||
authorize access | ||
%p | ||
= submit_tag | ||
This application | ||
%b=@oauth2.client.name | ||
wants | ||
the following permissions: | ||
%ul | ||
-@oauth2.scopes.each do |scope| | ||
-next unless PERMISSIONS[scope] | ||
%li=PERMISSIONS[scope] | ||
=form_tag oauth_allow_path do | ||
- @oauth2.params.each do |key, value| | ||
%input{:name => "#{key}", :type => "hidden", :value => "#{value}"} | ||
-#%input{:name => "user_id", :type => "hidden", :value => "#{@user.id}"} | ||
%fieldset | ||
%input#allow{:name => "allow", :type => "checkbox", :value => "1"} | ||
%label{:for => "allow"} Allow this application | ||
%fieldset | ||
%input{:type => "submit", :value => "Go!"}/ |
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,17 @@ | ||
=content_for :login do | ||
%li | ||
以 | ||
%a(href="http://test.myshopqi.com") test | ||
身份登录 | ||
( | ||
%a(href="/logout")> log out | ||
) | ||
|
||
.message-box | ||
%h2 您的主题正在更换... | ||
%p | ||
完成主题更换可能需要一两分钟的时间。您可以检查 | ||
%a(href="http://medhurst-shields-and-kunde7896.myshopify.com") 您的商店 | ||
看看是否已经更新为新的主题或者返回 | ||
=succeed "." do | ||
%a(href="/") 主题商店 |
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
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,3 @@ | ||
# encoding: utf-8 | ||
require 'oauth2/provider' | ||
OAuth2::Provider.realm = 'ShopQi' |
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
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,35 @@ | ||
class CreateOauth2Provider < ActiveRecord::Migration | ||
def self.up | ||
create_table :oauth2_clients, force: true do |t| | ||
t.string :oauth2_client_owner_type | ||
t.integer :oauth2_client_owner_id | ||
t.string :name | ||
t.string :client_id | ||
t.string :client_secret_hash | ||
t.string :redirect_uri | ||
t.timestamps | ||
end | ||
add_index :oauth2_clients, :client_id | ||
|
||
create_table :oauth2_authorizations, force: true do |t| | ||
t.string :oauth2_resource_owner_type | ||
t.integer :oauth2_resource_owner_id | ||
t.belongs_to :client | ||
t.string :scope | ||
t.string :code, limit: 40 | ||
t.string :access_token_hash, limit: 40 | ||
t.string :refresh_token_hash, limit: 40 | ||
t.datetime :expires_at | ||
t.timestamps | ||
end | ||
add_index :oauth2_authorizations, [:client_id, :code] | ||
add_index :oauth2_authorizations, [:access_token_hash] | ||
add_index :oauth2_authorizations, [:client_id, :access_token_hash] | ||
add_index :oauth2_authorizations, [:client_id, :refresh_token_hash] | ||
end | ||
|
||
def self.down | ||
drop_table :oauth2_clients | ||
drop_table :oauth2_authorizations | ||
end | ||
end |
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
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,17 @@ | ||
require 'active_record' | ||
|
||
module OAuth2 | ||
module Model | ||
autoload :ClientOwner, ROOT + '/oauth2/model/client_owner' | ||
autoload :ResourceOwner, ROOT + '/oauth2/model/resource_owner' | ||
autoload :Hashing, ROOT + '/oauth2/model/hashing' | ||
autoload :Authorization, ROOT + '/oauth2/model/authorization' | ||
autoload :Client, ROOT + '/oauth2/model/client' | ||
autoload :Schema, ROOT + '/oauth2/model/schema' | ||
|
||
def self.find_access_token(access_token) | ||
Authorization.find_by_access_token_hash(OAuth2.hashify(access_token)) | ||
end | ||
end | ||
end | ||
|
Oops, something went wrong.