omniauth-marvin 1.0.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: 8973cc487ddd0c9c10d27e88a1321db5a7796ef5
4
+ data.tar.gz: d4ad963f6c13f543c53d58aa6fa2d6e2b60389bd
5
+ SHA512:
6
+ metadata.gz: 3fb8073c2e268d037117ce83bf8df3cad44a469f1df04ece5892dc45a65c53118a17037d6fe40190ab6e35a73a68c799a0eeaa0cc0d1b2db3c571883deec60c8
7
+ data.tar.gz: cc5717573ba18833ae87c07b6d39c5e050c948da059169512a5590dc89fc4ed9a4f0e7bdc439668b0ece3a5b3e6c6f08eeed8f113c5b1618478eed8d13d4e0ba
data/.gitignore ADDED
@@ -0,0 +1,9 @@
1
+ /.bundle/
2
+ /.yardoc
3
+ /Gemfile.lock
4
+ /_yardoc/
5
+ /coverage/
6
+ /doc/
7
+ /pkg/
8
+ /spec/reports/
9
+ /tmp/
data/.rspec ADDED
@@ -0,0 +1,3 @@
1
+ --color
2
+ --require spec_helper
3
+ --format documentation
data/.travis.yml ADDED
@@ -0,0 +1,4 @@
1
+ language: ruby
2
+ rvm:
3
+ - 2.2.2
4
+ before_install: gem install bundler -v 1.10.6
data/Gemfile ADDED
@@ -0,0 +1,14 @@
1
+ source 'https://rubygems.org'
2
+
3
+ # Specify your gem's dependencies in omniauth-marvin.gemspec
4
+ gemspec
5
+
6
+ gem 'rake', '~> 10.0'
7
+
8
+ group :test do
9
+ gem 'rspec'
10
+ gem 'rack-test'
11
+ gem 'webmock'
12
+ gem 'simplecov', require: false
13
+ gem 'coveralls', require: false
14
+ end
data/LICENSE.txt ADDED
@@ -0,0 +1,21 @@
1
+ The MIT License (MIT)
2
+
3
+ Copyright (c) 2015 Samy KACIMI
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
13
+ all 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
21
+ THE SOFTWARE.
data/README.md ADDED
@@ -0,0 +1,850 @@
1
+ # Omniauth Marvin
2
+
3
+ [![Build Status](https://travis-ci.org/fakenine/omniauth-marvin.svg)](https://travis-ci.org/fakenine/omniauth-marvin) [![Code Climate](https://codeclimate.com/repos/5603ccdee30ba01582008c19/badges/acaf7e62ac0c254e87ef/gpa.svg)](https://codeclimate.com/repos/5603ccdee30ba01582008c19/feed) [![Coverage Status](https://coveralls.io/repos/fakenine/omniauth-marvin/badge.svg?branch=master&service=github)](https://coveralls.io/github/fakenine/omniauth-marvin?branch=master)
4
+
5
+ OmniAuth OAuth2 strategy for 42 School.
6
+
7
+ ## Installation
8
+
9
+ Add this line to your application's Gemfile:
10
+
11
+ ```ruby
12
+ gem 'omniauth-marvin', github: "fakenine/omniauth-marvin"
13
+ ```
14
+
15
+ run `bundle install`
16
+
17
+ ## Usage
18
+
19
+ Register your application on 42's intranet to receive an API Key.
20
+
21
+ Here's an example for adding the middleware to a Rails app in `config/initializers/omniauth.rb`
22
+
23
+ ```ruby
24
+ Rails.application.config.middleware.use OmniAuth::Builder do
25
+ provider :marvin, ENV["FT_ID"], ENV["FT_SECRET"]
26
+ end
27
+ ```
28
+
29
+ You can now access the OmniAuth 42 OAuth2 URL: `/auth/marvin`
30
+
31
+ ## Devise
32
+
33
+ If you wish to use this gem with devise, do not use the code snippet above in the Usage section. Instead, follow these steps:
34
+
35
+ Add the devise gem to your Gemfile.
36
+
37
+ ```ruby
38
+ gem 'devise'
39
+ ```
40
+
41
+ run `bundle install`
42
+
43
+ #### Generate migrations and models
44
+
45
+ ```
46
+ rails g devise:install
47
+ rails g devise user
48
+ rails g migration AddNicknameToUsers nickname:string
49
+ rails g migration AddOmniauthToUsers provider:index uid:index
50
+ rake db:migrate
51
+ ```
52
+
53
+ You can add any additional migration you want. For instance, phone, level, wallet...etc.
54
+
55
+ #### Declare the provider
56
+ `config/initializers/devise.rb`
57
+
58
+ ```ruby
59
+ Devise.setup do |config|
60
+ .
61
+ .
62
+ config.omniauth :marvin, ENV["FT_ID"], ENV["FT_SECRET"]
63
+ .
64
+ .
65
+ end
66
+ ```
67
+
68
+ Don't forget to set the "FT_ID" and "FT_SECRET" (your app id and secret) in your environment variables.
69
+
70
+
71
+ #### Make your model omniauthable
72
+
73
+ In this case, `app/models/user.rb`
74
+
75
+ ```ruby
76
+ class User < ActiveRecord::Base
77
+ devise :database_authenticatable, :registerable,
78
+ :recoverable, :rememberable, :trackable, :validatable,
79
+ :omniauthable, omniauth_providers: [:marvin]
80
+ end
81
+ ```
82
+
83
+ #### Add the from_omniauth class method to the user model
84
+
85
+ `app/models/user.rb`
86
+
87
+ Example:
88
+
89
+ ```ruby
90
+ def self.from_omniauth(auth)
91
+ where(provider: auth.provider, uid: auth.uid).first_or_create do |user|
92
+ user.email = auth.info.email
93
+ user.password = Devise.friendly_token[0,20]
94
+ user.nickname = auth.info.nickname
95
+ end
96
+ end
97
+ ```
98
+
99
+ #### Implement a callback in the routes
100
+
101
+ `config/routes.rb`
102
+
103
+ ```ruby
104
+ devise_for :users, controllers: { omniauth_callbacks: "users/omniauth_callbacks" }
105
+ ```
106
+
107
+ #### Create the callbacks controller
108
+
109
+ `app/controllers/users/omniauth_callbacks_controller.rb`
110
+
111
+ Example:
112
+
113
+ ```ruby
114
+ class Users::OmniauthCallbacksController < Devise::OmniauthCallbacksController
115
+ def marvin
116
+ @user = User.from_omniauth(request.env["omniauth.auth"])
117
+
118
+ if @user.persisted?
119
+ sign_in_and_redirect @user, :event => :authentication
120
+ set_flash_message(:notice, :success, :kind => "42") if is_navigational_format?
121
+ else
122
+ session["devise.marvin_data"] = request.env["omniauth.auth"]
123
+ redirect_to new_user_registration_url
124
+ end
125
+ end
126
+ end
127
+ ```
128
+
129
+ #### Add the Sign Out route
130
+
131
+ `config/routes.rb`
132
+
133
+ ```ruby
134
+ devise_scope :user do
135
+ delete 'sign_out', :to => 'devise/sessions#destroy', :as => :destroy_user_session_path
136
+ end
137
+ ```
138
+
139
+ #### Login/logout links
140
+
141
+ Here's a (very) basic example for login/logout links in the views
142
+
143
+ ```
144
+ <%= link_to "Sign in with 42", user_omniauth_authorize_path(:marvin) %>
145
+ ```
146
+
147
+ ```
148
+ <%= link_to "Sign out", destroy_user_session_path, :method => :delete %>
149
+ ```
150
+
151
+
152
+ #### More info
153
+
154
+ This section about devise and Omniauth was written with the help of devise documentation.
155
+ More info about devise and Omniauth on [their documentation](https://github.com/plataformatec/devise/wiki/OmniAuth:-Overview "their documentation").
156
+
157
+ ## Auth hash
158
+
159
+ Here's an example of the auth hash available in request.env['omniauth.auth']:
160
+
161
+ ```json
162
+ {
163
+ "provider": "marvin",
164
+ "uid": 12345,
165
+ "info": {
166
+ "name": "Samy KACIMI",
167
+ "email": "skacimi@student.42.fr",
168
+ "nickname": "skacimi",
169
+ "location": null,
170
+ "image": "https://cdn.42.fr/userprofil/profilview/skacimi.jpg",
171
+ "phone": null,
172
+ "urls": {
173
+ "Profile": "https://api.intrav2.42.fr/v2/users/skacimi"
174
+ }
175
+ },
176
+ "credentials": {
177
+ "token": "a1b2c3d4e5f6...",
178
+ "expires_at": 1443035254,
179
+ "expires": true
180
+ },
181
+ "extra": {
182
+ "raw_info": {
183
+ "id": 12345,
184
+ "alias": [
185
+ "samy.kacimi@student.42.fr",
186
+ "kacimi.samy@student.42.fr",
187
+ "skacimi@student.42.fr"
188
+ ],
189
+ "email": "skacimi@student.42.fr",
190
+ "login": "skacimi",
191
+ "url": "https://api.intrav2.42.fr/v2/users/skacimi",
192
+ "mobile": null,
193
+ "displayname": "Samy KACIMI",
194
+ "image_url": "https://cdn.42.fr/userprofil/profilview/skacimi.jpg",
195
+ "staff?": false,
196
+ "correction_point": 7,
197
+ "location": null,
198
+ "campus": {
199
+ "id": 1,
200
+ "name": "Paris",
201
+ "created_at": "2015-05-19T12:53:31.459+02:00",
202
+ "updated_at": "2015-07-20T19:28:05.730+02:00",
203
+ "time_zone": "Paris",
204
+ "language_id": 1,
205
+ "slug": "paris"
206
+ },
207
+ "wallet": 70,
208
+ "groups": [
209
+
210
+ ],
211
+ "cursus": {
212
+ "cursus": {
213
+ "id": 1,
214
+ "name": "42",
215
+ "created_at": "2014-11-02T17:43:38.480+01:00",
216
+ "updated_at": "2015-07-21T14:31:01.625+02:00",
217
+ "slug": "42"
218
+ },
219
+ "end_at": null,
220
+ "level": 7.15,
221
+ "grade": "Midshipman",
222
+ "projects": [
223
+ {
224
+ "name": "Introduction to Wordpress",
225
+ "id": 14,
226
+ "slug": "rushes-introduction-to-wordpress",
227
+ "final_mark": 84,
228
+ "occurrence": 0,
229
+ "retriable_at": null,
230
+ "teams_ids": [
231
+ 4017
232
+ ]
233
+ },
234
+ {
235
+ "name": "Push_swap",
236
+ "id": 27,
237
+ "slug": "push_swap",
238
+ "final_mark": 84,
239
+ "occurrence": 1,
240
+ "retriable_at": "2015-03-24T20:13:00.000+01:00",
241
+ "teams_ids": [
242
+ 55646,
243
+ 60613
244
+ ]
245
+ },
246
+ {
247
+ "name": "Piscine PHP",
248
+ "id": 48,
249
+ "slug": "piscine-php",
250
+ "final_mark": 81,
251
+ "occurrence": 0,
252
+ "retriable_at": "2015-03-30T17:40:57.000+02:00",
253
+ "teams_ids": [
254
+ 64600
255
+ ]
256
+ },
257
+ {
258
+ "name": "D06",
259
+ "id": 55,
260
+ "slug": "piscine-php-d06",
261
+ "final_mark": 13,
262
+ "occurrence": 0,
263
+ "retriable_at": "2015-03-30T17:41:30.000+02:00",
264
+ "teams_ids": [
265
+ 64607
266
+ ]
267
+ },
268
+ {
269
+ "name": "Wolf3d",
270
+ "id": 8,
271
+ "slug": "wolf3d",
272
+ "final_mark": 91,
273
+ "occurrence": 0,
274
+ "retriable_at": "2015-04-04T11:57:10.000+02:00",
275
+ "teams_ids": [
276
+ 53923
277
+ ]
278
+ },
279
+ {
280
+ "name": "D09",
281
+ "id": 58,
282
+ "slug": "piscine-php-d09",
283
+ "final_mark": 58,
284
+ "occurrence": 0,
285
+ "retriable_at": "2015-03-30T17:42:10.000+02:00",
286
+ "teams_ids": [
287
+ 64610
288
+ ]
289
+ },
290
+ {
291
+ "name": "Libft",
292
+ "id": 1,
293
+ "slug": "libft",
294
+ "final_mark": 103,
295
+ "occurrence": 2,
296
+ "retriable_at": "2015-01-29T14:55:48.000+01:00",
297
+ "teams_ids": [
298
+ 117,
299
+ 6157,
300
+ 54350
301
+ ]
302
+ },
303
+ {
304
+ "name": "Fract'ol",
305
+ "id": 15,
306
+ "slug": "fract-ol",
307
+ "final_mark": 102,
308
+ "occurrence": 0,
309
+ "retriable_at": "2015-04-02T14:11:59.000+02:00",
310
+ "teams_ids": [
311
+ 60569
312
+ ]
313
+ },
314
+ {
315
+ "name": "First Internship",
316
+ "id": 118,
317
+ "slug": "first-internship",
318
+ "final_mark": null,
319
+ "occurrence": 0,
320
+ "retriable_at": null,
321
+ "teams_ids": [
322
+ 84976
323
+ ]
324
+ },
325
+ {
326
+ "name": "LibftASM",
327
+ "id": 79,
328
+ "slug": "libftasm",
329
+ "final_mark": 100,
330
+ "occurrence": 0,
331
+ "retriable_at": "2015-03-06T17:03:47.000+01:00",
332
+ "teams_ids": [
333
+ 57132
334
+ ]
335
+ },
336
+ {
337
+ "name": "C Exam - Beginner",
338
+ "id": 11,
339
+ "slug": "c-exam-beginner",
340
+ "final_mark": 80,
341
+ "occurrence": 13,
342
+ "retriable_at": "2015-05-27T18:33:17.000+02:00",
343
+ "teams_ids": [
344
+ 3107,
345
+ 5187,
346
+ 56010,
347
+ 59778,
348
+ 60718,
349
+ 61716,
350
+ 62922,
351
+ 63373,
352
+ 75451,
353
+ 78206,
354
+ 78665,
355
+ 83011,
356
+ 83635,
357
+ 84658
358
+ ]
359
+ },
360
+ {
361
+ "name": "Duration",
362
+ "id": 140,
363
+ "slug": "first-internship-duration",
364
+ "final_mark": null,
365
+ "occurrence": 0,
366
+ "retriable_at": null,
367
+ "teams_ids": [
368
+ 95077
369
+ ]
370
+ },
371
+ {
372
+ "name": "Introduction to iOS",
373
+ "id": 18,
374
+ "slug": "rushes-introduction-to-ios",
375
+ "final_mark": 84,
376
+ "occurrence": 0,
377
+ "retriable_at": "2014-12-28T23:09:51.910+01:00",
378
+ "teams_ids": [
379
+ 4669
380
+ ]
381
+ },
382
+ {
383
+ "name": "FdF",
384
+ "id": 4,
385
+ "slug": "fdf",
386
+ "final_mark": 103,
387
+ "occurrence": 0,
388
+ "retriable_at": "2015-01-05T18:32:46.764+01:00",
389
+ "teams_ids": [
390
+ 2960
391
+ ]
392
+ },
393
+ {
394
+ "name": "Contract Upload",
395
+ "id": 119,
396
+ "slug": "first-internship-contract-upload",
397
+ "final_mark": 100,
398
+ "occurrence": 0,
399
+ "retriable_at": "2015-05-30T13:28:06.000+02:00",
400
+ "teams_ids": [
401
+ 85014
402
+ ]
403
+ },
404
+ {
405
+ "name": "Rush00",
406
+ "id": 59,
407
+ "slug": "piscine-php-rush00",
408
+ "final_mark": 69,
409
+ "occurrence": 0,
410
+ "retriable_at": "2015-04-10T18:55:10.000+02:00",
411
+ "teams_ids": [
412
+ 76109
413
+ ]
414
+ },
415
+ {
416
+ "name": "Rush01",
417
+ "id": 60,
418
+ "slug": "piscine-php-rush01",
419
+ "final_mark": 0,
420
+ "occurrence": 0,
421
+ "retriable_at": "2015-04-16T16:49:32.000+02:00",
422
+ "teams_ids": [
423
+ 77242
424
+ ]
425
+ },
426
+ {
427
+ "name": "D01",
428
+ "id": 50,
429
+ "slug": "piscine-php-d01",
430
+ "final_mark": 45,
431
+ "occurrence": 0,
432
+ "retriable_at": null,
433
+ "teams_ids": [
434
+ 64602
435
+ ]
436
+ },
437
+ {
438
+ "name": "D07",
439
+ "id": 56,
440
+ "slug": "piscine-php-d07",
441
+ "final_mark": 75,
442
+ "occurrence": 0,
443
+ "retriable_at": "2015-03-30T17:42:00.000+02:00",
444
+ "teams_ids": [
445
+ 64608
446
+ ]
447
+ },
448
+ {
449
+ "name": "D04",
450
+ "id": 53,
451
+ "slug": "piscine-php-d04",
452
+ "final_mark": 100,
453
+ "occurrence": 0,
454
+ "retriable_at": null,
455
+ "teams_ids": [
456
+ 64605
457
+ ]
458
+ },
459
+ {
460
+ "name": "D05",
461
+ "id": 54,
462
+ "slug": "piscine-php-d05",
463
+ "final_mark": 70,
464
+ "occurrence": 0,
465
+ "retriable_at": "2015-03-30T17:41:55.000+02:00",
466
+ "teams_ids": [
467
+ 64606
468
+ ]
469
+ },
470
+ {
471
+ "name": "wong_kar_wai",
472
+ "id": 93,
473
+ "slug": "rushes-wong_kar_wai",
474
+ "final_mark": 0,
475
+ "occurrence": 0,
476
+ "retriable_at": null,
477
+ "teams_ids": [
478
+ 58895
479
+ ]
480
+ },
481
+ {
482
+ "name": "Get_Next_Line",
483
+ "id": 2,
484
+ "slug": "get_next_line",
485
+ "final_mark": 102,
486
+ "occurrence": 0,
487
+ "retriable_at": "2014-11-22T18:29:02.195+01:00",
488
+ "teams_ids": [
489
+ 1241
490
+ ]
491
+ },
492
+ {
493
+ "name": "D08",
494
+ "id": 57,
495
+ "slug": "piscine-php-d08",
496
+ "final_mark": 0,
497
+ "occurrence": 0,
498
+ "retriable_at": "2015-03-30T17:41:36.000+02:00",
499
+ "teams_ids": [
500
+ 64609
501
+ ]
502
+ },
503
+ {
504
+ "name": "ft_ls",
505
+ "id": 3,
506
+ "slug": "ft_ls",
507
+ "final_mark": 0,
508
+ "occurrence": 0,
509
+ "retriable_at": "2015-01-17T19:13:33.000+01:00",
510
+ "teams_ids": [
511
+ 1971
512
+ ]
513
+ },
514
+ {
515
+ "name": "D02",
516
+ "id": 51,
517
+ "slug": "piscine-php-d02",
518
+ "final_mark": 13,
519
+ "occurrence": 0,
520
+ "retriable_at": "2015-03-30T17:41:17.000+02:00",
521
+ "teams_ids": [
522
+ 64603
523
+ ]
524
+ },
525
+ {
526
+ "name": "Rushes",
527
+ "id": 61,
528
+ "slug": "rushes",
529
+ "final_mark": null,
530
+ "occurrence": 0,
531
+ "retriable_at": null,
532
+ "teams_ids": [
533
+
534
+ ]
535
+ },
536
+ {
537
+ "name": "D03",
538
+ "id": 52,
539
+ "slug": "piscine-php-d03",
540
+ "final_mark": 100,
541
+ "occurrence": 0,
542
+ "retriable_at": null,
543
+ "teams_ids": [
544
+ 64604
545
+ ]
546
+ },
547
+ {
548
+ "name": "Savoir Relier",
549
+ "id": 96,
550
+ "slug": "savoir-relier",
551
+ "final_mark": 100,
552
+ "occurrence": 0,
553
+ "retriable_at": null,
554
+ "teams_ids": [
555
+ 62145
556
+ ]
557
+ },
558
+ {
559
+ "name": "Arkanoid",
560
+ "id": 141,
561
+ "slug": "rushes-arkanoid",
562
+ "final_mark": 0,
563
+ "occurrence": 0,
564
+ "retriable_at": null,
565
+ "teams_ids": [
566
+ 79069
567
+ ]
568
+ },
569
+ {
570
+ "name": "D00",
571
+ "id": 49,
572
+ "slug": "piscine-php-d00",
573
+ "final_mark": 118,
574
+ "occurrence": 0,
575
+ "retriable_at": null,
576
+ "teams_ids": [
577
+ 64601
578
+ ]
579
+ },
580
+ {
581
+ "name": "ft_sh1",
582
+ "id": 7,
583
+ "slug": "ft_sh1",
584
+ "final_mark": 97,
585
+ "occurrence": 0,
586
+ "retriable_at": "2015-02-10T16:24:33.000+01:00",
587
+ "teams_ids": [
588
+ 4776
589
+ ]
590
+ }
591
+ ],
592
+ "skills": [
593
+ {
594
+ "id": 2,
595
+ "name": "Imperative programming",
596
+ "level": 6.39
597
+ },
598
+ {
599
+ "id": 1,
600
+ "name": "Algorithms & AI",
601
+ "level": 6.2
602
+ },
603
+ {
604
+ "id": 5,
605
+ "name": "Graphics",
606
+ "level": 4.06
607
+ },
608
+ {
609
+ "id": 3,
610
+ "name": "Rigor",
611
+ "level": 3.95
612
+ },
613
+ {
614
+ "id": 4,
615
+ "name": "Unix",
616
+ "level": 1.8
617
+ },
618
+ {
619
+ "id": 6,
620
+ "name": "Web",
621
+ "level": 1.35
622
+ },
623
+ {
624
+ "id": 17,
625
+ "name": "Object-oriented programming",
626
+ "level": 0.63
627
+ },
628
+ {
629
+ "id": 14,
630
+ "name": "Adaptation & creativity",
631
+ "level": 0.34
632
+ },
633
+ {
634
+ "id": 12,
635
+ "name": "DB & Data",
636
+ "level": 0.21
637
+ },
638
+ {
639
+ "id": 10,
640
+ "name": "Network & system administration",
641
+ "level": 0.21
642
+ },
643
+ {
644
+ "id": 15,
645
+ "name": "Technology integration",
646
+ "level": 0.1
647
+ }
648
+ ]
649
+ },
650
+ "achievements": [
651
+ {
652
+ "id": 96,
653
+ "name": "Love me, I'm famous",
654
+ "description": "Avoir été upvoté 100 fois sur le forum.",
655
+ "users_url": "https://api.intrav2.42.fr/v2/achievements/96/users"
656
+ },
657
+ {
658
+ "id": 95,
659
+ "name": "Love me, I'm famous",
660
+ "description": "Avoir été upvoté 42 fois sur le forum.",
661
+ "users_url": "https://api.intrav2.42.fr/v2/achievements/95/users"
662
+ },
663
+ {
664
+ "id": 94,
665
+ "name": "Love me, I'm famous",
666
+ "description": "Avoir été upvoté 10 fois sur le forum.",
667
+ "users_url": "https://api.intrav2.42.fr/v2/achievements/94/users"
668
+ },
669
+ {
670
+ "id": 45,
671
+ "name": "Home is where the code is",
672
+ "description": "S'être logué dans le même cluster un mois de suite.",
673
+ "users_url": "https://api.intrav2.42.fr/v2/achievements/45/users"
674
+ },
675
+ {
676
+ "id": 41,
677
+ "name": "In the name of Nicolas",
678
+ "description": "Etre logué 90h sur une semaine. (à bosser, comme Nicolas vous l'a conseillé !)",
679
+ "users_url": "https://api.intrav2.42.fr/v2/achievements/41/users"
680
+ },
681
+ {
682
+ "id": 90,
683
+ "name": "I post, therefore I am",
684
+ "description": "Poster 10 messages sur le forum.",
685
+ "users_url": "https://api.intrav2.42.fr/v2/achievements/90/users"
686
+ },
687
+ {
688
+ "id": 1,
689
+ "name": "Welcome, Cadet !",
690
+ "description": "Tu as réussi ta piscine C. Bienvenue à 42 !",
691
+ "users_url": "https://api.intrav2.42.fr/v2/achievements/1/users"
692
+ },
693
+ {
694
+ "id": 57,
695
+ "name": "Attendee",
696
+ "description": "Assister à 21 conférences.",
697
+ "users_url": "https://api.intrav2.42.fr/v2/achievements/57/users"
698
+ },
699
+ {
700
+ "id": 56,
701
+ "name": "Attendee",
702
+ "description": "Assister à 10 conférences.",
703
+ "users_url": "https://api.intrav2.42.fr/v2/achievements/56/users"
704
+ },
705
+ {
706
+ "id": 55,
707
+ "name": "Attendee",
708
+ "description": "Assister à 3 conférences.",
709
+ "users_url": "https://api.intrav2.42.fr/v2/achievements/55/users"
710
+ },
711
+ {
712
+ "id": 54,
713
+ "name": "Attendee",
714
+ "description": "Assister à une conférence.",
715
+ "users_url": "https://api.intrav2.42.fr/v2/achievements/54/users"
716
+ },
717
+ {
718
+ "id": 84,
719
+ "name": "I'm reliable !",
720
+ "description": "Participer à 21 soutenances d'affilée sans en manquer aucune.",
721
+ "users_url": "https://api.intrav2.42.fr/v2/achievements/84/users"
722
+ },
723
+ {
724
+ "id": 91,
725
+ "name": "I post, therefore I am",
726
+ "description": "Poster 42 messages sur le forum.",
727
+ "users_url": "https://api.intrav2.42.fr/v2/achievements/91/users"
728
+ },
729
+ {
730
+ "id": 4,
731
+ "name": "Code Explorer",
732
+ "description": "Valider son premier projet.",
733
+ "users_url": "https://api.intrav2.42.fr/v2/achievements/4/users"
734
+ },
735
+ {
736
+ "id": 6,
737
+ "name": "Code Explorer",
738
+ "description": "Valider 10 projets.",
739
+ "users_url": "https://api.intrav2.42.fr/v2/achievements/6/users"
740
+ },
741
+ {
742
+ "id": 5,
743
+ "name": "Code Explorer",
744
+ "description": "Valider 3 projets.",
745
+ "users_url": "https://api.intrav2.42.fr/v2/achievements/5/users"
746
+ },
747
+ {
748
+ "id": 17,
749
+ "name": "Bonus Hunter",
750
+ "description": "Valider 1 projet avec le maximum de bonus.",
751
+ "users_url": "https://api.intrav2.42.fr/v2/achievements/17/users"
752
+ },
753
+ {
754
+ "id": 25,
755
+ "name": "Rigorous Basterd",
756
+ "description": "Valider 3 projets d'affilée (journées de piscines comprises).",
757
+ "users_url": "https://api.intrav2.42.fr/v2/achievements/25/users"
758
+ },
759
+ {
760
+ "id": 48,
761
+ "name": "Film buff",
762
+ "description": "Regarder 10 videos sur l'e-learning.",
763
+ "users_url": "https://api.intrav2.42.fr/v2/achievements/48/users"
764
+ },
765
+ {
766
+ "id": 82,
767
+ "name": "I have no idea what I'm doing",
768
+ "description": "Faire une soutenance sans avoir validé le projet.",
769
+ "users_url": "https://api.intrav2.42.fr/v2/achievements/82/users"
770
+ },
771
+ {
772
+ "id": 47,
773
+ "name": "Film buff",
774
+ "description": "Regarder 3 videos sur l'e-learning.",
775
+ "users_url": "https://api.intrav2.42.fr/v2/achievements/47/users"
776
+ },
777
+ {
778
+ "id": 87,
779
+ "name": "I post, therefore I am",
780
+ "description": "Poster 1 message sur le forum.",
781
+ "users_url": "https://api.intrav2.42.fr/v2/achievements/87/users"
782
+ },
783
+ {
784
+ "id": 79,
785
+ "name": "Perfect examiner",
786
+ "description": "Avoir un feedback correcteur à 100% sur 10 soutenances d'affilée.",
787
+ "users_url": "https://api.intrav2.42.fr/v2/achievements/79/users"
788
+ },
789
+ {
790
+ "id": 88,
791
+ "name": "Love me, I'm famous",
792
+ "description": "Avoir été upvoté 1 fois sur le forum.",
793
+ "users_url": "https://api.intrav2.42.fr/v2/achievements/88/users"
794
+ },
795
+ {
796
+ "id": 50,
797
+ "name": "Film buff",
798
+ "description": "Regarder 42 videos sur l'e-learning.",
799
+ "users_url": "https://api.intrav2.42.fr/v2/achievements/50/users"
800
+ },
801
+ {
802
+ "id": 49,
803
+ "name": "Film buff",
804
+ "description": "Regarder 21 videos sur l'e-learning.",
805
+ "users_url": "https://api.intrav2.42.fr/v2/achievements/49/users"
806
+ },
807
+ {
808
+ "id": 78,
809
+ "name": "Perfect examiner",
810
+ "description": "Avoir un feedback correcteur à 100% sur 3 soutenances d'affilée.",
811
+ "users_url": "https://api.intrav2.42.fr/v2/achievements/78/users"
812
+ },
813
+ {
814
+ "id": 46,
815
+ "name": "Film buff",
816
+ "description": "Regarder 1 video sur l'e-learning.",
817
+ "users_url": "https://api.intrav2.42.fr/v2/achievements/46/users"
818
+ }
819
+ ],
820
+ "titles": [
821
+
822
+ ]
823
+ }
824
+ }
825
+ }
826
+ ```
827
+
828
+ ## Licence
829
+
830
+ The MIT License (MIT)
831
+
832
+ Copyright (c) 2015 Samy KACIMI
833
+
834
+ Permission is hereby granted, free of charge, to any person obtaining a copy
835
+ of this software and associated documentation files (the "Software"), to deal
836
+ in the Software without restriction, including without limitation the rights
837
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
838
+ copies of the Software, and to permit persons to whom the Software is
839
+ furnished to do so, subject to the following conditions:
840
+
841
+ The above copyright notice and this permission notice shall be included in
842
+ all copies or substantial portions of the Software.
843
+
844
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
845
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
846
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
847
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
848
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
849
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
850
+ THE SOFTWARE.
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/marvin"
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
data/bin/setup ADDED
@@ -0,0 +1,7 @@
1
+ #!/bin/bash
2
+ set -euo pipefail
3
+ IFS=$'\n\t'
4
+
5
+ bundle install
6
+
7
+ # Do any other automated setup that you need to do here
@@ -0,0 +1 @@
1
+ require "omniauth/marvin"
@@ -0,0 +1,2 @@
1
+ require "omniauth/marvin/version"
2
+ require "omniauth/strategies/marvin"
@@ -0,0 +1,5 @@
1
+ module Omniauth
2
+ module Marvin
3
+ VERSION = "1.0.0"
4
+ end
5
+ end
@@ -0,0 +1,40 @@
1
+ require "omniauth/strategies/oauth2"
2
+
3
+ module OmniAuth
4
+ module Strategies
5
+ class Marvin < OmniAuth::Strategies::OAuth2
6
+ option :name, "marvin"
7
+
8
+ option :client_options, {
9
+ site: "https://api.intrav2.42.fr",
10
+ authorize_path: "v2/oauth/authorize"
11
+ }
12
+
13
+ uid { raw_info['id'] }
14
+
15
+ info do
16
+ {
17
+ name: raw_info["displayname"],
18
+ email: raw_info["email"],
19
+ nickname: raw_info["login"],
20
+ location: raw_info["location"],
21
+ image: raw_info["image_url"],
22
+ phone: raw_info["mobile"],
23
+ urls: {
24
+ "Profile" => raw_info["url"]
25
+ }
26
+ }
27
+ end
28
+
29
+ extra do
30
+ {
31
+ 'raw_info' => raw_info
32
+ }
33
+ end
34
+
35
+ def raw_info
36
+ @raw_info ||= access_token.get('v2/me').parsed
37
+ end
38
+ end
39
+ end
40
+ end
@@ -0,0 +1,34 @@
1
+ # coding: utf-8
2
+ lib = File.expand_path('../lib', __FILE__)
3
+ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
+ require 'omniauth/marvin/version'
5
+
6
+ Gem::Specification.new do |spec|
7
+ spec.name = "omniauth-marvin"
8
+ spec.version = Omniauth::Marvin::VERSION
9
+ spec.authors = ["Samy KACIMI"]
10
+ spec.email = ["samy.kacimi@gmail.com"]
11
+
12
+ spec.summary = %q{OmniAuth OAuth2 strategy for 42 School}
13
+ spec.description = %q{This gem is an OmniAuth OAuth2 strategy for 42 School. 42 Students can use it to signup/login on their apps.}
14
+ spec.homepage = "https://github.com/fakenine/omniauth-marvin"
15
+ spec.license = "MIT"
16
+
17
+ # Prevent pushing this gem to RubyGems.org by setting 'allowed_push_host', or
18
+ # delete this section to allow pushing this gem to any host.
19
+ if spec.respond_to?(:metadata)
20
+ spec.metadata['allowed_push_host'] = "https://rubygems.org"
21
+ else
22
+ raise "RubyGems 2.0 or newer is required to protect against public gem pushes."
23
+ end
24
+
25
+ spec.files = `git ls-files -z`.split("\x0").reject { |f| f.match(%r{^(test|spec|features)/}) }
26
+ spec.bindir = "exe"
27
+ spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
28
+ spec.require_paths = ["lib"]
29
+
30
+ spec.add_runtime_dependency 'omniauth-oauth2', '~> 1.2'
31
+ spec.add_runtime_dependency 'multi_json', '~> 1.3'
32
+
33
+ spec.add_development_dependency "bundler", "~> 1.10"
34
+ end
metadata ADDED
@@ -0,0 +1,102 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: omniauth-marvin
3
+ version: !ruby/object:Gem::Version
4
+ version: 1.0.0
5
+ platform: ruby
6
+ authors:
7
+ - Samy KACIMI
8
+ autorequire:
9
+ bindir: exe
10
+ cert_chain: []
11
+ date: 2015-09-25 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: omniauth-oauth2
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - "~>"
18
+ - !ruby/object:Gem::Version
19
+ version: '1.2'
20
+ type: :runtime
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - "~>"
25
+ - !ruby/object:Gem::Version
26
+ version: '1.2'
27
+ - !ruby/object:Gem::Dependency
28
+ name: multi_json
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - "~>"
32
+ - !ruby/object:Gem::Version
33
+ version: '1.3'
34
+ type: :runtime
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - "~>"
39
+ - !ruby/object:Gem::Version
40
+ version: '1.3'
41
+ - !ruby/object:Gem::Dependency
42
+ name: bundler
43
+ requirement: !ruby/object:Gem::Requirement
44
+ requirements:
45
+ - - "~>"
46
+ - !ruby/object:Gem::Version
47
+ version: '1.10'
48
+ type: :development
49
+ prerelease: false
50
+ version_requirements: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - "~>"
53
+ - !ruby/object:Gem::Version
54
+ version: '1.10'
55
+ description: This gem is an OmniAuth OAuth2 strategy for 42 School. 42 Students can
56
+ use it to signup/login on their apps.
57
+ email:
58
+ - samy.kacimi@gmail.com
59
+ executables: []
60
+ extensions: []
61
+ extra_rdoc_files: []
62
+ files:
63
+ - ".gitignore"
64
+ - ".rspec"
65
+ - ".travis.yml"
66
+ - Gemfile
67
+ - LICENSE.txt
68
+ - README.md
69
+ - Rakefile
70
+ - bin/console
71
+ - bin/setup
72
+ - lib/omniauth-marvin.rb
73
+ - lib/omniauth/marvin.rb
74
+ - lib/omniauth/marvin/version.rb
75
+ - lib/omniauth/strategies/marvin.rb
76
+ - omniauth-marvin.gemspec
77
+ homepage: https://github.com/fakenine/omniauth-marvin
78
+ licenses:
79
+ - MIT
80
+ metadata:
81
+ allowed_push_host: https://rubygems.org
82
+ post_install_message:
83
+ rdoc_options: []
84
+ require_paths:
85
+ - lib
86
+ required_ruby_version: !ruby/object:Gem::Requirement
87
+ requirements:
88
+ - - ">="
89
+ - !ruby/object:Gem::Version
90
+ version: '0'
91
+ required_rubygems_version: !ruby/object:Gem::Requirement
92
+ requirements:
93
+ - - ">="
94
+ - !ruby/object:Gem::Version
95
+ version: '0'
96
+ requirements: []
97
+ rubyforge_project:
98
+ rubygems_version: 2.4.8
99
+ signing_key:
100
+ specification_version: 4
101
+ summary: OmniAuth OAuth2 strategy for 42 School
102
+ test_files: []