msgraph-api 0.0.1 → 0.0.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: c7ac961753f90041dbf2c3d0705ee22fd78d1d66816c905a5d0309995373882e
4
- data.tar.gz: d1344c1156ef26f08af5e32e69ab153ad3f0eccbeb4f0bf6c9a119cc43406265
3
+ metadata.gz: 0bf5dffdb983eaba5c4517b3035f6ac9da673635f17c6028fa8636fed6d84fe1
4
+ data.tar.gz: 3ce62724c508c4883004832633a9dca8f37997948f6f8c33e316c80d522b50db
5
5
  SHA512:
6
- metadata.gz: cbcb3480b0264a8d97dea46a49bce4e8c95b145b4d28e0153ca00648884cbc3d9126f0b22f6c1d8bfc74408d8703bebd9627dca186da74cb65c3c28d92486c3c
7
- data.tar.gz: e7322e952349f8b8c6c42d2ce9c3875c4d4fd62e28b4ce815c2835ca624176a636de1550ebdfc53f74976f2041da44936a37b4f1d089362e8ff01c1e407b0501
6
+ metadata.gz: 9cd36861d1e7389ab4d4e551b82ad071c63459d91591f93dc0cd9aa080edcae40b1e5785824e3a656921c6e89654eaa9f2d1e4389da31f1a4c31f01afe801b58
7
+ data.tar.gz: 618b8e6adbd9bb8a6f06f158f87395413e272736ff5f144a946b36ff8cb79591e081734a300228015884f585265ff02b7bcfce319549acaf657059871aa0e06b
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- msgraph-api (0.0.1)
4
+ msgraph-api (0.0.2)
5
5
  activesupport (>= 5.2)
6
6
  microsoft_graph_mailer (~> 0.1.0)
7
7
 
@@ -14,11 +14,12 @@ GEM
14
14
  minitest (>= 5.1)
15
15
  tzinfo (~> 2.0)
16
16
  concurrent-ruby (1.1.10)
17
+ date (3.3.3)
17
18
  debase (0.2.4.1)
18
19
  debase-ruby_core_source (>= 0.10.2)
19
20
  debase-ruby_core_source (0.10.18)
20
21
  diff-lcs (1.5.0)
21
- faraday (2.7.1)
22
+ faraday (2.7.2)
22
23
  faraday-net_http (>= 2.0, < 3.1)
23
24
  ruby2_keywords (>= 0.0.4)
24
25
  faraday-net_http (3.0.2)
@@ -26,14 +27,26 @@ GEM
26
27
  i18n (1.12.0)
27
28
  concurrent-ruby (~> 1.0)
28
29
  jwt (2.5.0)
29
- mail (2.7.1)
30
+ mail (2.8.0)
30
31
  mini_mime (>= 0.1.1)
32
+ net-imap
33
+ net-pop
34
+ net-smtp
31
35
  microsoft_graph_mailer (0.1.0)
32
36
  mail (~> 2.7)
33
37
  oauth2 (>= 1.4.4, < 3)
34
38
  mini_mime (1.1.2)
35
39
  minitest (5.16.3)
36
40
  multi_xml (0.6.0)
41
+ net-imap (0.3.2)
42
+ date
43
+ net-protocol
44
+ net-pop (0.1.2)
45
+ net-protocol
46
+ net-protocol (0.2.1)
47
+ timeout
48
+ net-smtp (0.3.3)
49
+ net-protocol
37
50
  oauth2 (2.0.9)
38
51
  faraday (>= 0.17.3, < 3.0)
39
52
  jwt (>= 1.0, < 3.0)
@@ -41,7 +54,7 @@ GEM
41
54
  rack (>= 1.2, < 4)
42
55
  snaky_hash (~> 2.0)
43
56
  version_gem (~> 1.1)
44
- rack (3.0.1)
57
+ rack (3.0.2)
45
58
  rake (13.0.6)
46
59
  rspec (3.12.0)
47
60
  rspec-core (~> 3.12.0)
@@ -62,6 +75,7 @@ GEM
62
75
  snaky_hash (2.0.1)
63
76
  hashie
64
77
  version_gem (~> 1.1, >= 1.1.1)
78
+ timeout (0.3.1)
65
79
  tzinfo (2.0.5)
66
80
  concurrent-ruby (~> 1.0)
67
81
  version_gem (1.1.1)
data/README.md CHANGED
@@ -1,6 +1,8 @@
1
1
  # Msgraph::Api
2
2
 
3
- Client to connect to Microsoft's Graph API (Office365), based on [Gitlab's microsoft_graph_mailer gem](https://gitlab.com/gitlab-org/gitlab/-/tree/master/vendor/gems/microsoft_graph_mailer). Authentication is based on Azure AD's OAuth2 method. In order to login you need to register an application in Azure AD, with appropriate permissions. For OAuth2 access you will also need to create a client secret.
3
+ Client to connect to Microsoft's Graph API (Office365). As Microsoft will discontinue support for basic auth on IMAP, POP3, EWS,... we sought for a way to access exchange mail servers using modern APIs and state of the art authentication. Microsofts recommendation for this is [Microsoft Graph API](https://learn.microsoft.com/en-us/graph/?view=graph-rest-1.0), and there is already a basic implementation that enables ActionMailer to use this API by [Gitlab's microsoft_graph_mailer gem](https://gitlab.com/gitlab-org/gitlab/-/tree/master/vendor/gems/microsoft_graph_mailer) (Excellent work, thanks!). This gem is using [microsoft_graph_mailer](https://gitlab.com/gitlab-org/gitlab/-/tree/master/vendor/gems/microsoft_graph_mailer) as a basis to build an API to access exchange mail servers not only for sending APIs but also for receiving and managing messages. Still this gem integrates with ActionMailer the same way [microsoft_graph_mailer](https://gitlab.com/gitlab-org/gitlab/-/tree/master/vendor/gems/microsoft_graph_mailer) does.
4
+
5
+ Authentication is based on Azure AD's OAuth2 method. In order to login you need to register an application in Azure AD, with appropriate permissions. For OAuth2 access you will also need to create a client secret.
4
6
 
5
7
 
6
8
  ## Installation
@@ -0,0 +1,16 @@
1
+ module Msgraph
2
+ module Api
3
+ class NonMultipartInterceptor
4
+ def self.delivering_email(message)
5
+ if !message.multipart?
6
+ # multipart mails are rendered correctly, as the encoding
7
+ # ships with every part of the mail. But I think in case of
8
+ # single part messages, exchange is guessing the encoding
9
+ # ... and gets it totally wrong. So we force UTF-8 for
10
+ # mail transport and MS Graph API is happy with that.
11
+ message.transport_encoding = Encoding::UTF_8
12
+ end
13
+ end
14
+ end
15
+ end
16
+ end
@@ -0,0 +1,18 @@
1
+ require "msgraph/api/non_multipart_interceptor"
2
+
3
+ module Msgraph
4
+ module Api
5
+ class Railtie < Rails::Railtie
6
+
7
+ config.after_initialize do
8
+ if config.action_mailer.delivery_method == :microsoft_graph
9
+ # add interceptors for "post processing" of mails only if
10
+ # MS Graph API is used for mail transmission.
11
+ config.action_mailer.interceptors ||= []
12
+ config.action_mailer.interceptors << "Msgraph::Api::NonMultipartInterceptor"
13
+ end
14
+ end
15
+
16
+ end
17
+ end
18
+ end
@@ -2,6 +2,6 @@
2
2
 
3
3
  module Msgraph
4
4
  module Api
5
- VERSION = "0.0.1"
5
+ VERSION = "0.0.2"
6
6
  end
7
7
  end
data/lib/msgraph/api.rb CHANGED
@@ -1,16 +1,17 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- require_relative "../microsoft_graph_mailer/client"
4
- require_relative "../string"
5
- require_relative "../hash"
6
- require_relative "api/version"
7
- require_relative "api/errors"
8
- require_relative "api/resource/base"
9
- require_relative "api/resource/list"
10
- require_relative "api/resource/message"
11
- require_relative "api/resource/mail_folder"
12
- require_relative "api/resource/user"
13
- require_relative "api/client"
3
+ require "msgraph/../microsoft_graph_mailer/client"
4
+ require "msgraph/../string"
5
+ require "msgraph/../hash"
6
+ require "msgraph/api/version"
7
+ require "msgraph/api/errors"
8
+ require "msgraph/api/resource/base"
9
+ require "msgraph/api/resource/list"
10
+ require "msgraph/api/resource/message"
11
+ require "msgraph/api/resource/mail_folder"
12
+ require "msgraph/api/resource/user"
13
+ require "msgraph/api/client"
14
+ require "msgraph/api/railtie" if defined?(Rails::Railtie)
14
15
 
15
16
  module Msgraph
16
17
  module Api
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: msgraph-api
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.1
4
+ version: 0.0.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Tobi Schmid
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2022-12-08 00:00:00.000000000 Z
11
+ date: 2022-12-20 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: microsoft_graph_mailer
@@ -89,6 +89,8 @@ files:
89
89
  - lib/msgraph/api.rb
90
90
  - lib/msgraph/api/client.rb
91
91
  - lib/msgraph/api/errors.rb
92
+ - lib/msgraph/api/non_multipart_interceptor.rb
93
+ - lib/msgraph/api/railtie.rb
92
94
  - lib/msgraph/api/resource/base.rb
93
95
  - lib/msgraph/api/resource/list.rb
94
96
  - lib/msgraph/api/resource/mail_folder.rb
@@ -96,7 +98,6 @@ files:
96
98
  - lib/msgraph/api/resource/user.rb
97
99
  - lib/msgraph/api/version.rb
98
100
  - lib/string.rb
99
- - msg
100
101
  - msgraph-api.gemspec
101
102
  homepage: https://gitlab.com/digitalwerk/community/gems/msgraph-api
102
103
  licenses: []
data/msg DELETED
@@ -1,92 +0,0 @@
1
- Received: from GV1P189MB2106.EURP189.PROD.OUTLOOK.COM (2603:10a6:150:56::18)
2
- by HE1P189MB0556.EURP189.PROD.OUTLOOK.COM with HTTPS; Mon, 28 Nov 2022
3
- 14:23:37 +0000
4
- Received: from DB8P189MB0904.EURP189.PROD.OUTLOOK.COM (2603:10a6:10:166::20)
5
- by GV1P189MB2106.EURP189.PROD.OUTLOOK.COM (2603:10a6:150:56::18) with
6
- Microsoft SMTP Server (version=TLS1_2,
7
- cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5880.5; Mon, 28 Nov
8
- 2022 14:23:36 +0000
9
- Received: from DB8P189MB0904.EURP189.PROD.OUTLOOK.COM
10
- ([fe80::2033:e347:6de9:ec88]) by DB8P189MB0904.EURP189.PROD.OUTLOOK.COM
11
- ([fe80::2033:e347:6de9:ec88%8]) with mapi id 15.20.5880.008; Mon, 28 Nov 2022
12
- 14:23:35 +0000
13
- From: "noreply (Digitalwerk GmbH)" <noreply@digitalwerk.net>
14
- To: "Support (Digitalwerk GmbH)" <support@digitalwerk.net>
15
- Subject: Letzte Testnachricht
16
- Thread-Topic: Letzte Testnachricht
17
- Thread-Index: AQHZAzT/jjhB3d+BOES51F2N/wQdwg==
18
- Date: Mon, 28 Nov 2022 14:23:35 +0000
19
- Message-ID: <6384c46522c3a_19d751c1524f@95b90cc98fba.mail>
20
- Reply-To: "Lukas Hiereth (Digitalwerk GmbH)" <Lukas.Hiereth@digitalwerk.net>
21
- Accept-Language: de-DE, en-US
22
- Content-Language: en-US
23
- X-MS-Exchange-Organization-AuthAs: Internal
24
- X-MS-Exchange-Organization-AuthMechanism: 04
25
- X-MS-Exchange-Organization-AuthSource: DB8P189MB0904.EURP189.PROD.OUTLOOK.COM
26
- X-MS-Has-Attach:
27
- X-MS-Exchange-Organization-Network-Message-Id:
28
- 779e8264-3301-4df1-0989-08dad14c225e
29
- X-MS-Exchange-Organization-SCL: -1
30
- X-MS-TNEF-Correlator:
31
- X-MS-Exchange-Organization-RecordReviewCfmType: 0
32
- x-ms-publictraffictype: Email
33
- x-ms-exchange-transport-endtoendlatency: 00:00:02.8907979
34
- x-ms-exchange-processed-by-bccfoldering: 15.20.5880.008
35
- authentication-results: dkim=none (message not signed)
36
- header.d=none;dmarc=none action=none header.from=digitalwerk.net;
37
- x-forefront-antispam-report:
38
- CIP:255.255.255.255;CTRY:;LANG:de;SCL:-1;SRV:;IPV:NLI;SFV:SKI;H:DB8P189MB0904.EURP189.PROD.OUTLOOK.COM;PTR:;CAT:NONE;SFS:;DIR:INB;
39
- x-ms-office365-filtering-correlation-id: 779e8264-3301-4df1-0989-08dad14c225e
40
- x-microsoft-antispam: BCL:0;
41
- x-ms-traffictypediagnostic: DB8P189MB0904:EE_|GV1P189MB2106:EE_
42
- x-ms-exchange-crosstenant-network-message-id:
43
- 779e8264-3301-4df1-0989-08dad14c225e
44
- x-ms-exchange-crosstenant-originalarrivaltime: 28 Nov 2022 14:23:35.0341 (UTC)
45
- x-ms-exchange-crosstenant-fromentityheader: Hosted
46
- x-ms-exchange-crosstenant-id: 1daa929d-0264-46b8-b2e5-2e8116be53da
47
- x-ms-exchange-transport-crosstenantheadersstamped: GV1P189MB2106
48
- x-ms-exchange-crosstenant-mailboxtype: HOSTED
49
- x-ms-exchange-crosstenant-userprincipalname:
50
- NXEA9/EG9BfCyU6FvHXhp0QoBDoJUd9Dooh7//ojQcBIMec6CasZTly2X/4ZEyWo6rVsDdbfaTJ1bW0j9Ff9WQ==
51
- x-ms-exchange-crosstenant-authas: Internal
52
- x-ms-exchange-crosstenant-authsource: DB8P189MB0904.EURP189.PROD.OUTLOOK.COM
53
- X-Microsoft-Antispam-Mailbox-Delivery:
54
- ucf:0;jmr:0;auth:0;dest:I;ENG:(910001)(944506478)(944626604)(920097)(425001)(930097);
55
- X-Microsoft-Antispam-Message-Info:
56
- 1/Tw5Iz0hbC2Z9iwVQ8RSTIbDAl9mXZtd+p3/XxiX0MCmytO5drwjPJOfrfstdrtz2gl8zC9r0kMAn+2xA5RSV/D8ZrLH3N8/I4EAY3TgkyzY38S/riS+SFFmCi4yz+Y4uAtXs/NqBnq/LXcx12THtNqouTKlvnhxpHV1SBJa7WiYAXtx/BC0B78oYqa8g1uRnajnLvX6kE2Rho8eztxQWUSx33FIpMzjMy8xXM/B1FYbyLZbWmvSG3ivE0bfepcIbF2GrwaYR0EB0594rPd5ezbFXqcelK0v9ohGFbnhPjd0X/5WvNqpCXP+7INBo3MvawVj1qPO8Cy3bIZHNMjhP+NAev1XqYHCIZRnBszeMX+ItFWlrjYvhOJBsKrsD9sHRGFS1/zvxLKMtk0Ut+sQUJn04cKDHNVga26vMAs2ROLNI51G/0MaYn58B+rgv421sNz8ZnVEbCUulxU9UVefHexonpwxaslDgnNh7k65HAGFyWiT384LKs5Qatvw9+UbXUjReOcd5FewcLtLoIN6tQfqdra2gf3iw0dvDLH9oW4MVomKtc7YV1NWI9VU27+BIlJ7gAXl6mwZWFiZijmdq89b0p3cSsi3Z1V4vZyseRBwhPII/RP7YmhotFdYdELcVMigGvvX+T6k2aY2DmeUZIC6WlFDZvW6oxdp2PxSANJnmDKDQFRf8TwbdQm6cr6Gb7WatWBpfrOuHTcKXRFPw==
57
- Content-Type: multipart/alternative;
58
- boundary="_000_6384c46522c3a19d751c1524f95b90cc98fbamail_"
59
- MIME-Version: 1.0
60
-
61
- --_000_6384c46522c3a19d751c1524f95b90cc98fbamail_
62
- Content-Type: text/plain; charset="utf-8"
63
- Content-Transfer-Encoding: base64
64
-
65
- SGFsbG8gU3VwcG9ydC1UZWFtLA0KDQpmb2xnZW5kZSBOYWNocmljaHQgaXN0IGVpbmdlZ2FuZ2Vu
66
- Og0KDQpBYnNlbmRlcjoNCg0KTHVrYXMgSGllcmV0aA0KDQpFLU1haWw6DQoNCmx1a2FzLmhpZXJl
67
- dGhAZGlnaXRhbHdlcmsubmV0DQoNCkJldHJlZmY6DQoNCkxldHp0ZSBUZXN0bmFjaHJpY2h0DQoN
68
- Ck5hY2hyaWNodDoNCg0KZXdyd2VyZXdyd3dyDQp3ZXINCndlcg0Kd2UNCnINCndlDQpyZXcNCmVy
69
- ZXdld3J3ZXJld2VyIDwzDQo=
70
-
71
- --_000_6384c46522c3a19d751c1524f95b90cc98fbamail_
72
- Content-Type: text/html; charset="utf-8"
73
- Content-ID: <0684D6A186149F4AB27D008B8F70DFEE@EURP189.PROD.OUTLOOK.COM>
74
- Content-Transfer-Encoding: base64
75
-
76
- PCFET0NUWVBFIGh0bWw+DQo8aHRtbD4NCjxoZWFkPg0KPG1ldGEgaHR0cC1lcXVpdj0iQ29udGVu
77
- dC1UeXBlIiBjb250ZW50PSJ0ZXh0L2h0bWw7IGNoYXJzZXQ9dXRmLTgiPg0KPG1ldGEgbmFtZT0i
78
- dmlld3BvcnQiIGNvbnRlbnQ9IndpZHRoPWRldmljZS13aWR0aCwgaW5pdGlhbC1zY2FsZT0xLCBz
79
- aHJpbmstdG8tZml0PW5vIj4NCjxzdHlsZT4NCiAgICAgIC8qIEVtYWlsIHN0eWxlcyBuZWVkIHRv
80
- IGJlIGlubGluZSAqLw0KICAgIDwvc3R5bGU+DQo8L2hlYWQ+DQo8Ym9keT4NCjxoND5IYWxsbyBT
81
- dXBwb3J0LVRlYW0sPC9oND4NCjxwPmZvbGdlbmRlIE5hY2hyaWNodCBpc3QgZWluZ2VnYW5nZW46
82
- PC9wPg0KPHN0cm9uZz5BYnNlbmRlcjo8L3N0cm9uZz4NCjxwIHN0eWxlPSJwYWRkaW5nLXRvcDog
83
- MDsgbWFyZ2luLXRvcDogMDsiPkx1a2FzIEhpZXJldGg8L3A+DQo8c3Ryb25nPkUtTWFpbDo8L3N0
84
- cm9uZz4NCjxwIHN0eWxlPSJwYWRkaW5nLXRvcDogMDsgbWFyZ2luLXRvcDogMDsiPmx1a2FzLmhp
85
- ZXJldGhAZGlnaXRhbHdlcmsubmV0PC9wPg0KPHN0cm9uZz5CZXRyZWZmOjwvc3Ryb25nPg0KPHAg
86
- c3R5bGU9InBhZGRpbmctdG9wOiAwOyBtYXJnaW4tdG9wOiAwOyI+TGV0enRlIFRlc3RuYWNocmlj
87
- aHQ8L3A+DQo8c3Ryb25nPk5hY2hyaWNodDo8L3N0cm9uZz4NCjxwIHN0eWxlPSJwYWRkaW5nLXRv
88
- cDogMDsgbWFyZ2luLXRvcDogMDsiPmV3cndlcmV3cnd3ciA8YnI+DQp3ZXIgPGJyPg0Kd2VyIDxi
89
- cj4NCndlIDxicj4NCnIgPGJyPg0Kd2UgPGJyPg0KcmV3IDxicj4NCmVyZXdld3J3ZXJld2VyICZs
90
- dDszPC9wPg0KPC9ib2R5Pg0KPC9odG1sPg0K
91
-
92
- --_000_6384c46522c3a19d751c1524f95b90cc98fbamail_--