Module: InstAccess
- Defined in:
- lib/inst_access/token.rb,
lib/inst_access.rb,
lib/inst_access/config.rb,
lib/inst_access/errors.rb,
lib/inst_access/version.rb
Overview
Copyright © 2023 - present Instructure, Inc.
This file is part of Canvas.
Canvas is free software: you can redistribute it and/or modify it under the terms of the GNU Affero General Public License as published by the Free Software Foundation, version 3 of the License.
Canvas is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License for more details.
You should have received a copy of the GNU Affero General Public License along with this program. If not, see <www.gnu.org/licenses/>.
Defined Under Namespace
Classes: Config, ConfigError, Error, InvalidToken, Token, TokenExpired
Constant Summary collapse
- VERSION =
'0.4.2'
Class Method Summary collapse
- .config ⇒ Object
-
.configure(signing_key:, encryption_key: nil) ⇒ Object
signing_key is required.
-
.with_config(signing_key:, encryption_key: nil) ⇒ Object
set a configuration only for the duration of the given block, then revert it.
Class Method Details
.config ⇒ Object
49 50 51 |
# File 'lib/inst_access.rb', line 49 def config @config || raise(ConfigError, 'InstAccess is not configured!') end |
.configure(signing_key:, encryption_key: nil) ⇒ Object
signing_key is required. if you are going to be producing (and therefore signing) tokens, this needs to be an RSA private key. if you’re just consuming tokens, it can be the RSA public key corresponding to the private key that signed them. encryption_key is only required if you are going to be producing tokens.
35 36 37 |
# File 'lib/inst_access.rb', line 35 def configure(signing_key:, encryption_key: nil) @config = Config.new(signing_key, encryption_key) end |
.with_config(signing_key:, encryption_key: nil) ⇒ Object
set a configuration only for the duration of the given block, then revert it. useful for testing.
41 42 43 44 45 46 47 |
# File 'lib/inst_access.rb', line 41 def with_config(signing_key:, encryption_key: nil) old_config = @config configure(signing_key: signing_key, encryption_key: encryption_key) yield ensure @config = old_config end |