teams_connector 0.1.1 → 0.1.2

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: c6a72ee260e0976efb58e9871414f88ea25090fef32d9786a9d0b2b5dad252be
4
- data.tar.gz: 8a17c4cf19aa3313bd2361a2a2ca5524ba354d6be8079f594ef065209fd60c44
3
+ metadata.gz: 40959c6f8d45faa4aa12b64948404cc58fcb6d382088a0d62a1407256472892b
4
+ data.tar.gz: 02cc425ed3911368332604643bb923423b22349c4934567395655312590b7dd9
5
5
  SHA512:
6
- metadata.gz: 51b2a71c1d50f252f1804a037e546d9e240707553f7052128b31191e1c28316177a95afb598eadfff11d1a7dd414eaa7d53294dd64da859fc9d3c6f73112af74
7
- data.tar.gz: 9f39957ce3655246af7404d99b1f7281c0cc200257faf3ccf4c64ec02d45cd83ef08264e47f8769c0fc2affab1a7cfedf9ce10e60a876a8b9cff21aed2fd6a89
6
+ metadata.gz: 2687ee07637e06bd3fb52bd4bdef9c9997ab1fc37e8736d0eaa54879d726f254053b796f0e4552b222127b7b8d97c5feaf73c1774dffa35fe1e33a009660e0fa
7
+ data.tar.gz: 841a4a799f57f98adf218fec0b555d13028412ade5a59438a0ff9ef5d8f7859d11f82f10587f9b47faddb3042b3f2c5cd9f83d51b68eefad4d6dbdb1051b3866
data/CHANGES.md CHANGED
@@ -1,5 +1,9 @@
1
1
  # Teams Connector Changelog
2
2
 
3
+ 0.1.2
4
+ ---
5
+ - Use `TeamsConnector::Configuration#load_from_rails_credentials` to load encrypted channel URLs in your Rails environment
6
+
3
7
  0.1.1
4
8
  ---
5
9
  - Adaptive Card Notification
data/README.md CHANGED
@@ -25,10 +25,10 @@ Or install it yourself as:
25
25
  $ gem install teams_connector
26
26
 
27
27
  ## Usage
28
- After setting up the Incoming Webhook Connector four your Microsoft Teams channel, it is as simple as configuring the channel and creating a new `TeamsConnector::Notification`.
28
+ After setting up the Incoming Webhook Connector for your Microsoft Teams channel, it is as simple as configuring the channel and creating a new `TeamsConnector::Notification`.
29
29
 
30
30
  ```ruby
31
- # Configuration
31
+ # TeamsConnector initializer
32
32
  TeamsConnector.configure do |config|
33
33
  config.channel :channel_id, "https://<YOUR COMPLETE WEBHOOK URL GOES HERE>"
34
34
  end
@@ -46,9 +46,38 @@ content = {
46
46
  }
47
47
  TeamsConnector::Notification::Message.new(:facts_card, "This is a summary", content).deliver_later
48
48
  ```
49
- This gem provides some basic templates in its default template path. You can also define your own templates in your own path. The default templates will be still available so you can mix and match.
50
49
 
51
- ### Default templates
50
+ ### Secure Channel Configuration
51
+ Since the Incoming Webhook Connector does not allow any authentication at the endpoint it is crucial that you keep your channel urls secret.
52
+ At best nobody finds the url but it can also lead to spam or even faking of critical messages.
53
+
54
+ In Rails provides the credentials functionality for [environmental security](https://edgeguides.rubyonrails.org/security.html#environmental-security). This mechanism can be used by TeamsConnector to load channels from an encrypted file. This also allows easy separation of production and development channel URLs.
55
+ All channels are defined under the top-level entry `teams_connector` and will be identified by their key.
56
+ ```yaml
57
+ # $ bin/rails credentials:edit
58
+ teams_connector:
59
+ default: "<INSERT DEFAULT URL HERE>"
60
+ sales: "<INSERT URL FOR THE :sales CHANNEL HERE>"
61
+ ```
62
+
63
+ After configuration of the credentials you can load the channels in your initializer.
64
+ Since `#load_from_rails_configuration` is a wrapper around `#channel` both methods can be used together.
65
+
66
+ ```ruby
67
+ # TeamsConnector initializer
68
+ TeamsConnector.configure do |config|
69
+ config.load_from_rails_credentials
70
+ # After loading the :default channel is available and can be set as the default
71
+ config.default = :default
72
+ config.channel :another_channel, "<URL>"
73
+ end
74
+ ```
75
+
76
+ ### Templates
77
+ This gem provides some basic templates in its default template path. You can also define your own templates in your own path.
78
+ The default templates will be still available so you can mix and match.
79
+
80
+ #### Default templates
52
81
 
53
82
  Template name | Description
54
83
  -----|-------
@@ -56,13 +85,13 @@ Template name | Description
56
85
  :facts_card | A card with title, subtitle and a list of facts
57
86
  :test_card | A simple text message without any configurable content for testing
58
87
 
59
- ### Custom Templates
88
+ #### Custom Templates
60
89
 
61
90
  Custom templates are stored in the directory specified by the configuration option `template_dir`. As an array of strings, describing the path relative to the project root. When using Rails or Bundler their root is used, otherwise it is the current working directory.
62
91
 
63
92
  Templates are json files with the extension `.json.erb`. The file is parsed and populated by the ruby ERB module.
64
93
 
65
- ### Builder
94
+ #### Builder
66
95
 
67
96
  You can use TeamsConnector::Builder to create Adaptive Cards directly in ruby. YOu can output the result of the builder as JSON for future use with `TeamsController::Notification::AdaptiveCard#pretty_print`.
68
97
 
@@ -27,5 +27,16 @@ module TeamsConnector
27
27
  def channel(name, url)
28
28
  @channels[name] = url;
29
29
  end
30
+
31
+ def load_from_rails_credentials
32
+ unless defined? Rails
33
+ raise RuntimeError, "This method is only available in Ruby on Rails."
34
+ end
35
+
36
+ webhook_urls = Rails.application.credentials.teams_connector!
37
+ webhook_urls.each do |entry|
38
+ channel(entry[0], entry[1])
39
+ end
40
+ end
30
41
  end
31
42
  end
@@ -1,3 +1,3 @@
1
1
  module TeamsConnector
2
- VERSION = "0.1.1"
2
+ VERSION = "0.1.2"
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: teams_connector
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.1
4
+ version: 0.1.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Lucas Keune
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2021-11-15 00:00:00.000000000 Z
11
+ date: 2021-11-16 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler