oauth_im 0.4.7 → 0.7.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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: a70d55e5fdd5e744b2dc73080162d95b932e18a889b8705e9ccddbb17ac04058
4
- data.tar.gz: 253c1abec16f1895b8c4a663b46ac01699b46d81248ff5e661854445783987a0
3
+ metadata.gz: 49173e12b6a9dd53124b3ecb56a5f71411a819daacd7a1d2e914dd911e4157a1
4
+ data.tar.gz: 1c7e47395be3b93a95604aa880cacc2f84edf6d45cd516e0e036e86068d67feb
5
5
  SHA512:
6
- metadata.gz: 73134ec8ba1250f443cd82f3f8ceea8ef1634967d19f0fcfe9dc0bc41dbf34dc6f3769daf4040e57eceb5ec960fb045c22e2a7187a77cbb873167be109c0348b
7
- data.tar.gz: 9de025db4311239f823a0503abb80a84b21ab663272c607a029f7aa4d5d1dbd7223140b13d6e162eacd65cd2a09e3cfbde850b8dbd504403d8aab2c7545627b5
6
+ metadata.gz: b376f8f3b03157df81d18c56d34dd9c9f58d4f5577a308ad75fb709e02ed0b6dbec3d51f9733ad2897402b9bfe2d0c5fed639e861c25a80975dc89db1a3abd4a
7
+ data.tar.gz: c81f6b6aad610aa99f800f00023c0478e25b39afb56abcf8dbedd9affe08a2fdd16cd4ee5101d2c896d5243b8d2996d6311b3d9accd69626c2df354a8c6d1d9a
data/README.md CHANGED
@@ -79,7 +79,53 @@ some other appropriate location, e.g.:
79
79
  class ApplicationController < ActionController::Base
80
80
  include OauthIm::Authenticable
81
81
 
82
- # etc. etc. etc.
82
+ # etc.
83
83
  end
84
-
85
84
  ```
85
+
86
+ ### Initializer
87
+ * The gem provides a single initializer, `AppContext`.
88
+ * This module is **not** name-spaced.
89
+ * It provides a single method, `provide_authentication?`, which by
90
+ default is `true`.
91
+ * Client apps can override this initializer method.
92
+ * For example, `iiab` overrides this initializer so that the
93
+ `provide_authentication?` method returns `false` unless the app is
94
+ `kh_iiab` (not `demo_im`).
95
+
96
+ ## Gem Maintenance
97
+ After many false starts, this repo includes two (seemingly functional) github workflows.
98
+
99
+ 1. Thanks to [this workflow](https://github.com/illustrativemathematics/oauth_im/blob/main/.github/workflows/ci.yml),
100
+ largely copied from the CMS, the specs should run automatically when a PR is issued.
101
+ 2. Thanks to [this workflow](https://github.com/illustrativemathematics/oauth_im/blob/main/.github/workflows/release.yml)
102
+ based on [this blog post](https://andrewm.codes/blog/automating-ruby-gem-releases-with-github-actions/)
103
+ and using [this release phase action](https://github.com/illustrativemathematics/oauth_im/blob/main/.github/workflows/release.yml),
104
+ certain so-called [conventional commits](https://github.com/google-github-actions/release-please-action#how-should-i-write-my-commits)
105
+ will result in a so-called **release PR**.
106
+ * Per the above documentation, to issue such a commit, use the following format for your commit message:
107
+ * `fix: a comment about a minor change that corresponds to a SemVar patch`
108
+ * `feat: a comment about a feature change that corresponds to a SemVar minor`
109
+ * `fix!: a comment about a breaking change that corresponds to a Semvar major`
110
+ * `feat!: ditto`
111
+ * Once a release PR is accepted and merged, a new PR is created that does several things:
112
+ * The gem is versioned by updating [the version file](https://github.com/illustrativemathematics/oauth_im/blob/main/lib/oauth_im/version.rb#L4).
113
+ * The new PR also includes auto-generated updates to [CHANGELOG.md](https://github.com/illustrativemathematics/oauth_im/blob/main/CHANGELOG.md).
114
+ * If this new PR is accepted and merged, several other things happened:
115
+ * A new tag and github release are created.
116
+ * The new gem version is automatically pushed up to Rubygems.
117
+
118
+ ### Notes
119
+ * Because the above process adds new commits to the repository, you
120
+ should remember to pull them.
121
+ * At Rubygems it is difficult to reuse version numbers for gems. For
122
+ this reason, you shouldn't try to force-push updates to gem version
123
+ numbers. Instead, let the automatic process manage versioning for
124
+ you.
125
+
126
+ ## Version History
127
+
128
+ ### 0.6.0
129
+ * Remove coupling between gem and `iiab` app via the `AppContext`
130
+ module. Added default `AppContext` settings to be overridden in
131
+ client app (in this case, `iiab`).
@@ -12,7 +12,8 @@ module OauthIm
12
12
  private
13
13
 
14
14
  def authenticated?
15
- AppContext.kh_iiab? && logged_in?
15
+ AppContext.authenticated_for_specs? ||
16
+ (AppContext.provide_authentication? && logged_in?)
16
17
  end
17
18
 
18
19
  def email
@@ -39,6 +40,8 @@ module OauthIm
39
40
  else
40
41
  head :forbidden
41
42
  end
43
+ else
44
+ AppContext.current_user
42
45
  end
43
46
  end
44
47
 
@@ -0,0 +1,23 @@
1
+ # frozen_string_literal: true
2
+
3
+ module AppContext
4
+ def self.provide_authentication?
5
+ true
6
+ end
7
+
8
+ def self.authenticated_for_specs?
9
+ @authenticated_for_specs
10
+ end
11
+
12
+ def self.authenticate_for_specs(current_user: nil)
13
+ @current_user = current_user
14
+ @authenticated_for_specs = true
15
+ yield
16
+ @authenticated_for_specs = false
17
+ @current_user = nil
18
+ end
19
+
20
+ def self.current_user
21
+ @current_user
22
+ end
23
+ end
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module OauthIm
4
- VERSION = '0.4.7'
4
+ VERSION = '0.7.0'
5
5
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: oauth_im
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.4.7
4
+ version: 0.7.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Eric Connally
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2022-02-14 00:00:00.000000000 Z
11
+ date: 2022-05-04 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: jwt
@@ -127,6 +127,7 @@ files:
127
127
  - app/helpers/oauth_im/application_helper.rb
128
128
  - app/services/oauth_im/token_decoder.rb
129
129
  - app/views/layouts/oauth_im/application.html.erb
130
+ - config/initializers/app_context.rb
130
131
  - config/routes.rb
131
132
  - lib/oauth_im.rb
132
133
  - lib/oauth_im/configuration.rb