Remove already packaged embedded modules

This commit is contained in:
Sruthi Chandran 2019-09-05 18:58:42 +05:30
parent 1446d8385e
commit deb547ef73
77 changed files with 4 additions and 2139 deletions

5
debian/control vendored
View file

@ -67,6 +67,8 @@ Depends: ${shlibs:Depends}, ${misc:Depends},
ruby-omniauth-crowd (>= 2.2~),
ruby-omniauth-authentiq (>= 0.3.3~),
ruby-omniauth-openid-connect (>= 0.3~),
ruby-omniauth-ultraauth (>= 0.0.2~),
ruby-omniauth-salesforce (>= 1.0.5~),
ruby-rack-oauth2 (>= 1.9.3~),
# ruby-jwt (>= 2.1~),
# Spam and anti-bot protection
@ -95,6 +97,7 @@ Depends: ${shlibs:Depends}, ${misc:Depends},
# GraphQL API
ruby-graphql (>= 1.8~),
ruby-graphiql-rails (>= 1.4.10~),
ruby-apollo-upload-server (>= 2.0.0.beta3~),
# Disable strong_params so that Mash does not respond to :permitted?
ruby-hashie-forbidden-attributes,
# Pagination
@ -229,7 +232,7 @@ Depends: ${shlibs:Depends}, ${misc:Depends},
yarnpkg,
ruby-rack-proxy (>= 0.6~),
#
# ruby-sassc-rails (>= 2.1~),
ruby-sassc-rails (>= 2.1~),
ruby-sassc (>= 2.0~),
ruby-uglifier (>= 2.7.2~),
libjs-uglify (<< 3.0~),

View file

@ -1,8 +0,0 @@
/.bundle/
/.yardoc
/_yardoc/
/coverage/
/doc/
/pkg/
/spec/reports/
/tmp/

View file

@ -1 +0,0 @@
--require spec_helper

View file

@ -1,9 +0,0 @@
language: ruby
cache: bundler
rvm:
- 2.3.8
- 2.4
- 2.4.3
- 2.5
install: bundle install --jobs=3 --retry=3
script: bundle exec rspec

View file

@ -1,74 +0,0 @@
# Contributor Covenant Code of Conduct
## Our Pledge
In the interest of fostering an open and welcoming environment, we as
contributors and maintainers pledge to making participation in our project and
our community a harassment-free experience for everyone, regardless of age, body
size, disability, ethnicity, gender identity and expression, level of experience,
nationality, personal appearance, race, religion, or sexual identity and
orientation.
## Our Standards
Examples of behavior that contributes to creating a positive environment
include:
* Using welcoming and inclusive language
* Being respectful of differing viewpoints and experiences
* Gracefully accepting constructive criticism
* Focusing on what is best for the community
* Showing empathy towards other community members
Examples of unacceptable behavior by participants include:
* The use of sexualized language or imagery and unwelcome sexual attention or
advances
* Trolling, insulting/derogatory comments, and personal or political attacks
* Public or private harassment
* Publishing others' private information, such as a physical or electronic
address, without explicit permission
* Other conduct which could reasonably be considered inappropriate in a
professional setting
## Our Responsibilities
Project maintainers are responsible for clarifying the standards of acceptable
behavior and are expected to take appropriate and fair corrective action in
response to any instances of unacceptable behavior.
Project maintainers have the right and responsibility to remove, edit, or
reject comments, commits, code, wiki edits, issues, and other contributions
that are not aligned to this Code of Conduct, or to ban temporarily or
permanently any contributor for other behaviors that they deem inappropriate,
threatening, offensive, or harmful.
## Scope
This Code of Conduct applies both within project spaces and in public spaces
when an individual is representing the project or its community. Examples of
representing a project or community include using an official project e-mail
address, posting via an official social media account, or acting as an appointed
representative at an online or offline event. Representation of a project may be
further defined and clarified by project maintainers.
## Enforcement
Instances of abusive, harassing, or otherwise unacceptable behavior may be
reported by contacting the project team at ifuelen@gmail.com. All
complaints will be reviewed and investigated and will result in a response that
is deemed necessary and appropriate to the circumstances. The project team is
obligated to maintain confidentiality with regard to the reporter of an incident.
Further details of specific enforcement policies may be posted separately.
Project maintainers who do not follow or enforce the Code of Conduct in good
faith may face temporary or permanent repercussions as determined by other
members of the project's leadership.
## Attribution
This Code of Conduct is adapted from the [Contributor Covenant][homepage], version 1.4,
available at [http://contributor-covenant.org/version/1/4][version]
[homepage]: http://contributor-covenant.org
[version]: http://contributor-covenant.org/version/1/4/

View file

@ -1,6 +0,0 @@
source 'https://rubygems.org'
git_source(:github) { |repo_name| "https://github.com/#{repo_name}" }
# Specify your gem's dependencies in apollo_upload_server.gemspec
gemspec

View file

@ -1,144 +0,0 @@
PATH
remote: .
specs:
apollo_upload_server (2.0.0.beta.3)
graphql (>= 1.8)
rails (>= 4.2)
GEM
remote: https://rubygems.org/
specs:
actioncable (5.2.2)
actionpack (= 5.2.2)
nio4r (~> 2.0)
websocket-driver (>= 0.6.1)
actionmailer (5.2.2)
actionpack (= 5.2.2)
actionview (= 5.2.2)
activejob (= 5.2.2)
mail (~> 2.5, >= 2.5.4)
rails-dom-testing (~> 2.0)
actionpack (5.2.2)
actionview (= 5.2.2)
activesupport (= 5.2.2)
rack (~> 2.0)
rack-test (>= 0.6.3)
rails-dom-testing (~> 2.0)
rails-html-sanitizer (~> 1.0, >= 1.0.2)
actionview (5.2.2)
activesupport (= 5.2.2)
builder (~> 3.1)
erubi (~> 1.4)
rails-dom-testing (~> 2.0)
rails-html-sanitizer (~> 1.0, >= 1.0.3)
activejob (5.2.2)
activesupport (= 5.2.2)
globalid (>= 0.3.6)
activemodel (5.2.2)
activesupport (= 5.2.2)
activerecord (5.2.2)
activemodel (= 5.2.2)
activesupport (= 5.2.2)
arel (>= 9.0)
activestorage (5.2.2)
actionpack (= 5.2.2)
activerecord (= 5.2.2)
marcel (~> 0.3.1)
activesupport (5.2.2)
concurrent-ruby (~> 1.0, >= 1.0.2)
i18n (>= 0.7, < 2)
minitest (~> 5.1)
tzinfo (~> 1.1)
arel (9.0.0)
builder (3.2.3)
concurrent-ruby (1.1.4)
crass (1.0.4)
diff-lcs (1.3)
erubi (1.8.0)
globalid (0.4.2)
activesupport (>= 4.2.0)
graphql (1.8.13)
i18n (1.5.3)
concurrent-ruby (~> 1.0)
loofah (2.2.3)
crass (~> 1.0.2)
nokogiri (>= 1.5.9)
mail (2.7.1)
mini_mime (>= 0.1.1)
marcel (0.3.3)
mimemagic (~> 0.3.2)
method_source (0.9.2)
mimemagic (0.3.3)
mini_mime (1.0.1)
mini_portile2 (2.4.0)
minitest (5.11.3)
nio4r (2.3.1)
nokogiri (1.10.1)
mini_portile2 (~> 2.4.0)
rack (2.0.6)
rack-test (1.1.0)
rack (>= 1.0, < 3)
rails (5.2.2)
actioncable (= 5.2.2)
actionmailer (= 5.2.2)
actionpack (= 5.2.2)
actionview (= 5.2.2)
activejob (= 5.2.2)
activemodel (= 5.2.2)
activerecord (= 5.2.2)
activestorage (= 5.2.2)
activesupport (= 5.2.2)
bundler (>= 1.3.0)
railties (= 5.2.2)
sprockets-rails (>= 2.0.0)
rails-dom-testing (2.0.3)
activesupport (>= 4.2.0)
nokogiri (>= 1.6)
rails-html-sanitizer (1.0.4)
loofah (~> 2.2, >= 2.2.2)
railties (5.2.2)
actionpack (= 5.2.2)
activesupport (= 5.2.2)
method_source
rake (>= 0.8.7)
thor (>= 0.19.0, < 2.0)
rake (10.5.0)
rspec (3.8.0)
rspec-core (~> 3.8.0)
rspec-expectations (~> 3.8.0)
rspec-mocks (~> 3.8.0)
rspec-core (3.8.0)
rspec-support (~> 3.8.0)
rspec-expectations (3.8.2)
diff-lcs (>= 1.2.0, < 2.0)
rspec-support (~> 3.8.0)
rspec-mocks (3.8.0)
diff-lcs (>= 1.2.0, < 2.0)
rspec-support (~> 3.8.0)
rspec-support (3.8.0)
sprockets (3.7.2)
concurrent-ruby (~> 1.0)
rack (> 1, < 3)
sprockets-rails (3.2.1)
actionpack (>= 4.0)
activesupport (>= 4.0)
sprockets (>= 3.0.0)
thor (0.20.3)
thread_safe (0.3.6)
tzinfo (1.2.5)
thread_safe (~> 0.1)
websocket-driver (0.7.0)
websocket-extensions (>= 0.1.0)
websocket-extensions (0.1.3)
PLATFORMS
ruby
DEPENDENCIES
apollo_upload_server!
bundler (~> 1.16)
rake (~> 10.0)
rspec (~> 3.5)
BUNDLED WITH
1.17.2

View file

@ -1,21 +0,0 @@
The MIT License (MIT)
Copyright (c) 2017 Artur Plysyuk
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in
all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
THE SOFTWARE.

View file

@ -1,53 +0,0 @@
# ApolloUploadServer
Middleware which allows you to upload files using [graphql-ruby](https://github.com/rmosolgo/graphql-ruby), [apollo-upload-client](https://github.com/jaydenseric/apollo-upload-client) and Ruby on Rails.
Note: this implementation uses [v2 of the GraphQL multipart request spec](https://github.com/jaydenseric/graphql-multipart-request-spec/tree/v2.0.0-alpha.2), so you should use apollo-upload-client library >= v7.0.0-alpha.3. If you need support for [v1 of the GraphQL multipart request spec](https://github.com/jaydenseric/graphql-multipart-request-spec/tree/v1.0.0), you must
use [version 1.0.0](https://github.com/jetruby/apollo_upload_server-ruby/tree/1.0.0) of this gem.
## Installation
Add this line to your application's Gemfile:
```ruby
gem 'apollo_upload_server', '2.0.0.beta.3'
```
And then execute:
$ bundle
Or install it yourself as:
$ gem install apollo_upload_server
Middleware will be used automatically.
Gem adds custom `Upload` type to your GraphQL types.
Use `ApolloUploadServer::Upload` type for your file as input field:
```ruby
input_field :file, ApolloUploadServer::Upload
```
That's all folks!
## Contributing
Bug reports and pull requests are welcome on GitHub at https://github.com/jetruby/apollo_upload_server-ruby. This project is intended to be a safe, welcoming space for collaboration, and contributors are expected to adhere to the [Contributor Covenant](http://contributor-covenant.org) code of conduct.
## License
The gem is available as open source under the terms of the [MIT License](https://opensource.org/licenses/MIT).
## Code of Conduct
Everyone interacting in the ApolloUploadServer projects codebases, issue trackers, chat rooms and mailing lists is expected to follow the [code of conduct](https://github.com/jetruby/apollo_upload_server-ruby/blob/master/CODE_OF_CONDUCT.md).
## About JetRuby
ApolloUploadServer is maintained and founded by JetRuby Agency.
We love open source software!
See [our projects][portfolio] or
[contact us][contact] to design, develop, and grow your product.
[portfolio]: http://jetruby.com/portfolio/
[contact]: http://jetruby.com/#contactUs

View file

@ -1,2 +0,0 @@
require 'bundler/gem_tasks'
task default: :spec

View file

@ -1,29 +0,0 @@
lib = File.expand_path('../lib', __FILE__)
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
require 'apollo_upload_server/version'
Gem::Specification.new do |spec|
spec.name = 'apollo_upload_server'
spec.version = ApolloUploadServer::VERSION
spec.authors = ['JetRuby']
spec.email = ['engineering@jetruby.com']
spec.summary = 'Middleware which allows you to upload files using graphql and multipart/form-data.'
spec.description = 'apollo-upload-server implementation for Ruby on Rails as middleware.'
spec.homepage = 'https://github.com/jetruby/apollo_upload_server-ruby'
spec.license = 'MIT'
spec.files = `git ls-files -z`.split("\x0").reject do |f|
f.match(%r{^(test|spec|features)/})
end
spec.bindir = 'bin'
spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) }
spec.require_paths = ['lib']
spec.add_dependency 'rails', '>= 4.2'
spec.add_dependency 'graphql', '>= 1.8'
spec.add_development_dependency 'bundler', '~> 1.16'
spec.add_development_dependency 'rake', '~> 10.0'
spec.add_development_dependency 'rspec', '~> 3.5'
end

View file

@ -1,14 +0,0 @@
#!/usr/bin/env ruby
require 'bundler/setup'
require 'apollo_upload_server'
# You can add fixtures and/or initialization code here to make experimenting
# with your gem easier. You can also use a different console, if you like.
# (If you use this, don't forget to add pry to your Gemfile!)
# require "pry"
# Pry.start
require 'irb'
IRB.start(__FILE__)

View file

@ -1,8 +0,0 @@
#!/usr/bin/env bash
set -euo pipefail
IFS=$'\n\t'
set -vx
bundle install
# Do any other automated setup that you need to do here

View file

@ -1,5 +0,0 @@
require 'apollo_upload_server/graphql_data_builder'
require 'apollo_upload_server/middleware'
require 'apollo_upload_server/version'
require 'apollo_upload_server/railtie'
require 'apollo_upload_server/upload'

View file

@ -1,80 +0,0 @@
# frozen_string_literal: true
require 'json'
require 'apollo_upload_server/wrappers/uploaded_file'
module ApolloUploadServer
class GraphQLDataBuilder
def call(params)
operations = safe_json_parse(params['operations'])
file_mapper = safe_json_parse(params['map'])
return nil if operations.nil? || file_mapper.nil?
if operations.is_a?(Hash)
single_transformation(file_mapper, operations, params)
else
{ '_json' => multiple_transformation(file_mapper, operations, params) }
end
end
private
def single_transformation(file_mapper, operations, params)
operations = operations.dup
file_mapper.each do |file_index, paths|
paths.each do |path|
splited_path = path.split('.')
# splited_path => 'variables.input.profile_photo'; splited_path[0..-2] => ['variables', 'input']
# dig from first to penultimate key, and merge last key with value as file
field = get_parent_field(operations, splited_path)
assign_file(field, splited_path, params[file_index])
end
end
operations
end
def multiple_transformation(file_mapper, operations, params)
operations = operations.dup
file_mapper.each do |file_index, paths|
paths.each do |path|
splited_path = path.split('.')
# dig from second to penultimate key, and merge last key with value as file to operation with first key index
field = operations[splited_path.first.to_i].dig(*splited_path[1..-2])
assign_file(field, splited_path, params[file_index])
end
end
operations
end
def safe_json_parse(data)
JSON.parse(data)
rescue JSON::ParserError
nil
end
def get_parent_field(operations, splited_path)
# returns parent element of file field
splited_path[0..-2].inject(operations) do |element, key|
case element
when Array
element[Integer(key)]
else
element[key]
end
end
end
def assign_file(field, splited_path, file)
wrapped_file = Wrappers::UploadedFile.new(file)
if field.is_a? Hash
field.merge!(splited_path.last => wrapped_file)
elsif field.is_a? Array
field[splited_path.last.to_i] = wrapped_file
end
end
end
end

View file

@ -1,23 +0,0 @@
require 'apollo_upload_server/graphql_data_builder'
module ApolloUploadServer
class Middleware
def initialize(app)
@app = app
end
def call(env)
request = ActionDispatch::Request.new(env)
params = request.params
if env['CONTENT_TYPE'].to_s.include?('multipart/form-data') && params['operations'].present? && params['map'].present?
result = GraphQLDataBuilder.new.call(request.params)
result&.each do |key, value|
request.update_param(key, value)
end
end
@app.call(env)
end
end
end

View file

@ -1,9 +0,0 @@
require 'apollo_upload_server/middleware'
module ApolloUploadServer
class Railtie < Rails::Railtie
initializer 'apollo_upload_server.apply_middleware' do |app|
app.middleware.use Middleware
end
end
end

View file

@ -1,17 +0,0 @@
# frozen_string_literal: true
require 'graphql'
module ApolloUploadServer
class Upload < GraphQL::Schema::Scalar
graphql_name "Upload"
def self.coerce_input(value, _ctx)
value
end
def self.coerse_result(value, _ctx)
value
end
end
end

View file

@ -1,3 +0,0 @@
module ApolloUploadServer
VERSION = '2.0.0.beta.3'.freeze
end

View file

@ -1,18 +0,0 @@
# frozen_string_literal: true
require 'delegate'
require 'action_dispatch/http/upload'
module ApolloUploadServer
module Wrappers
class UploadedFile < DelegateClass(::ActionDispatch::Http::UploadedFile)
def initialize(wrapped_foo)
super
end
def as_json(options = nil)
instance_values.except('tempfile').as_json(options)
end
end
end
end

View file

@ -1,17 +0,0 @@
*.gem
*.rbc
.bundle
.config
.yardoc
Gemfile.lock
InstalledFiles
_yardoc
coverage
doc/
lib/bundler/man
/pkg
rdoc
spec/reports
test/tmp
test/version_tmp
tmp

View file

@ -1 +0,0 @@
--colour

View file

@ -1 +0,0 @@
rvm use 1.9.2-p290@omniauth-salesforce --create

View file

@ -1,12 +0,0 @@
source 'https://rubygems.org'
# Specify your gem's dependencies in omniauth-salesforce.gemspec
gemspec
group :development, :test do
gem 'guard'
gem 'guard-rspec'
gem 'guard-bundler'
gem 'rb-fsevent'
gem 'growl'
end

View file

@ -1,10 +0,0 @@
guard 'rspec', :version => 2 do
watch(%r{^spec/.+_spec\.rb$})
watch(%r{^lib/(.+)\.rb$}) { |m| "spec/#{m[1]}_spec.rb" }
watch('spec/spec_helper.rb') { "spec" }
end
guard 'bundler' do
watch('Gemfile')
watch('omniauth-salesforce.gemspec')
end

View file

@ -1,5 +0,0 @@
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

View file

@ -1,49 +0,0 @@
# omniauth-salesforce
[OmniAuth](https://github.com/intridea/omniauth) Strategy for [salesforce.com](salesforce.com).
Note: This is a fork of the [original](https://github.com/richardvanhook/omniauth-salesforce) project and is now the main repository for the omniauth-salesforce gem.
## See it in action
[http://omniauth-salesforce-example.herokuapp.com](http://omniauth-salesforce-example.herokuapp.com)
[Source for above app](https://github.com/richardvanhook/omniauth-salesforce-example)
## Basic Usage
```ruby
require "sinatra"
require "omniauth"
require "omniauth-salesforce"
class MyApplication < Sinatra::Base
use Rack::Session
use OmniAuth::Builder do
provider :salesforce, ENV['SALESFORCE_KEY'], ENV['SALESFORCE_SECRET']
end
end
```
## Including other sites
```ruby
use OmniAuth::Builder do
provider :salesforce,
ENV['SALESFORCE_KEY'],
ENV['SALESFORCE_SECRET']
provider OmniAuth::Strategies::SalesforceSandbox,
ENV['SALESFORCE_SANDBOX_KEY'],
ENV['SALESFORCE_SANDBOX_SECRET']
provider OmniAuth::Strategies::SalesforcePreRelease,
ENV['SALESFORCE_PRERELEASE_KEY'],
ENV['SALESFORCE_PRERELEASE_SECRET']
provider OmniAuth::Strategies::DatabaseDotCom,
ENV['DATABASE_DOT_COM_KEY'],
ENV['DATABASE_DOT_COM_SECRET']
end
```
## Resources
* [Article: Digging Deeper into OAuth 2.0 on Force.com](http://wiki.developerforce.com/index.php/Digging_Deeper_into_OAuth_2.0_on_Force.com)

View file

@ -1,12 +0,0 @@
#!/usr/bin/env rake
require "bundler/gem_tasks"
require 'rspec/core/rake_task'
desc 'Default: run specs.'
task :default => :spec
desc "Run specs"
RSpec::Core::RakeTask.new
desc 'Run specs'
task :default => :spec

View file

@ -1,2 +0,0 @@
require "omniauth-salesforce/version"
require 'omniauth/strategies/salesforce'

View file

@ -1,5 +0,0 @@
module OmniAuth
module Salesforce
VERSION = "1.0.5"
end
end

View file

@ -1,97 +0,0 @@
require 'omniauth-oauth2'
require 'openssl'
require 'base64'
module OmniAuth
module Strategies
class Salesforce < OmniAuth::Strategies::OAuth2
MOBILE_USER_AGENTS = 'webos|ipod|iphone|ipad|android|blackberry|mobile'
option :client_options, {
:site => 'https://login.salesforce.com',
:authorize_url => '/services/oauth2/authorize',
:token_url => '/services/oauth2/token'
}
option :authorize_options, [
:scope,
:display,
:immediate,
:state,
:prompt
]
def request_phase
req = Rack::Request.new(@env)
options.update(req.params)
ua = req.user_agent.to_s
if !options.has_key?(:display)
mobile_request = ua.downcase =~ Regexp.new(MOBILE_USER_AGENTS)
options[:display] = mobile_request ? 'touch' : 'page'
end
super
end
def auth_hash
signed_value = access_token.params['id'] + access_token.params['issued_at']
raw_expected_signature = OpenSSL::HMAC.digest('sha256', options.client_secret.to_s, signed_value)
expected_signature = Base64.strict_encode64 raw_expected_signature
signature = access_token.params['signature']
fail! "Salesforce user id did not match signature!" unless signature == expected_signature
super
end
uid { raw_info['id'] }
info do
{
'name' => raw_info['display_name'],
'email' => raw_info['email'],
'nickname' => raw_info['nick_name'],
'first_name' => raw_info['first_name'],
'last_name' => raw_info['last_name'],
'location' => '',
'description' => '',
'image' => raw_info['photos']['thumbnail'] + "?oauth_token=#{access_token.token}",
'phone' => '',
'urls' => raw_info['urls']
}
end
credentials do
hash = {'token' => access_token.token}
hash.merge!('instance_url' => access_token.params["instance_url"])
hash.merge!('refresh_token' => access_token.refresh_token) if access_token.refresh_token
hash
end
def raw_info
access_token.options[:mode] = :header
@raw_info ||= access_token.post(access_token['id']).parsed
end
extra do
raw_info.merge({
'instance_url' => access_token.params['instance_url'],
'pod' => access_token.params['instance_url'],
'signature' => access_token.params['signature'],
'issued_at' => access_token.params['issued_at']
})
end
end
class SalesforceSandbox < OmniAuth::Strategies::Salesforce
default_options[:client_options][:site] = 'https://test.salesforce.com'
end
class DatabaseDotCom < OmniAuth::Strategies::Salesforce
default_options[:client_options][:site] = 'https://login.database.com'
end
class SalesforcePreRelease < OmniAuth::Strategies::Salesforce
default_options[:client_options][:site] = 'https://prerellogin.pre.salesforce.com/'
end
end
end

View file

@ -1,25 +0,0 @@
# -*- encoding: utf-8 -*-
require File.expand_path('../lib/omniauth-salesforce/version', __FILE__)
Gem::Specification.new do |gem|
gem.authors = ["Richard Vanhook"]
gem.email = ["rvanhook@salesforce.com"]
gem.description = %q{OmniAuth strategy for salesforce.com.}
gem.summary = %q{OmniAuth strategy for salesforce.com.}
gem.homepage = "https://github.com/realdoug/omniauth-salesforce"
gem.executables = `git ls-files -- bin/*`.split("\n").map{ |f| File.basename(f) }
gem.files = `git ls-files`.split("\n")
gem.test_files = `git ls-files -- {test,spec,features}/*`.split("\n")
gem.name = "omniauth-salesforce"
gem.require_paths = ["lib"]
gem.version = OmniAuth::Salesforce::VERSION
gem.license = "MIT"
gem.add_dependency 'omniauth', '~> 1.0'
gem.add_dependency 'omniauth-oauth2', '~> 1.0'
gem.add_development_dependency 'rspec', '~> 2.7'
gem.add_development_dependency 'rack-test'
gem.add_development_dependency 'simplecov'
gem.add_development_dependency 'webmock'
end

View file

@ -1,217 +0,0 @@
require 'spec_helper'
describe OmniAuth::Strategies::Salesforce do
strategy = nil
before do
OmniAuth.config.test_mode = true
rack_app = []
rack_app.stub :call
strategy = OmniAuth::Strategies::Salesforce.new rack_app, 'Consumer Key', 'Consumer Secret'
end
describe "request_phase" do
env = nil
before do
env = {
'rack.session' => {},
'HTTP_USER_AGENT' => 'unknown',
'REQUEST_METHOD' => 'GET',
'rack.input' => '',
'rack.url_scheme' => 'http',
'SERVER_NAME' => 'server.example',
'QUERY_STRING' => 'code=xxxx',
'SCRIPT_NAME' => '',
'SERVER_PORT' => 80
}
end
context "when using a mobile browser" do
user_agents = {
:Pre => "Mozilla/5.0 (webOS/1.4.0; U; en-US) AppleWebKit/532.2 (KHTML, like Gecko) Version/1.0 Safari/532.2 Pre/1.1",
:iPod => "Mozilla/5.0 (iPod; U; CPU like Mac OS X; en) AppleWebKit/420.1 (KHTML, like Gecko) Version/3.0 Mobile/4A93 Safari/419.3",
:iPhone => "Mozilla/5.0 (iPhone; U; CPU like Mac OS X; en) AppleWebKit/420+ (KHTML, like Gecko) Version/3.0 Mobile/1A543 Safari/419.3",
:iPad => "Mozilla/5.0 (iPad; U; CPU OS 3_2 like Mac OS X; en-us) AppleWebKit/531.21.10 (KHTML, like Gecko) Version/4.0.4 Mobile/7B334b Safari/531.21.10",
:Nexus => "Mozilla/5.0 (Linux; U; Android 2.2; en-us; Nexus One Build/FRF91) AppleWebKit/533.1 (KHTML, like Gecko) Version/4.0 Mobile Safari/533.1",
:myTouch => "Mozilla/5.0 (Linux; U; Android 1.6; en-us; WOWMobile myTouch 3G Build/unknown) AppleWebKit/528.5+ (KHTML, like Gecko) Version/3.1.2 Mobile Safari/525.20.1",
:Storm => "BlackBerry9530/4.7.0.148 Profile/MIDP-2.0 Configuration/CLDC-1.1 VendorID/105",
:Torch => "Mozilla/5.0 (BlackBerry; U; BlackBerry 9810; en-US) AppleWebKit/534.11+ (KHTML, like Gecko) Version/7.0.0 Mobile Safari/534.11+",
:generic_mobile => "some mobile device"
}
user_agents.each_pair do |name, agent|
context "with the user agent from a #{name.to_s}" do
before do
env['HTTP_USER_AGENT'] = agent
strategy.call!(env)
strategy.request_phase
end
subject {strategy.options}
it "sets the :display option to 'touch'" do
subject[:display].should == 'touch'
end
end
end
end
context "when using a desktop browser" do
user_agents = {
:Chrome => "Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/535.21 (KHTML, like Gecko) Chrome/19.0.1042.0 Safari/535.21",
:Safari => "Mozilla/5.0 (Macintosh; U; Intel Mac OS X 10_6_8; de-at) AppleWebKit/533.21.1 (KHTML, like Gecko) Version/5.0.5 Safari/533.21.1",
:IE => "Mozilla/5.0 (compatible; MSIE 8.0; Windows NT 6.0; Trident/4.0; WOW64; Trident/4.0; SLCC2; .NET CLR 2.0.50727; .NET CLR 3.5.30729; .NET CLR 3.0.30729; .NET CLR 1.0.3705; .NET CLR 1.1.4322)",
:anything_else => "unknown"
}
user_agents.each_pair do |name, agent|
context "with the user agent from #{name.to_s}" do
before do
env['HTTP_USER_AGENT'] = agent
strategy.call!(env)
strategy.request_phase
end
subject {strategy.options}
it "sets the :display option to 'page'" do
subject[:display].should == 'page'
end
end
end
end
end
describe "callback phase" do
raw_info = nil
before do
raw_info = {
'id' => 'salesforce id',
'display_name' => 'display name',
'email' => 'email',
'nick_name' => 'nick name',
'first_name' => 'first name',
'last_name' => 'last name',
'photos' => {'thumbnail' => '/thumbnail/url'},
'urls'=> {
"enterprise" => "https://salesforce.example/services",
"metadata" => "https://salesforce.example/services"
}
}
client = OAuth2::Client.new 'id', 'secret', {:site => 'example.com'}
access_token = OAuth2::AccessToken.from_hash client, {
'access_token' => 'token',
'instance_url' => 'http://instance.salesforce.example',
'signature' => 'invalid',
'issued_at' => '1296458209517'
}
strategy.stub(:raw_info) { raw_info }
strategy.stub(:access_token) { access_token }
end
describe "uid" do
it "sets the id" do
strategy.uid.should == raw_info['id']
end
end
describe "info" do
subject { strategy.info }
it "returns an info hash" do
subject.should_not be_nil
end
it "sets name" do
subject['name'].should == raw_info['display_name']
end
it "sets email" do
subject['email'].should == raw_info['email']
end
it "sets nickname" do
subject['nickname'].should == raw_info['nick_name']
end
it "sets first_name" do
subject['first_name'].should == raw_info['first_name']
end
it "sets last_name" do
subject['last_name'].should == raw_info['last_name']
end
it "sets location" do
subject['location'].should == ''
end
it "sets description" do
subject['description'].should == ''
end
it "sets image" do
subject['image'].should == raw_info['photos']['thumbnail'] + "?oauth_token=#{strategy.access_token.token}"
end
it "sets phone" do
subject['phone'].should == ''
end
it "sets urls" do
subject['urls'].should == raw_info['urls']
end
end
describe "credentials" do
subject { strategy.credentials }
it "sets token" do
subject['token'].should == strategy.access_token.token
end
it "sets instance_url" do
subject['instance_url'].should == strategy.access_token.params["instance_url"]
end
context "given a refresh token" do
it "sets refresh_token" do
subject['refresh_token'].should == strategy.access_token.refresh_token
end
end
context "when not given a refresh token" do
it "does not set a refresh token" do
subject['refresh_token'].should be_nil
end
end
end
describe "extra" do
subject { strategy.extra }
it "sets instance_url" do
subject['instance_url'].should == strategy.access_token.params['instance_url']
end
it "sets pod" do
subject['pod'].should == strategy.access_token.params['instance_url']
end
it "sets signature" do
subject['signature'].should == strategy.access_token.params['signature']
end
it "sets issued_at" do
subject['issued_at'].should == strategy.access_token.params['issued_at']
end
end
describe "user id validation" do
client_id = nil
issued_at = nil
signature = nil
instance_url = 'http://instance.salesforce.example'
before do
client_id = "https://login.salesforce.com/id/00Dd0000000d45TEBQ/005d0000000fyGPCCY"
issued_at = "1331142541514"
signature = Base64.strict_encode64(OpenSSL::HMAC.digest('sha256', strategy.options.client_secret.to_s, client_id + issued_at))
end
context "when the signature does not match" do
before do
access_token = OAuth2::AccessToken.from_hash strategy.access_token.client, {
'id' => 'forged client id',
'issued_at' => issued_at,
'instance_url' => 'http://instance.salesforce.example',
'signature' => signature
}
strategy.stub(:access_token) { access_token }
end
it "should call fail!" do
strategy.should_receive(:fail!)
strategy.auth_hash
end
end
context "when the signature does match" do
before do
access_token = OAuth2::AccessToken.from_hash strategy.access_token.client, {
'id' => client_id,
'issued_at' => issued_at,
'instance_url' => 'http://instance.salesforce.example',
'signature' => signature
}
strategy.stub(:access_token) { access_token }
end
it "should not fail" do
strategy.should_not_receive(:fail!)
strategy.auth_hash
end
end
end
end
end

View file

@ -1,16 +0,0 @@
$:.unshift File.expand_path('..', __FILE__)
$:.unshift File.expand_path('../../lib', __FILE__)
require 'simplecov'
SimpleCov.start
require 'rspec'
require 'rack/test'
require 'webmock/rspec'
require 'omniauth'
require 'omniauth-salesforce'
RSpec.configure do |config|
config.include WebMock::API
config.include Rack::Test::Methods
config.extend OmniAuth::Test::StrategyMacros, :type => :strategy
end

View file

@ -1,11 +0,0 @@
/.bundle/
/.yardoc
/_yardoc/
/coverage/
/doc/
/pkg/
/spec/reports/
/tmp/
# rspec failure tracking
.rspec_status

View file

@ -1,3 +0,0 @@
--format documentation
--color
--require spec_helper

View file

@ -1,7 +0,0 @@
---
sudo: false
language: ruby
cache: bundler
rvm:
- 2.5.3
before_install: gem install bundler -v 1.17.3

View file

@ -1,6 +0,0 @@
source "https://rubygems.org"
git_source(:github) {|repo_name| "https://github.com/#{repo_name}" }
# Specify your gem's dependencies in omniauth-ultraauth.gemspec
gemspec

View file

@ -1,101 +0,0 @@
PATH
remote: .
specs:
omniauth-ultraauth (0.0.1)
omniauth_openid_connect (~> 0.3.0)
GEM
remote: https://rubygems.org/
specs:
activemodel (5.2.2)
activesupport (= 5.2.2)
activesupport (5.2.2)
concurrent-ruby (~> 1.0, >= 1.0.2)
i18n (>= 0.7, < 2)
minitest (~> 5.1)
tzinfo (~> 1.1)
addressable (2.6.0)
public_suffix (>= 2.0.2, < 4.0)
aes_key_wrap (1.0.1)
attr_required (1.0.1)
bindata (2.4.4)
concurrent-ruby (1.1.4)
diff-lcs (1.3)
hashie (3.6.0)
httpclient (2.8.3)
i18n (1.5.3)
concurrent-ruby (~> 1.0)
json-jwt (1.10.0)
activesupport (>= 4.2)
aes_key_wrap
bindata
mail (2.7.1)
mini_mime (>= 0.1.1)
mini_mime (1.0.1)
minitest (5.11.3)
omniauth (1.9.0)
hashie (>= 3.4.6, < 3.7.0)
rack (>= 1.6.2, < 3)
omniauth_openid_connect (0.3.0)
addressable (~> 2.5)
omniauth (~> 1.3)
openid_connect (~> 1.1)
openid_connect (1.1.6)
activemodel
attr_required (>= 1.0.0)
json-jwt (>= 1.5.0)
rack-oauth2 (>= 1.6.1)
swd (>= 1.0.0)
tzinfo
validate_email
validate_url
webfinger (>= 1.0.1)
public_suffix (3.0.3)
rack (2.0.6)
rack-oauth2 (1.9.3)
activesupport
attr_required
httpclient
json-jwt (>= 1.9.0)
rack
rake (10.5.0)
rspec (3.8.0)
rspec-core (~> 3.8.0)
rspec-expectations (~> 3.8.0)
rspec-mocks (~> 3.8.0)
rspec-core (3.8.0)
rspec-support (~> 3.8.0)
rspec-expectations (3.8.2)
diff-lcs (>= 1.2.0, < 2.0)
rspec-support (~> 3.8.0)
rspec-mocks (3.8.0)
diff-lcs (>= 1.2.0, < 2.0)
rspec-support (~> 3.8.0)
rspec-support (3.8.0)
swd (1.1.2)
activesupport (>= 3)
attr_required (>= 0.0.5)
httpclient (>= 2.4)
thread_safe (0.3.6)
tzinfo (1.2.5)
thread_safe (~> 0.1)
validate_email (0.1.6)
activemodel (>= 3.0)
mail (>= 2.2.5)
validate_url (1.0.4)
activemodel (>= 3.0.0)
webfinger (1.1.0)
activesupport
httpclient (>= 2.4)
PLATFORMS
ruby
DEPENDENCIES
bundler (~> 1.17)
omniauth-ultraauth!
rake (~> 10.0)
rspec (~> 3.0)
BUNDLED WITH
1.17.3

View file

@ -1,21 +0,0 @@
The MIT License (MIT)
Copyright (c) 2019 Kartikey Tanna
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in
all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
THE SOFTWARE.

View file

@ -1,78 +0,0 @@
# OmniAuth::UltraAuth
## Installation
Add the following to Gemfile:
gem 'omniauth-ultraauth'
Install it using Bundler:
$ bundle
## Before You Begin
You will require to create an application on https://ultraauth.com
1. Create an account and login to https://ultraauth.com
2. Go to "Create an App" and select "Ruby on Rails"
3. Click on "Edit Callback URL". The URL should be your host followed by `/auth/ultraauth/callback`. For example, http://localhost:3000/auth/ultraauth/callback
## Usage
Example configuration:
If you are using Rails, your `config/intializers/omniauth.rb` file should look like this:
```ruby
Rails.application.config.middleware.use OmniAuth::Builder do
provider :ultraauth, "CLIENT_ID", "CLIENT_SECRET", client_options: {
redirect_uri: "CALLBACK_URI" # i.e. http://localhost:3000/auth/ultraauth/callback
}
end
```
Replace "CLIENT_ID", "CLIENT_SECRET", "CALLBACK_URI" with the values from the application you created on https://ultraauth.com
## Authentication Hash
An example of auth hash returned from the server available under `request.env['omniauth.auth']`:
```
{
"provider": "ultraauth",
"uid": "abcd1234...",
"info": {
"name": null,
"email": null,
"nickname": null,
"first_name": null,
"last_name": null,
"gender": null,
"image": null,
"phone": null,
"urls": {
"website": null
}
},
"credentials": {
"id_token": "abcd1234...",
"token": "abcd1234...",
"refresh_token": null,
"expires_in": 3600,
"scope": "openid"
},
"extra": {
"raw_info": {
"sub": "abcd1234...."
}
}
}
```
## Contributing
1. Fork it ( http://github.com/ultraauth/omniauth-ultraauth/fork )
2. Create your feature branch (`git checkout -b my-new-feature`)
3. Commit your changes (`git commit -am 'Add some feature'`)
4. Push to the branch (`git push origin my-new-feature`)
5. Create new Pull Request

View file

@ -1,6 +0,0 @@
require "bundler/gem_tasks"
require "rspec/core/rake_task"
RSpec::Core::RakeTask.new(:spec)
task :default => :spec

View file

@ -1,14 +0,0 @@
#!/usr/bin/env ruby
require "bundler/setup"
require "omniauth-ultraauth"
# You can add fixtures and/or initialization code here to make experimenting
# with your gem easier. You can also use a different console, if you like.
# (If you use this, don't forget to add pry to your Gemfile!)
# require "pry"
# Pry.start
require "irb"
IRB.start(__FILE__)

View file

@ -1,8 +0,0 @@
#!/usr/bin/env bash
set -euo pipefail
IFS=$'\n\t'
set -vx
bundle install
# Do any other automated setup that you need to do here

View file

@ -1,2 +0,0 @@
require 'omniauth-ultraauth/version'
require 'omniauth/strategies/ultraauth'

View file

@ -1,5 +0,0 @@
module OmniAuth
module UltraAuth
VERSION = "0.0.2"
end
end

View file

@ -1,33 +0,0 @@
require 'omniauth'
require 'omniauth_openid_connect'
module OmniAuth
module Strategies
class UltraAuth < OmniAuth::Strategies::OpenIDConnect
args %i[identifier secret]
option :identifier, nil
option :secret, nil
option :name, 'ultraauth'
option :scope, [:openid]
option :discovery, "true"
option :response_type, :code
option :issuer, "https://srv.qryp.to/op"
option :client_auth_method, :basic
info do
{
username: uid
}
end
private
def client_options
options.client_options.merge!(identifier: options.identifier, secret: options.secret)
end
end
end
end
OmniAuth.config.add_camelization('ultraauth', 'UltraAuth')

View file

@ -1,29 +0,0 @@
lib = File.expand_path("../lib", __FILE__)
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
require "omniauth-ultraauth/version"
Gem::Specification.new do |spec|
spec.name = "omniauth-ultraauth"
spec.version = OmniAuth::UltraAuth::VERSION
spec.authors = ["Kartikey Tanna"]
spec.email = ["tannakartikey@gmail.com"]
spec.summary = %q{Omniauth strategy for UltraAuth.}
spec.description = %q{Eliminate customer phishing / hijacking and increase user satisfaction with password-less authentication.}
spec.homepage = "https://ultraauth.com"
spec.license = "MIT"
spec.files = Dir.chdir(File.expand_path('..', __FILE__)) do
`git ls-files -z`.split("\x0").reject { |f| f.match(%r{^(test|spec|features)/}) }
end
spec.bindir = "exe"
spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
spec.require_paths = ["lib"]
spec.add_runtime_dependency "omniauth_openid_connect", "~> 0.3.0"
spec.add_development_dependency "bundler", "~> 1.17"
spec.add_development_dependency "rake", "~> 10.0"
spec.add_development_dependency "rspec", "~> 3.0"
end

View file

@ -1,17 +0,0 @@
/.bundle/
/.yardoc
/Gemfile.lock
/gemfiles/*.lock
/_yardoc/
/coverage/
/doc/
/pkg/
/spec/reports/
tmp/
*.bundle
*.so
*.o
*.a
mkmf.log
vendor
*.log

View file

@ -1,31 +0,0 @@
language: ruby
bundler_args: "--binstubs --standalone --without documentation --path ../bundle"
script: "bundle exec rake test"
before_install:
- rvm @global do gem uninstall bundler -x
- gem install bundler --version '< 2'
gemfile:
- gemfiles/sprockets-rails_3_0.gemfile
- gemfiles/sprockets-rails_2_3.gemfile
- gemfiles/sprockets_3_0.gemfile
- gemfiles/sprockets_4_0.gemfile
- gemfiles/rails_4_2.gemfile
- gemfiles/rails_5_2.gemfile
rvm:
- 2.4.6
- 2.5.5
- 2.6.3
- jruby
matrix:
allow_failures:
- gemfile: gemfiles/rails_4_2.gemfile
rvm: jruby
notifications:
email: false

View file

@ -1,10 +0,0 @@
Sass is more than a technology; Sass is driven by the community of individuals
that power its development and use every day. As a community, we want to embrace
the very differences that have made our collaboration so powerful, and work
together to provide the best environment for learning, growing, and sharing of
ideas. It is imperative that we keep Sass a fun, welcoming, challenging, and
fair place to play.
[The full community guidelines can be found on the Sass website.][link]
[link]: https://sass-lang.com/community-guidelines

View file

@ -1,7 +0,0 @@
source 'https://rubygems.org'
# for working locally
# gem "sassc", :path => "../sassc"
# Specify your gem's dependencies in sassc-rails.gemspec
gemspec

View file

@ -1,22 +0,0 @@
Copyright (c) 2015 Ryan Boland
MIT License
Permission is hereby granted, free of charge, to any person obtaining
a copy of this software and associated documentation files (the
"Software"), to deal in the Software without restriction, including
without limitation the rights to use, copy, modify, merge, publish,
distribute, sublicense, and/or sell copies of the Software, and to
permit persons to whom the Software is furnished to do so, subject to
the following conditions:
The above copyright notice and this permission notice shall be
included in all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

View file

@ -1,124 +0,0 @@
# SassC::Rails [![Build Status](https://travis-ci.org/sass/sassc-rails.svg)](https://travis-ci.org/sass/sassc-rails) [![Gem Version](https://badge.fury.io/rb/sassc-rails.svg)](http://badge.fury.io/rb/sassc-rails)
We all love working with Sass, but compilation can take quite a long time for larger
codebases. This gem integrates the C implementation of Sass,
[LibSass](https://github.com/sass/libsass), into the asset pipeline.
In one larger project, this made compilation 4x faster:
```
# Using sassc-rails
[1] pry(main)> Benchmark.bm { |bm| bm.report { Rails.application.assets["application.css"] } }
user system total real
1.720000 0.170000 1.890000 ( 1.936867)
# Using sass-rails
[1] pry(main)> Benchmark.bm { |bm| bm.report { Rails.application.assets["application.css"] } }
user system total real
7.820000 0.250000 8.070000 ( 8.106347)
```
This should essentially be a drop in alternative to [sass-rails](https://github.com/rails/sass-rails).
## Inline Source Maps
With SassC-Rails, it's also extremely easy to turn on inline source maps. Simply
add the following configuration to your development.rb file:
```ruby
# config/environments/development.rb
config.sass.inline_source_maps = true
```
After adding this config line, you may need to clear your assets cache
(`rm -r tmp/cache/assets`), stop spring, and restart your rails server. You may
also wish to disable line comments (`config.sass.line_comments = false`).
Note, as indicated, these source maps are *inline*. They will not generate additional
files or anything like that. Instead, they will be appended to the compiled
application.css file.
## LibSass Compatibility With Ruby Sass
For a look at the compatibility between Ruby Sass and LibSass, check this
[compatibility chart](http://sass-compatibility.github.io/) out.
## Installation
Add this line to your application's Gemfile:
```ruby
gem 'sassc-rails'
```
And then execute:
$ bundle
## Common Issues
### Deployment to Heroku
Due to LibSass compilation requirements, you must upgrade to the
[Heroku Cedar-14 Stack](https://devcenter.heroku.com/articles/cedar-14-migration)
in order to successfully install this gem.
Upgrading to Cedar-14 is usually a painless process.
### Installing alongside a gem that depends on Sass-Rails
Libraries explicitly depending on Sass-Rails, such as ActiveAdmin, can cause
conflicts with installation of SassC-Rails. While we have no built-in solution
for this, please check out [this issue](https://github.com/sass/sassc-rails/issues/6)
for a workaround.
## Credits
This gem is based on [sass-rails](https://github.com/rails/sass-rails), and
is maintained by [Ryan Boland](https://ryanboland.com) and [awesome contributors](https://github.com/sass/sassc-rails/graphs/contributors).
## Changelog
- **2.1.2**
- [Correct reference to SassC::Script::Value::String](https://github.com/sass/sassc-rails/pull/129)
- **2.1.1**
- [Fix Scaffolding](https://github.com/sass/sassc-rails/pull/119)
- **2.1.0**
- [JRuby support](https://github.com/sass/sassc-rails/pull/113)
- [SCSS / SASS scaffolding](https://github.com/sass/sassc-rails/pull/112)
- **2.0.0**
- [Drop support for Sprockets 2](https://github.com/sass/sassc-rails/pull/109)
- [Remove dependency on Ruby Sass](https://github.com/sass/sassc-rails/pull/109)
- **1.3.0**
- [Silence Sprockets deprecation warnings](https://github.com/sass/sassc-rails/pull/76)
- [Sprockets 4 compatibility](https://github.com/sass/sassc-rails/pull/65)
- **1.2.1**
- Bump SassC (and thus LibSass) version
- **1.2.0**
- [Support sprockets-rails 3](https://github.com/sass/sassc-rails/pull/41)
- [Only depend on Railties instead of full Rails](https://github.com/sass/sassc-rails/pull/52)
- **1.1.0**
- Moved under the official sass organization!
- [Source line comments](https://github.com/sass/sassc-rails/pull/24) (`app.config.sass.line_comments`)
- [Prevent sass-rails railtie from running](https://github.com/sass/sassc-rails/pull/34)
- [CSS compression may be disabled in test mode](https://github.com/sass/sassc-rails/issues/33). Special thanks to [this Sass-Rails PR](https://github.com/rails/sass-rails/pull/338) for inspiration.
- **1.0.0**
- Initial Release
- Add support for inline source maps
- Support compression in the way that Sass-Rails handles it
## Contributing
1. Fork it ( https://github.com/sass/sassc-rails/fork )
1. Create your feature branch (`git checkout -b my-new-feature`)
1. Commit your changes (`git commit -am 'Add some feature'`)
1. Add Tests
1. Push to the branch (`git push origin my-new-feature`)
1. Create a new Pull Request

View file

@ -1,33 +0,0 @@
require "bundler/gem_tasks"
task :test do
$LOAD_PATH.unshift('lib', 'test')
Dir.glob('./test/**/*_test.rb') { |f| require f }
end
task :default => [:test]
namespace :tests do
gemfiles = %w[
sprockets-rails_3_0
sprockets-rails_2_3
sprockets_3_0
sprockets_4_0
rails_4_2
rails_5_2
]
gemfiles.each do |gemfile|
desc "Run tests against #{gemfile}"
task gemfile do
sh "BUNDLE_GEMFILE='gemfiles/#{gemfile}.gemfile' bundle install"
sh "BUNDLE_GEMFILE='gemfiles/#{gemfile}.gemfile' bundle exec rake test"
end
end
desc "Run tests against all common asset pipeline setups"
task :all do
gemfiles.each do |gemfile|
Rake::Task["tests:#{gemfile}"].invoke
end
end
end

View file

@ -1,6 +0,0 @@
source 'https://rubygems.org'
gem "rails", "~> 4.2.0"
# Specify your gem's dependencies in sassc-rails.gemspec
gemspec path: "../"

View file

@ -1,6 +0,0 @@
source 'https://rubygems.org'
gem "rails", "~> 5.2.1"
# Specify your gem's dependencies in sassc-rails.gemspec
gemspec path: "../"

View file

@ -1,6 +0,0 @@
source 'https://rubygems.org'
gem "sprockets-rails", "~> 2.3.3"
# Specify your gem's dependencies in sassc-rails.gemspec
gemspec path: "../"

View file

@ -1,6 +0,0 @@
source 'https://rubygems.org'
gem "sprockets-rails", "~> 3.0.0"
# Specify your gem's dependencies in sassc-rails.gemspec
gemspec path: "../"

View file

@ -1,6 +0,0 @@
source 'https://rubygems.org'
gem "sprockets", "~> 3.0.3"
# Specify your gem's dependencies in sassc-rails.gemspec
gemspec path: "../"

View file

@ -1,6 +0,0 @@
source 'https://rubygems.org'
gem "sprockets", "~> 4.0.x"
# Specify your gem's dependencies in sassc-rails.gemspec
gemspec path: "../"

View file

@ -1,13 +0,0 @@
require "rails/generators/named_base"
module Sass
module Generators
class AssetsGenerator < ::Rails::Generators::NamedBase
source_root File.expand_path("../templates", __FILE__)
def copy_sass
template "stylesheet.sass", File.join('app/assets/stylesheets', class_path, "#{file_name}.sass")
end
end
end
end

View file

@ -1,3 +0,0 @@
// Place all the styles related to the <%= name %> controller here.
// They will automatically be included in application.css.
// You can use Sass here: https://sass-lang.com/

View file

@ -1,9 +0,0 @@
require "rails/generators/sass_scaffold"
module Sass
module Generators
class ScaffoldGenerator < ::Sass::Generators::ScaffoldBase
def syntax() :sass end
end
end
end

View file

@ -1,15 +0,0 @@
require "sassc/engine"
require "rails/generators/named_base"
module Sass
module Generators
class ScaffoldBase < ::Rails::Generators::NamedBase
def copy_stylesheet
dir = ::Rails::Generators::ScaffoldGenerator.source_root
file = File.join(dir, "scaffold.css")
converted_contents = ::SassC::Engine.new(File.read(file)).render
create_file "app/assets/stylesheets/scaffolds.#{syntax}", converted_contents
end
end
end
end

View file

@ -1,13 +0,0 @@
require "rails/generators/named_base"
module Scss
module Generators
class AssetsGenerator < ::Rails::Generators::NamedBase
source_root File.expand_path("../templates", __FILE__)
def copy_scss
template "stylesheet.scss", File.join('app/assets/stylesheets', class_path, "#{file_name}.scss")
end
end
end
end

View file

@ -1,3 +0,0 @@
// Place all the styles related to the <%= name %> controller here.
// They will automatically be included in application.css.
// You can use Sass (SCSS) here: https://sass-lang.com/

View file

@ -1,10 +0,0 @@
require "rails/generators/sass_scaffold"
module Scss
module Generators
class ScaffoldGenerator < ::Sass::Generators::ScaffoldBase
def syntax() :scss end
end
end
end

View file

@ -1,4 +0,0 @@
# frozen_string_literal: true
require_relative "sassc/rails"

View file

@ -1,10 +0,0 @@
# frozen_string_literal: true
require_relative "rails/version"
require "sassc"
require_relative "rails/functions"
require_relative "rails/importer"
require_relative "rails/template"
require_relative "rails/compressor"
require_relative "rails/railtie"

View file

@ -1,34 +0,0 @@
# frozen_string_literal: true
require 'sprockets/sass_compressor'
require 'securerandom'
class Sprockets::SassCompressor
def initialize(options = {})
@options = {
syntax: :scss,
cache: false,
read_cache: false,
style: :compressed
}.merge(options).freeze
@cache_key = SecureRandom.uuid
end
def call(*args)
input = if defined?(data)
data # sprockets 2.x
else
args[0][:data] #sprockets 3.x
end
SassC::Engine.new(
input,
{
style: :compressed
}
).render
end
# sprockets 2.x
alias :evaluate :call
end

View file

@ -1,13 +0,0 @@
# frozen_string_literal: true
require 'sprockets/sass_functions'
module Sprockets
module SassFunctions
def asset_data_url(path)
::SassC::Script::Value::String.new("url(" + sprockets_context.asset_data_uri(path.value) + ")")
end
end
end
::SassC::Script::Functions.send :include, Sprockets::SassFunctions

View file

@ -1,181 +0,0 @@
# frozen_string_literal: true
require 'tilt'
module SassC
module Rails
class Importer < SassC::Importer
class Extension
attr_reader :postfix
def initialize(postfix=nil)
@postfix = postfix
end
def import_for(full_path, parent_dir, options)
SassC::Importer::Import.new(full_path)
end
end
class CSSExtension
def postfix
".css"
end
def import_for(full_path, parent_dir, options)
import_path = full_path.gsub(/\.css$/,"")
SassC::Importer::Import.new(import_path)
end
end
class CssScssExtension < Extension
def postfix
".css.scss"
end
def import_for(full_path, parent_dir, options)
source = File.open(full_path, 'rb') { |f| f.read }
SassC::Importer::Import.new(full_path, source: source)
end
end
class CssSassExtension < Extension
def postfix
".css.sass"
end
def import_for(full_path, parent_dir, options)
sass = File.open(full_path, 'rb') { |f| f.read }
parsed_scss = SassC::Sass2Scss.convert(sass)
SassC::Importer::Import.new(full_path, source: parsed_scss)
end
end
class SassERBExtension < Extension
def postfix
".sass.erb"
end
def import_for(full_path, parent_dir, options)
template = Tilt::ERBTemplate.new(full_path)
parsed_erb = template.render(options[:sprockets][:context], {})
parsed_scss = SassC::Sass2Scss.convert(parsed_erb)
SassC::Importer::Import.new(full_path, source: parsed_scss)
end
end
class ERBExtension < Extension
def import_for(full_path, parent_dir, options)
template = Tilt::ERBTemplate.new(full_path)
parsed_erb = template.render(options[:sprockets][:context], {})
SassC::Importer::Import.new(full_path, source: parsed_erb)
end
end
EXTENSIONS = [
CssScssExtension.new,
CssSassExtension.new,
SassERBExtension.new,
ERBExtension.new(".scss.erb"),
ERBExtension.new(".css.erb"),
Extension.new(".scss"),
Extension.new(".sass"),
CSSExtension.new
].freeze
PREFIXS = [ "", "_" ]
GLOB = /(\A|\/)(\*|\*\*\/\*)\z/
def imports(path, parent_path)
parent_dir, _ = File.split(parent_path)
specified_dir, specified_file = File.split(path)
if m = path.match(GLOB)
path = path.sub(m[0], "")
base = File.expand_path(path, File.dirname(parent_path))
return glob_imports(base, m[2], parent_path)
end
search_paths = ([parent_dir] + load_paths).uniq
if specified_dir != "."
search_paths.map! do |path|
File.join(path, specified_dir)
end
search_paths.select! do |path|
File.directory?(path)
end
end
search_paths.each do |search_path|
PREFIXS.each do |prefix|
file_name = prefix + specified_file
EXTENSIONS.each do |extension|
try_path = File.join(search_path, file_name + extension.postfix)
if File.exist?(try_path)
record_import_as_dependency try_path
return extension.import_for(try_path, parent_dir, options)
end
end
end
end
SassC::Importer::Import.new(path)
end
private
def extension_for_file(file)
EXTENSIONS.detect do |extension|
file.include? extension.postfix
end
end
def record_import_as_dependency(path)
context.depend_on path
end
def context
options[:sprockets][:context]
end
def load_paths
options[:load_paths]
end
def glob_imports(base, glob, current_file)
files = globbed_files(base, glob)
files = files.reject { |f| f == current_file }
files.map do |filename|
record_import_as_dependency(filename)
extension = extension_for_file(filename)
extension.import_for(filename, base, options)
end
end
def globbed_files(base, glob)
# TODO: Raise an error from SassC here
raise ArgumentError unless glob == "*" || glob == "**/*"
extensions = EXTENSIONS.map(&:postfix)
exts = extensions.map { |ext| Regexp.escape("#{ext}") }.join("|")
sass_re = Regexp.compile("(#{exts})$")
record_import_as_dependency(base)
files = Dir["#{base}/#{glob}"].sort.map do |path|
if File.directory?(path)
record_import_as_dependency(path)
nil
elsif sass_re =~ path
path
end
end
files.compact
end
end
end
end

View file

@ -1,81 +0,0 @@
# frozen_string_literal: true
require 'active_support/core_ext/class/attribute'
require 'sprockets/railtie'
module SassC::Rails
class Railtie < ::Rails::Railtie
config.sass = ActiveSupport::OrderedOptions.new
# Establish static configuration defaults
# Emit scss files during stylesheet generation of scaffold
config.sass.preferred_syntax = :scss
# Initialize the load paths to an empty array
config.sass.load_paths = []
# Display line comments above each selector as a debugging aid
config.sass.line_comments = true
# Set the default stylesheet engine
# It can be overridden by passing:
# --stylesheet_engine=sass
# to the rails generate command
config.app_generators.stylesheet_engine config.sass.preferred_syntax
if config.respond_to?(:annotations)
config.annotations.register_extensions("scss", "sass") { |annotation| /\/\/\s*(#{annotation}):?\s*(.*)$/ }
end
# Remove the sass middleware if it gets inadvertently enabled by applications.
config.after_initialize do |app|
app.config.middleware.delete(Sass::Plugin::Rack) if defined?(Sass::Plugin::Rack)
end
initializer :setup_sass, group: :all do |app|
# Only emit one kind of syntax because though we have registered two kinds of generators
syntax = app.config.sass.preferred_syntax.to_sym
alt_syntax = syntax == :sass ? "scss" : "sass"
app.config.generators.hide_namespace alt_syntax
# Override stylesheet engine to the preferred syntax
config.app_generators.stylesheet_engine syntax
# Establish configuration defaults that are environmental in nature
# if config.sass.full_exception.nil?
# # Display a stack trace in the css output when in development-like environments.
# config.sass.full_exception = app.config.consider_all_requests_local
# end
app.config.assets.configure do |env|
env.context_class.class_eval do
class_attribute :sass_config
self.sass_config = app.config.sass
end
if env.respond_to?(:register_transformer)
env.register_transformer 'text/sass', 'text/css', SassC::Rails::SassTemplate.new
env.register_transformer 'text/scss', 'text/css', SassC::Rails::ScssTemplate.new
end
if env.respond_to?(:register_engine)
[
['.sass', SassC::Rails::SassTemplate],
['.scss', SassC::Rails::ScssTemplate]
].each do |engine|
engine << { silence_deprecation: true } if Sprockets::VERSION.start_with?("3")
env.register_engine(*engine)
end
end
end
end
initializer :setup_compression, group: :all do |app|
if !Rails.env.development?
app.config.assets.css_compressor = :sass unless app.config.assets.has_key?(:css_compressor)
else
# Use expanded output instead of the sass default of :nested unless specified
app.config.sass.style ||= :expanded
end
end
end
end

View file

@ -1,113 +0,0 @@
# frozen_string_literal: true
require "sprockets/version"
require 'sprockets/sass_processor'
require "sprockets/utils"
module SassC::Rails
class SassTemplate < Sprockets::SassProcessor
def initialize(options = {}, &block)
@cache_version = options[:cache_version]
@cache_key = "#{self.class.name}:#{VERSION}:#{SassC::VERSION}:#{@cache_version}".freeze
#@importer_class = options[:importer] || Sass::Importers::Filesystem
@sass_config = options[:sass_config] || {}
@functions = Module.new do
include Functions
include options[:functions] if options[:functions]
class_eval(&block) if block_given?
end
end
def call(input)
context = input[:environment].context_class.new(input)
options = {
filename: input[:filename],
line_comments: line_comments?,
syntax: self.class.syntax,
load_paths: input[:environment].paths,
importer: SassC::Rails::Importer,
sprockets: {
context: context,
environment: input[:environment],
dependencies: context.metadata[:dependency_paths]
}
}.merge!(config_options) { |key, left, right| safe_merge(key, left, right) }
engine = ::SassC::Engine.new(input[:data], options)
css = Sprockets::Utils.module_include(::SassC::Script::Functions, @functions) do
engine.render
end
context.metadata.merge(data: css)
end
def config_options
opts = { style: sass_style, load_paths: load_paths }
if Rails.application.config.sass.inline_source_maps
opts.merge!({
source_map_file: ".",
source_map_embed: true,
source_map_contents: true,
})
end
opts
end
def sass_style
(Rails.application.config.sass.style || :expanded).to_sym
end
def load_paths
Rails.application.config.sass.load_paths || []
end
def line_comments?
Rails.application.config.sass.line_comments
end
def safe_merge(_key, left, right)
if [left, right].all? { |v| v.is_a? Hash }
left.merge(right) { |k, l, r| safe_merge(k, l, r) }
elsif [left, right].all? { |v| v.is_a? Array }
(left + right).uniq
else
right
end
end
# The methods in the Functions module were copied here from sprockets in order to
# override the Value class names (e.g. ::SassC::Script::Value::String)
module Functions
def asset_path(path, options = {})
path = path.value
path, _, query, fragment = URI.split(path)[5..8]
path = sprockets_context.asset_path(path, options)
query = "?#{query}" if query
fragment = "##{fragment}" if fragment
::SassC::Script::Value::String.new("#{path}#{query}#{fragment}", :string)
end
def asset_url(path, options = {})
::SassC::Script::Value::String.new("url(#{asset_path(path, options).value})")
end
def asset_data_url(path)
url = sprockets_context.asset_data_uri(path.value)
::SassC::Script::Value::String.new("url(" + url + ")")
end
end
end
class ScssTemplate < SassTemplate
def self.syntax
:scss
end
end
end

View file

@ -1,7 +0,0 @@
# frozen_string_literal: true
module SassC
module Rails
VERSION = "2.1.2"
end
end

View file

@ -1,32 +0,0 @@
# coding: utf-8
lib = File.expand_path('../lib', __FILE__)
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
require 'sassc/rails/version'
Gem::Specification.new do |spec|
spec.name = "sassc-rails"
spec.version = SassC::Rails::VERSION
spec.authors = ["Ryan Boland"]
spec.email = ["ryan@tanookilabs.com"]
spec.summary = %q{Integrate SassC-Ruby into Rails.}
spec.description = %q{Integrate SassC-Ruby into Rails.}
spec.homepage = "https://github.com/sass/sassc-rails"
spec.license = "MIT"
spec.files = `git ls-files -z`.split("\x0")
spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) }
spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
spec.require_paths = ["lib"]
spec.add_development_dependency 'pry'
spec.add_development_dependency "bundler"
spec.add_development_dependency "rake", "~> 10.0"
spec.add_development_dependency 'mocha'
spec.add_dependency "sassc", ">= 2.0"
spec.add_dependency "tilt"
spec.add_dependency 'railties', '>= 4.0.0'
spec.add_dependency 'sprockets', '> 3.0'
spec.add_dependency 'sprockets-rails'
end