Skip to content
Snippets Groups Projects
Unverified Commit 925f5444 authored by azul's avatar azul
Browse files

feat: initial Omniauth Strategy

parents
Branches
Tags
No related merge requests found
Pipeline #
Gemfile.lock
# Official language image. Look for the different tagged releases at:
# https://hub.docker.com/r/library/ruby/tags/
image: "ruby:2.3"
# Cache gems in between builds
cache:
paths:
- vendor/ruby
# This is a basic example for a gem or script which doesn't use
# services such as redis or postgres
before_script:
- ruby -v # Print out ruby version for debugging
- apt-get update -q && apt-get install libsodium-dev -yqq
- gem install bundler --no-ri --no-rdoc # Bundler is not installed with the image
- bundle install -j $(nproc) --path vendor # Install dependencies into ./vendor/ruby
test:
script:
- bundle exec rake test
source 'https://rubygems.org'
gemspec
gem "minitest-autotest"
gem 'autotest-suffix'
gem 'byebug'
require 'rake/testtask'
Rake::TestTask.new do |t|
t.pattern = "test/**/*_test.rb"
t.libs << 'test'
end
require 'omniauth'
require 'rbsso/client'
module OmniAuth
module Strategies
class SSO
include OmniAuth::Strategy
args [:service_id, :client_key]
option :fields, [:name, :email]
option :uid_field, :email
SSO_URL = 'neststaging.riseup.net/sso_auth'
def request_phase
redirect authorize_url(options.authorize_params)
end
uid do
info_from_ticket[options.uid_field]
end
info do
info_from_ticket.slice *options.fields
end
def authorize_url(_params_from_options)
params = { s: options.service_id }
"https://#{SSO_URL}/?" + params.to_param
end
def name
'ai_sso'
end
def info_from_ticket
@info_from_ticket ||= client.open request["t"]
end
def client
RbSSO::Client.new options.client_key
end
end
end
end
OmniAuth.config.add_camelization "sso" , "SSO"
Gem::Specification.new do |s|
s.name = 'omniauth-sso'
s.version = '0.1.0'
s.licenses = ['MIT']
s.summary = "Omniauth strategy for ai's sso"
s.description = <<-EODESC
Omniauth strategy for "ai's sso"(https://git.autistici.org/ai/sso) based on rbsso.
EODESC
s.authors = ['Azul']
s.email = 'azul@riseup.net'
s.files = Dir['lib/**/*.rb']
s.homepage = 'https://0xacab.org/riseup/omniauth-sso'
s.add_runtime_dependency 'omniauth', '~> 1.3'
s.add_runtime_dependency 'rbsso', '~> 0.1'
s.add_development_dependency 'rake', '>= 10', '< 13'
s.add_development_dependency 'minitest', '~>5.0'
s.add_development_dependency 'simplecov', '~> 0.11'
s.add_development_dependency 'rack-test', '~> 0.6', '>= 0.6.3'
s.add_development_dependency 'conventional-changelog', '~> 1.2'
s.files = ['README.md', 'CHANGELOG.md'] + Dir['lib/**/*.rb']
s.test_files = Dir['test/**/*.rb']
s.require_paths = ["lib"]
end
require 'test_helper'
require 'bundler'
class GemspecTest < Minitest::Test
def test_valid
spec_path = File.expand_path('../../omniauth-sso.gemspec', __FILE__)
spec = Bundler.load_gemspec(spec_path)
spec.validate
end
end
require 'minitest/autorun'
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment