omniauth-smarthr 0.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA256:
3
+ metadata.gz: 0cc3deac75d12e05d3cbd68103c9806fe412121fc11faf7b0a1ffda9e48d88b9
4
+ data.tar.gz: 4898b08c710219287ce09c0ffe8f25d6589f60edfa9fe06563e3f6da5390236e
5
+ SHA512:
6
+ metadata.gz: 1f2307db5d23c20a6d435f2e921dd4e8751d7e9e66497544c31bdb133ba4413533de6567a214af0999c85cf5f9fc0c7505fcfc8720bbbe46135f0e20c8d6313b
7
+ data.tar.gz: 370a55fbf6ff380eec40e3daad70b3b7e42e3a81d8e910aa7d7f66cae4814f97ca960b3905af945beee3fa86c550fd455d9232eca9dd422a00c44fd577c4bee8
data/.gitignore ADDED
@@ -0,0 +1,11 @@
1
+ /.bundle/
2
+ /.yardoc
3
+ /_yardoc/
4
+ /coverage/
5
+ /doc/
6
+ /pkg/
7
+ /spec/reports/
8
+ /tmp/
9
+
10
+ # rspec failure tracking
11
+ .rspec_status
data/.rspec ADDED
@@ -0,0 +1,3 @@
1
+ --format documentation
2
+ --color
3
+ --require spec_helper
data/.travis.yml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ sudo: false
3
+ language: ruby
4
+ cache: bundler
5
+ rvm:
6
+ - 2.5.1
7
+ before_install: gem install bundler -v 1.16.4
@@ -0,0 +1,87 @@
1
+
2
+ # コントリビューター行動規範
3
+
4
+ ## 私たちの約束
5
+ メンバー、コントリビューター、およびリーダーとして、年齢、体の大きさ、目に見えるまたは目に見えない障害、民族性、性別、
6
+ 性同一性、表現、経験のレベル、教育、社会経済的地位、国籍、人格、人種、宗教、または性的同一性と指向に関係なく、
7
+ コミュニティへの参加をハラスメントのない体験にすることを誓います。
8
+
9
+ 私たちは、オープンで親しみやすく、多様で包括的で健全なコミュニティに貢献する方法で行動し、交流することを誓います。
10
+
11
+ ## 私たちの標準
12
+
13
+ 前向きな環境を作り上げることに貢献する行動の例:
14
+
15
+ * 他人への共感と優しさを示す
16
+
17
+ * 異なる意見、視点、経験を尊重する
18
+
19
+ * 建設的なフィードバックを与え、礼儀正しく受け入れる
20
+
21
+ * 私たちの過ちの影響を受けた人々に責任を受け入れ、謝罪し、そしてその経験から学ぶ
22
+
23
+ * 個人としてだけでなく、コミュニティ全体にとっても最善であることに焦点を当てる
24
+
25
+ 許容できない行動の例は次のとおりです。
26
+
27
+ * 性的な言葉や画像の使用、および性的な注意またはその他あらゆる種類の問題行為
28
+
29
+ * トローリング、侮辱的または中傷的なコメント、個人的または政治的攻撃
30
+
31
+ * 公的またはプライベートの嫌がらせ
32
+
33
+ * 明示的な許可なしに、住所や電子メールアドレスなど、他者の個人情報を公開する
34
+
35
+ * 職業上不適切と合理的に考えられるその他の行為
36
+
37
+ ## 執行責任
38
+
39
+ コミュニティリーダーは、許容される行動の基準を明確にし、実施する責任があり、不適切、脅迫的、攻撃的、または有害と見なされる行動に応じて、適切で公正な是正措置を講じます。
40
+
41
+ コミュニティリーダーは、コメント、コミット、コード、wikiの編集、問題、およびこの行動規範に沿っていないその他の貢献を削除、編集、または拒否する権利と責任を持ち、適切な場合はモデレーションの決定の理由を伝えます。
42
+
43
+ ## 適用範囲
44
+
45
+ この行動規範は、すべてのコミュニティスペース内で適用され、個人がパブリックスペースでコミュニティを公式に代表している場合にも適用されます。
46
+ 私たちのコミュニティを代表する例には、公式の電子メールアドレスの使用、公式のソーシャルメディアアカウントを介した投稿、オンラインまたはオフラインのイベントでの指定代理人としての行動などがあります。
47
+
48
+ ## 執行
49
+
50
+ 虐待的、嫌がらせ、またはその他の許容できない行動の事例は、執行を担当するコミュニティリーダーに対して`oss@smarthr.co.jp`で報告される場合があります。
51
+ すべての苦情は迅速かつ公正にレビューおよび調査されます。
52
+
53
+ すべてのコミュニティリーダーは、問題の報告者のプライバシーとセキュリティを尊重する義務があります。
54
+
55
+ ## 執行ガイドライン
56
+
57
+ コミュニティリーダーは、この行動規範に違反していると見なした行動への帰結を判断する際に、これらのコミュニティガイドラインに従います。
58
+
59
+ ### 1. 更生
60
+
61
+ **コミュニティへの影響**: コミュニティで専門家にふさわしくない、または歓迎されないと思われる不適切な言葉の使用やその他の不適切な行動をすること。
62
+
63
+ **帰結**: コミュニティリーダーからの非公開の書面による警告。違反の理由を明確にし、行動が不適切だった理由を説明します。 公の謝罪が要求される場合があります。
64
+
65
+ ### 2. 警告
66
+
67
+ **コミュニティへの影響**: 単一の出来事または一連の動作による違反。
68
+
69
+ **帰結**: 持続的な行動の結果を伴う警告。 指定された期間、行動規範の実施者との一方的な対話を含め、関係者との対話はありません。 これには、コミュニティスペースやソーシャルメディアなどの外部チャネルでの相互作用の回避が含まれます。 これらの条件に違反すると、一時的または永続的に禁止される場合があります。
70
+
71
+ ### 3. 一時的な禁止
72
+ **コミュニティへの影響**: 持続的で不適切な行動を含む、コミュニティ標準の重大な違反。
73
+
74
+ **帰結**: 指定された期間のコミュニティとのあらゆる種類の相互関係または公的なコミュニケーションの一時的な禁止。 この期間中、行動規範を実施する人々との一方的な対話を含め、関係する人々との公的または私的な対話は許可されません。
75
+ これらの条件に違反すると、永久的に禁止される場合があります。
76
+ ### 4. 永久的な禁止
77
+ **コミュニティへの影響**: 連続的な不適切な行動、個人への嫌がらせ、または個人の集団に対する攻撃または名誉毀損を含む、コミュニティの標準への違反のパターンを示す。
78
+
79
+ **帰結**: コミュニティ内でのあらゆる種類の公的な相互関係の永久的な禁止。
80
+
81
+ ## 帰属
82
+ この行動規範は、https://www.contributor-covenant.org/version/2/0/code_of_conduct.html で利用可能な [Contributor Covenant][homepage] バージョン2.0を基に作成されています。
83
+
84
+ コミュニティへの影響ガイドラインは[Mozilla's code of conduct enforcement ladder](https://github.com/mozilla/diversity)に適合しています。
85
+
86
+ [homepage]: https://www.contributor-covenant.org
87
+ この行動規範に関する一般的な質問への回答については、https://www.contributor-covenant.org/faq のFAQを参照してください。翻訳はhttps://www.contributor-covenant.org/translations で入手できます。
data/CONTRIBUTION.md ADDED
@@ -0,0 +1,24 @@
1
+ SmartHR OSS プロダクトへのコントリビューションガイド
2
+ ===
3
+
4
+ SmartHRのOSSプロダクトは、一部の例外を除き、GitHub上ですべてのやり取りを完結させ、情報の公開と共有を心がけてください。また、SmartHRのOSSにコントリビュートした場合、SmartHR CODE OF CONDUCT に同意したとみなします。
5
+
6
+ # バグを発見した場合
7
+
8
+ - **脆弱性に関わるバグを発見した場合、GitHub上ではレポートしないでください、必ず `oss@smarthr.co.jp` 経由でのコンタクトをお願いします**
9
+ - すでに同様のバグがIssue上で報告されていないかどうかを確認してください
10
+ - 同様の報告が見当たらない場合、新規にIssueをオープンしてください
11
+ - Issueのタイトルで簡潔にバグの内容を説明し、本文でその詳細を説明してください
12
+ - 動作環境など、再現情報は可能な限り提供してください
13
+ - 期待してる動作と実際の動作を明確に説明してください
14
+ - 問題を再現するための最小限のコードを記述してください
15
+
16
+ # パッチを提供したい場合
17
+
18
+ - 新規にPullRequestをオープンしてください
19
+ - PullRequestのタイトルで簡潔に修正の内容を説明し、本文でその詳細を説明してください
20
+ - 対応するIssueがある場合は、その番号を本文に含めてください
21
+
22
+ # バグやパッチ以外の、ソースコードに関する質問
23
+
24
+ 各OSSのGitHub Discussionを通じて質問をしてください。
data/Gemfile ADDED
@@ -0,0 +1,6 @@
1
+ source "https://rubygems.org"
2
+
3
+ git_source(:github) {|repo_name| "https://github.com/#{repo_name}" }
4
+
5
+ # Specify your gem's dependencies in omniauth-smarthr.gemspec
6
+ gemspec
data/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2023 SmartHR, Inc.
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
data/README.md ADDED
@@ -0,0 +1,61 @@
1
+ # OmniAuth SmartHR
2
+ OmniAuth SmartHRはSmartHRとのOAuth連携処理を簡素化するための[OmniAuth](https://github.com/omniauth/omniauth) strategyです。
3
+
4
+ ## インストール
5
+
6
+ ```ruby
7
+ gem 'omniauth-smarthr'
8
+ ```
9
+ ## 使い方
10
+
11
+ ### Rails
12
+
13
+ OmniAuthをミドルウェアとして登録します。
14
+
15
+ **config/initializers/omniauth.rb**:
16
+ ```ruby
17
+ Rails.application.config.middleware.use OmniAuth::Builder do
18
+ provider :smarthr, ENV['SMARTHR_CLIENT_ID'], ENV['SMARTHR_CLIENT_SECRET']
19
+ end
20
+ ```
21
+ ※`SMARTHR_CLIENT_ID` 及び `SMARTHR_CLIENT_SECRET`を取得するには[SmartHR Plus について](https://www.smarthr.plus/about)をご参照の上、パートナープログラムについてお問い合わせください。
22
+
23
+ 環境変数を用意します。
24
+
25
+ **.env**:
26
+ ```
27
+ # Required
28
+ SMARTHR_CLIENT_ID=YOUR_CLIENT_ID
29
+ SMARTHR_CLIENT_SECRET=YOUR_CLIENT_SECRET
30
+
31
+ # Optional
32
+ # サンドボックス環境を利用する場合には、サンドボックス環境のエンドポイントを指定してください。
33
+ SMARTHR_AUTH_ENDPOINT=SANDBOX_ENVIRONMENT_ENDPOINT
34
+ ```
35
+
36
+ ルーティングとコントローラを用意します。
37
+
38
+ **config/routes.rb**:
39
+
40
+ ```ruby
41
+ get 'auth/:provider/callback', to: 'sessions#create'
42
+ ```
43
+
44
+ **app/controllers/sessions_controller.rb**:
45
+ ```ruby
46
+ class SessionsController < ApplicationController
47
+ def create
48
+ user_info = request.env['omniauth.auth']
49
+ raise user_info # 適宜セッション管理を行います。
50
+ end
51
+ end
52
+ ```
53
+
54
+ ユーザーを`/auth/smarthr`に遷移させることでOAuth認可コードフローが開始されます。
55
+ OAuth認可コードフローが開始するとアプリケーションとの連携許可を求める認可画面が表示されます。
56
+ 認可画面で連携を許可するとアプリケーションにリダイレクトされ`Sessions#create`が呼び出されます。
57
+ `Sessions#create`で`request.env['omniauth.auth']`を参照することでSmartHRから受け取ったユーザー情報(アクセストークン含む)を取得できます。
58
+
59
+ ## Contributing
60
+
61
+ Bug reports and pull requests are welcome on GitHub at https://github.com/kufu/omniauth-smarthr.
data/Rakefile ADDED
@@ -0,0 +1,6 @@
1
+ require "bundler/gem_tasks"
2
+ require "rspec/core/rake_task"
3
+
4
+ RSpec::Core::RakeTask.new(:spec)
5
+
6
+ task :default => :spec
data/bin/console ADDED
@@ -0,0 +1,14 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ require "bundler/setup"
4
+ require "omniauth/smarthr"
5
+
6
+ # You can add fixtures and/or initialization code here to make experimenting
7
+ # with your gem easier. You can also use a different console, if you like.
8
+
9
+ # (If you use this, don't forget to add pry to your Gemfile!)
10
+ # require "pry"
11
+ # Pry.start
12
+
13
+ require "irb"
14
+ IRB.start(__FILE__)
data/bin/setup ADDED
@@ -0,0 +1,8 @@
1
+ #!/usr/bin/env bash
2
+ set -euo pipefail
3
+ IFS=$'\n\t'
4
+ set -vx
5
+
6
+ bundle install
7
+
8
+ # Do any other automated setup that you need to do here
@@ -0,0 +1,5 @@
1
+ module OmniAuth
2
+ module SmartHR
3
+ VERSION = "0.1.0"
4
+ end
5
+ end
@@ -0,0 +1,5 @@
1
+ require "omniauth/smarthr/version"
2
+ require "omniauth/strategies/smarthr"
3
+
4
+ OmniAuth.config.add_camelization("smarthr", "SmartHR")
5
+ OmniAuth.config.allowed_request_methods = %i(get post)
@@ -0,0 +1,55 @@
1
+ require "omniauth-oauth2"
2
+
3
+ module OmniAuth
4
+ module Strategies
5
+ class SmartHR < OmniAuth::Strategies::OAuth2
6
+
7
+ SMARTHR_AUTH_ENDPOINT = ENV.fetch("SMARTHR_AUTH_ENDPOINT", "https://app.smarthr.jp")
8
+ private_constant :SMARTHR_AUTH_ENDPOINT
9
+
10
+ option :name, "smarthr"
11
+ option :client_options, {
12
+ site: SMARTHR_AUTH_ENDPOINT,
13
+ authorize_url: "/oauth/authorization",
14
+ token_url: "/oauth/token",
15
+ auth_scheme: :request_body,
16
+ }
17
+ option :redirect_uri, nil
18
+ option :authorize_options, %i(scope state)
19
+
20
+ uid { raw_info["id"] }
21
+
22
+ info do
23
+ {
24
+ email: raw_info["email"],
25
+ }
26
+ end
27
+
28
+ extra do
29
+ skip_info? ? {} : {raw_info: raw_info}
30
+ end
31
+
32
+ def raw_info
33
+ @raw_info ||= access_token.get("/api/v1/users/me", headers: {}, parse: :json).parsed
34
+ end
35
+
36
+ def callback_url
37
+ options.redirect_uri || full_host + script_name + callback_path
38
+ end
39
+
40
+ def authorize_params
41
+ super.tap do |params|
42
+ options[:authorize_options].each do |k|
43
+ value = request.params[k.to_s]
44
+
45
+ next if [nil, ""].include?(value)
46
+
47
+ params[k] = value
48
+ end
49
+
50
+ session["omniauth.state"] = params[:state] if params[:state]
51
+ end
52
+ end
53
+ end
54
+ end
55
+ end
@@ -0,0 +1 @@
1
+ require "omniauth/smarthr"
@@ -0,0 +1,30 @@
1
+
2
+ lib = File.expand_path("../lib", __FILE__)
3
+ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
+ require "omniauth/smarthr/version"
5
+
6
+ Gem::Specification.new do |spec|
7
+ spec.name = "omniauth-smarthr"
8
+ spec.version = OmniAuth::SmartHR::VERSION
9
+ spec.licenses = ["MIT"]
10
+ spec.authors = ["SmartHR, Inc."]
11
+ spec.email = ["oss@smarthr.co.jp"]
12
+
13
+ spec.summary = "SmartHR OAuth2 Strategy for OmniAuth"
14
+ spec.description = spec.summary
15
+ spec.homepage = "https://github.com/kufu/omniauth-smarthr"
16
+
17
+ # Specify which files should be added to the gem when it is released.
18
+ # The `git ls-files -z` loads the files in the RubyGem that have been added into git.
19
+ spec.files = Dir.chdir(File.expand_path('..', __FILE__)) do
20
+ `git ls-files -z`.split("\x0").reject { |f| f.match(%r{^(test|spec|features)/}) }
21
+ end
22
+ spec.bindir = "exe"
23
+ spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
24
+ spec.require_paths = ["lib"]
25
+
26
+ spec.add_runtime_dependency 'omniauth', ">= 2.1.1"
27
+ spec.add_runtime_dependency 'omniauth-oauth2', ">= 1.8.0"
28
+ spec.add_development_dependency "rake", "~> 10.0"
29
+ spec.add_development_dependency "rspec", "~> 3.0"
30
+ end
metadata ADDED
@@ -0,0 +1,115 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: omniauth-smarthr
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.1.0
5
+ platform: ruby
6
+ authors:
7
+ - SmartHR, Inc.
8
+ autorequire:
9
+ bindir: exe
10
+ cert_chain: []
11
+ date: 2023-12-08 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: omniauth
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - ">="
18
+ - !ruby/object:Gem::Version
19
+ version: 2.1.1
20
+ type: :runtime
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - ">="
25
+ - !ruby/object:Gem::Version
26
+ version: 2.1.1
27
+ - !ruby/object:Gem::Dependency
28
+ name: omniauth-oauth2
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - ">="
32
+ - !ruby/object:Gem::Version
33
+ version: 1.8.0
34
+ type: :runtime
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - ">="
39
+ - !ruby/object:Gem::Version
40
+ version: 1.8.0
41
+ - !ruby/object:Gem::Dependency
42
+ name: rake
43
+ requirement: !ruby/object:Gem::Requirement
44
+ requirements:
45
+ - - "~>"
46
+ - !ruby/object:Gem::Version
47
+ version: '10.0'
48
+ type: :development
49
+ prerelease: false
50
+ version_requirements: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - "~>"
53
+ - !ruby/object:Gem::Version
54
+ version: '10.0'
55
+ - !ruby/object:Gem::Dependency
56
+ name: rspec
57
+ requirement: !ruby/object:Gem::Requirement
58
+ requirements:
59
+ - - "~>"
60
+ - !ruby/object:Gem::Version
61
+ version: '3.0'
62
+ type: :development
63
+ prerelease: false
64
+ version_requirements: !ruby/object:Gem::Requirement
65
+ requirements:
66
+ - - "~>"
67
+ - !ruby/object:Gem::Version
68
+ version: '3.0'
69
+ description: SmartHR OAuth2 Strategy for OmniAuth
70
+ email:
71
+ - oss@smarthr.co.jp
72
+ executables: []
73
+ extensions: []
74
+ extra_rdoc_files: []
75
+ files:
76
+ - ".gitignore"
77
+ - ".rspec"
78
+ - ".travis.yml"
79
+ - CODE_OF_CONDUCT.md
80
+ - CONTRIBUTION.md
81
+ - Gemfile
82
+ - LICENSE
83
+ - README.md
84
+ - Rakefile
85
+ - bin/console
86
+ - bin/setup
87
+ - lib/omniauth-smarthr.rb
88
+ - lib/omniauth/smarthr.rb
89
+ - lib/omniauth/smarthr/version.rb
90
+ - lib/omniauth/strategies/smarthr.rb
91
+ - omniauth-smarthr.gemspec
92
+ homepage: https://github.com/kufu/omniauth-smarthr
93
+ licenses:
94
+ - MIT
95
+ metadata: {}
96
+ post_install_message:
97
+ rdoc_options: []
98
+ require_paths:
99
+ - lib
100
+ required_ruby_version: !ruby/object:Gem::Requirement
101
+ requirements:
102
+ - - ">="
103
+ - !ruby/object:Gem::Version
104
+ version: '0'
105
+ required_rubygems_version: !ruby/object:Gem::Requirement
106
+ requirements:
107
+ - - ">="
108
+ - !ruby/object:Gem::Version
109
+ version: '0'
110
+ requirements: []
111
+ rubygems_version: 3.4.21
112
+ signing_key:
113
+ specification_version: 4
114
+ summary: SmartHR OAuth2 Strategy for OmniAuth
115
+ test_files: []