gds-sso 0.5.4 → 0.6.0
Sign up to get free protection for your applications and to get access to all the features.
- data/Gemfile +1 -0
- data/lib/gds-sso.rb +8 -2
- data/lib/gds-sso/user.rb +1 -1
- data/lib/gds-sso/version.rb +1 -1
- data/lib/gds-sso/warden_config.rb +0 -1
- data/spec/fixtures/integration/signonotron2.sql +1 -1
- data/spec/internal/log/test.log +336 -0
- data/spec/requests/authentication_soot2.rb +2 -2
- data/test/user_test.rb +3 -3
- metadata +28 -55
- data/lib/gds-sso/omniauth_strategy.rb +0 -54
- data/test/gds_sso_strategy_test.rb +0 -19
- data/test/omniauth_strategy_test.rb +0 -35
data/Gemfile
CHANGED
data/lib/gds-sso.rb
CHANGED
@@ -1,8 +1,8 @@
|
|
1
1
|
require 'rails'
|
2
2
|
|
3
3
|
require 'gds-sso/config'
|
4
|
-
require 'gds-sso/omniauth_strategy'
|
5
4
|
require 'gds-sso/warden_config'
|
5
|
+
require 'omniauth-gds'
|
6
6
|
|
7
7
|
module GDS
|
8
8
|
module SSO
|
@@ -24,7 +24,13 @@ module GDS
|
|
24
24
|
config.before_eager_load { |app| app.reload_routes! }
|
25
25
|
|
26
26
|
config.app_middleware.use ::OmniAuth::Builder do
|
27
|
-
provider :gds, GDS::SSO::Config.oauth_id, GDS::SSO::Config.oauth_secret
|
27
|
+
provider :gds, GDS::SSO::Config.oauth_id, GDS::SSO::Config.oauth_secret,
|
28
|
+
client_options: {
|
29
|
+
site: GDS::SSO::Config.oauth_root_url,
|
30
|
+
authorize_url: "#{GDS::SSO::Config.oauth_root_url}/oauth/authorize",
|
31
|
+
token_url: "#{GDS::SSO::Config.oauth_root_url}/oauth/access_token",
|
32
|
+
ssl: { verify: false }
|
33
|
+
}
|
28
34
|
end
|
29
35
|
|
30
36
|
def self.use_mock_strategies?
|
data/lib/gds-sso/user.rb
CHANGED
@@ -14,7 +14,7 @@ module GDS
|
|
14
14
|
|
15
15
|
module User
|
16
16
|
def self.user_params_from_auth_hash(auth_hash)
|
17
|
-
{'uid' => auth_hash['uid'], 'email' => auth_hash['
|
17
|
+
{'uid' => auth_hash['uid'], 'email' => auth_hash['info']['email'], 'name' => auth_hash['info']['name']}
|
18
18
|
end
|
19
19
|
|
20
20
|
extend ActiveSupport::Concern
|
data/lib/gds-sso/version.rb
CHANGED
@@ -6,4 +6,4 @@ DELETE FROM `users`;
|
|
6
6
|
|
7
7
|
-- Setup fixture data
|
8
8
|
INSERT INTO `oauth_applications` VALUES (1,'GDS_SSO integration test','gds-sso-test','secret','http://www.example-client.com/auth/gds/callback','2012-04-19 13:26:54','2012-04-19 13:26:54');
|
9
|
-
INSERT INTO `users` VALUES (1,'test@example-client.com','$2a$04$MdMkVFwTq5GLJJkHS8GLIe6dK1.C4ozzba5ZS5Ks2b/NenVsMGGRW',
|
9
|
+
INSERT INTO `users` (id, email, encrypted_password, created_at, updated_at, name, uid, is_admin) VALUES (1,'test@example-client.com','$2a$04$MdMkVFwTq5GLJJkHS8GLIe6dK1.C4ozzba5ZS5Ks2b/NenVsMGGRW','2012-04-19 13:26:54','2012-04-19 13:26:54','Test User','integration-uid', 0);
|
data/spec/internal/log/test.log
CHANGED
@@ -1389,3 +1389,339 @@ Started GET "/restricted" for 127.0.0.1 at 2012-05-11 15:59:02 +0000
|
|
1389
1389
|
Processing by ExampleController#restricted as JSON
|
1390
1390
|
Authenticating with gds_sso_api_access strategy
|
1391
1391
|
Completed 200 OK in 1ms (Views: 0.5ms)
|
1392
|
+
|
1393
|
+
|
1394
|
+
Started GET "/" for 127.0.0.1 at 2012-06-11 16:13:57 +0000
|
1395
|
+
Processing by ExampleController#index as HTML
|
1396
|
+
Rendered text template (0.0ms)
|
1397
|
+
Completed 200 OK in 48ms (Views: 47.5ms)
|
1398
|
+
|
1399
|
+
|
1400
|
+
Started GET "/restricted" for 127.0.0.1 at 2012-06-11 16:13:58 +0000
|
1401
|
+
Processing by ExampleController#restricted as HTML
|
1402
|
+
Authenticating with gds_sso strategy
|
1403
|
+
Completed in 1ms
|
1404
|
+
|
1405
|
+
|
1406
|
+
Started GET "/auth/gds" for 127.0.0.1 at 2012-06-11 16:13:58 +0000
|
1407
|
+
|
1408
|
+
|
1409
|
+
Started GET "/auth/gds/callback?code=p73LMkRgOXEF8ErideRXIEK6EnHPPkoCFopUg65tMpng51lb" for 127.0.0.1 at 2012-06-11 16:13:59 +0000
|
1410
|
+
Processing by AuthenticationsController#callback as HTML
|
1411
|
+
Parameters: {"code"=>"p73LMkRgOXEF8ErideRXIEK6EnHPPkoCFopUg65tMpng51lb"}
|
1412
|
+
Authenticating with gds_sso strategy
|
1413
|
+
Redirected to http://www.example-client.com/restricted
|
1414
|
+
Completed 302 Found in 1ms
|
1415
|
+
|
1416
|
+
|
1417
|
+
Started GET "/restricted" for 127.0.0.1 at 2012-06-11 16:13:59 +0000
|
1418
|
+
Processing by ExampleController#restricted as HTML
|
1419
|
+
Completed 200 OK in 1ms (Views: 0.5ms)
|
1420
|
+
|
1421
|
+
|
1422
|
+
Started GET "/restricted" for 127.0.0.1 at 2012-06-11 16:13:59 +0000
|
1423
|
+
Processing by ExampleController#restricted as HTML
|
1424
|
+
Authenticating with gds_sso strategy
|
1425
|
+
Completed in 0ms
|
1426
|
+
|
1427
|
+
|
1428
|
+
Started GET "/auth/gds" for 127.0.0.1 at 2012-06-11 16:13:59 +0000
|
1429
|
+
|
1430
|
+
|
1431
|
+
Started GET "/auth/gds/callback?code=1QYBpw8JIMJ4IxPWKwOnx3g2WVN62Sl89CQsBUYOwopsYuXX" for 127.0.0.1 at 2012-06-11 16:13:59 +0000
|
1432
|
+
Processing by AuthenticationsController#callback as HTML
|
1433
|
+
Parameters: {"code"=>"1QYBpw8JIMJ4IxPWKwOnx3g2WVN62Sl89CQsBUYOwopsYuXX"}
|
1434
|
+
Authenticating with gds_sso strategy
|
1435
|
+
Redirected to http://www.example-client.com/restricted
|
1436
|
+
Completed 302 Found in 1ms
|
1437
|
+
|
1438
|
+
|
1439
|
+
Started GET "/restricted" for 127.0.0.1 at 2012-06-11 16:13:59 +0000
|
1440
|
+
Processing by ExampleController#restricted as HTML
|
1441
|
+
Completed 200 OK in 1ms (Views: 0.6ms)
|
1442
|
+
|
1443
|
+
|
1444
|
+
Started GET "/restricted" for 127.0.0.1 at 2012-06-11 16:13:59 +0000
|
1445
|
+
Processing by ExampleController#restricted as HTML
|
1446
|
+
Authenticating with gds_sso strategy
|
1447
|
+
Completed in 0ms
|
1448
|
+
|
1449
|
+
|
1450
|
+
Started GET "/auth/gds" for 127.0.0.1 at 2012-06-11 16:13:59 +0000
|
1451
|
+
|
1452
|
+
|
1453
|
+
Started GET "/auth/gds/callback?code=VPCSnPRSAac6iZp9Wbrpae83Gw15fjc0N0u08MFBToGSTtCv" for 127.0.0.1 at 2012-06-11 16:13:59 +0000
|
1454
|
+
Processing by AuthenticationsController#callback as HTML
|
1455
|
+
Parameters: {"code"=>"VPCSnPRSAac6iZp9Wbrpae83Gw15fjc0N0u08MFBToGSTtCv"}
|
1456
|
+
Authenticating with gds_sso strategy
|
1457
|
+
Redirected to http://www.example-client.com/restricted
|
1458
|
+
Completed 302 Found in 1ms
|
1459
|
+
|
1460
|
+
|
1461
|
+
Started GET "/restricted" for 127.0.0.1 at 2012-06-11 16:13:59 +0000
|
1462
|
+
Processing by ExampleController#restricted as HTML
|
1463
|
+
Completed 200 OK in 1ms (Views: 0.4ms)
|
1464
|
+
|
1465
|
+
|
1466
|
+
Started GET "/restricted" for 127.0.0.1 at 2012-06-11 16:13:59 +0000
|
1467
|
+
Processing by ExampleController#restricted as JSON
|
1468
|
+
Authenticating with gds_sso_api_access strategy
|
1469
|
+
Completed in 69ms
|
1470
|
+
|
1471
|
+
|
1472
|
+
Started GET "/restricted" for 127.0.0.1 at 2012-06-11 16:13:59 +0000
|
1473
|
+
Processing by ExampleController#restricted as JSON
|
1474
|
+
Authenticating with gds_sso_api_access strategy
|
1475
|
+
Completed 200 OK in 1ms (Views: 0.5ms)
|
1476
|
+
|
1477
|
+
|
1478
|
+
Started GET "/" for 127.0.0.1 at 2012-06-11 16:14:34 +0000
|
1479
|
+
Processing by ExampleController#index as HTML
|
1480
|
+
Rendered text template (0.0ms)
|
1481
|
+
Completed 200 OK in 48ms (Views: 47.8ms)
|
1482
|
+
|
1483
|
+
|
1484
|
+
Started GET "/restricted" for 127.0.0.1 at 2012-06-11 16:14:35 +0000
|
1485
|
+
Processing by ExampleController#restricted as HTML
|
1486
|
+
Authenticating with gds_sso strategy
|
1487
|
+
Completed in 1ms
|
1488
|
+
|
1489
|
+
|
1490
|
+
Started GET "/auth/gds" for 127.0.0.1 at 2012-06-11 16:14:35 +0000
|
1491
|
+
|
1492
|
+
|
1493
|
+
Started GET "/auth/gds/callback?code=7e49b29c459a8f21d98adeb9d257a4d87928bf1fab1da079ee6b15355f9f6a1d" for 127.0.0.1 at 2012-06-11 16:14:36 +0000
|
1494
|
+
Processing by AuthenticationsController#callback as HTML
|
1495
|
+
Parameters: {"code"=>"7e49b29c459a8f21d98adeb9d257a4d87928bf1fab1da079ee6b15355f9f6a1d"}
|
1496
|
+
Authenticating with gds_sso strategy
|
1497
|
+
Redirected to http://www.example-client.com/restricted
|
1498
|
+
Completed 302 Found in 1ms
|
1499
|
+
|
1500
|
+
|
1501
|
+
Started GET "/restricted" for 127.0.0.1 at 2012-06-11 16:14:36 +0000
|
1502
|
+
Processing by ExampleController#restricted as HTML
|
1503
|
+
Completed 200 OK in 1ms (Views: 0.5ms)
|
1504
|
+
|
1505
|
+
|
1506
|
+
Started GET "/restricted" for 127.0.0.1 at 2012-06-11 16:14:36 +0000
|
1507
|
+
Processing by ExampleController#restricted as HTML
|
1508
|
+
Authenticating with gds_sso strategy
|
1509
|
+
Completed in 0ms
|
1510
|
+
|
1511
|
+
|
1512
|
+
Started GET "/auth/gds" for 127.0.0.1 at 2012-06-11 16:14:36 +0000
|
1513
|
+
|
1514
|
+
|
1515
|
+
Started GET "/auth/gds/callback?code=a379d659afad615d0c8f53618942cf7ec5745c9807dd56f74bf8299720f33017" for 127.0.0.1 at 2012-06-11 16:14:36 +0000
|
1516
|
+
Processing by AuthenticationsController#callback as HTML
|
1517
|
+
Parameters: {"code"=>"a379d659afad615d0c8f53618942cf7ec5745c9807dd56f74bf8299720f33017"}
|
1518
|
+
Authenticating with gds_sso strategy
|
1519
|
+
Redirected to http://www.example-client.com/restricted
|
1520
|
+
Completed 302 Found in 1ms
|
1521
|
+
|
1522
|
+
|
1523
|
+
Started GET "/restricted" for 127.0.0.1 at 2012-06-11 16:14:36 +0000
|
1524
|
+
Processing by ExampleController#restricted as HTML
|
1525
|
+
Completed 200 OK in 1ms (Views: 0.6ms)
|
1526
|
+
|
1527
|
+
|
1528
|
+
Started GET "/restricted" for 127.0.0.1 at 2012-06-11 16:14:36 +0000
|
1529
|
+
Processing by ExampleController#restricted as HTML
|
1530
|
+
Authenticating with gds_sso strategy
|
1531
|
+
Completed in 0ms
|
1532
|
+
|
1533
|
+
|
1534
|
+
Started GET "/auth/gds" for 127.0.0.1 at 2012-06-11 16:14:36 +0000
|
1535
|
+
|
1536
|
+
|
1537
|
+
Started GET "/auth/gds/callback?code=0c262328cc615d4c88e4e2435e9ee63a5502f4baa8f80438a07ecf1ed57c1eed" for 127.0.0.1 at 2012-06-11 16:14:36 +0000
|
1538
|
+
Processing by AuthenticationsController#callback as HTML
|
1539
|
+
Parameters: {"code"=>"0c262328cc615d4c88e4e2435e9ee63a5502f4baa8f80438a07ecf1ed57c1eed"}
|
1540
|
+
Authenticating with gds_sso strategy
|
1541
|
+
Redirected to http://www.example-client.com/restricted
|
1542
|
+
Completed 302 Found in 1ms
|
1543
|
+
|
1544
|
+
|
1545
|
+
Started GET "/restricted" for 127.0.0.1 at 2012-06-11 16:14:36 +0000
|
1546
|
+
Processing by ExampleController#restricted as HTML
|
1547
|
+
Completed 200 OK in 1ms (Views: 0.3ms)
|
1548
|
+
|
1549
|
+
|
1550
|
+
Started GET "/restricted" for 127.0.0.1 at 2012-06-11 16:14:36 +0000
|
1551
|
+
Processing by ExampleController#restricted as JSON
|
1552
|
+
Authenticating with gds_sso_api_access strategy
|
1553
|
+
Completed in 57ms
|
1554
|
+
|
1555
|
+
|
1556
|
+
Started GET "/restricted" for 127.0.0.1 at 2012-06-11 16:14:36 +0000
|
1557
|
+
Processing by ExampleController#restricted as JSON
|
1558
|
+
Authenticating with gds_sso_api_access strategy
|
1559
|
+
Completed 200 OK in 1ms (Views: 0.5ms)
|
1560
|
+
|
1561
|
+
|
1562
|
+
Started GET "/" for 127.0.0.1 at 2012-06-12 15:18:24 +0000
|
1563
|
+
Processing by ExampleController#index as HTML
|
1564
|
+
Rendered text template (0.0ms)
|
1565
|
+
Completed 200 OK in 48ms (Views: 47.8ms)
|
1566
|
+
|
1567
|
+
|
1568
|
+
Started GET "/restricted" for 127.0.0.1 at 2012-06-12 15:18:25 +0000
|
1569
|
+
Processing by ExampleController#restricted as HTML
|
1570
|
+
Authenticating with gds_sso strategy
|
1571
|
+
Completed in 89ms
|
1572
|
+
|
1573
|
+
|
1574
|
+
Started GET "/auth/gds" for 127.0.0.1 at 2012-06-12 15:18:25 +0000
|
1575
|
+
|
1576
|
+
|
1577
|
+
Started GET "/auth/gds/callback?code=I9YRVyM5xAFBIWdzgJXzFdp0m393iBveFAfEqAlXrsYwl1Bd" for 127.0.0.1 at 2012-06-12 15:18:26 +0000
|
1578
|
+
Processing by AuthenticationsController#callback as HTML
|
1579
|
+
Parameters: {"code"=>"I9YRVyM5xAFBIWdzgJXzFdp0m393iBveFAfEqAlXrsYwl1Bd"}
|
1580
|
+
Authenticating with gds_sso strategy
|
1581
|
+
Redirected to http://www.example-client.com/restricted
|
1582
|
+
Completed 302 Found in 1ms
|
1583
|
+
|
1584
|
+
|
1585
|
+
Started GET "/restricted" for 127.0.0.1 at 2012-06-12 15:18:26 +0000
|
1586
|
+
Processing by ExampleController#restricted as HTML
|
1587
|
+
Completed 200 OK in 1ms (Views: 0.5ms)
|
1588
|
+
|
1589
|
+
|
1590
|
+
Started GET "/restricted" for 127.0.0.1 at 2012-06-12 15:18:26 +0000
|
1591
|
+
Processing by ExampleController#restricted as HTML
|
1592
|
+
Authenticating with gds_sso strategy
|
1593
|
+
Completed in 0ms
|
1594
|
+
|
1595
|
+
|
1596
|
+
Started GET "/auth/gds" for 127.0.0.1 at 2012-06-12 15:18:26 +0000
|
1597
|
+
|
1598
|
+
|
1599
|
+
Started GET "/auth/gds/callback?code=hrttBREqJ5jCLBLwSiBEDmCKakeyZsHtbxpCDzcfC2Lk6FpI" for 127.0.0.1 at 2012-06-12 15:18:26 +0000
|
1600
|
+
Processing by AuthenticationsController#callback as HTML
|
1601
|
+
Parameters: {"code"=>"hrttBREqJ5jCLBLwSiBEDmCKakeyZsHtbxpCDzcfC2Lk6FpI"}
|
1602
|
+
Authenticating with gds_sso strategy
|
1603
|
+
Redirected to http://www.example-client.com/restricted
|
1604
|
+
Completed 302 Found in 1ms
|
1605
|
+
|
1606
|
+
|
1607
|
+
Started GET "/restricted" for 127.0.0.1 at 2012-06-12 15:18:26 +0000
|
1608
|
+
Processing by ExampleController#restricted as HTML
|
1609
|
+
Completed 200 OK in 1ms (Views: 0.5ms)
|
1610
|
+
|
1611
|
+
|
1612
|
+
Started GET "/restricted" for 127.0.0.1 at 2012-06-12 15:18:26 +0000
|
1613
|
+
Processing by ExampleController#restricted as HTML
|
1614
|
+
Authenticating with gds_sso strategy
|
1615
|
+
Completed in 0ms
|
1616
|
+
|
1617
|
+
|
1618
|
+
Started GET "/auth/gds" for 127.0.0.1 at 2012-06-12 15:18:26 +0000
|
1619
|
+
|
1620
|
+
|
1621
|
+
Started GET "/auth/gds/callback?code=mc9tvDPRt34yjVFlxzpW1YeypbgXVYHwDDBHub84G2ZjNCBh" for 127.0.0.1 at 2012-06-12 15:18:26 +0000
|
1622
|
+
Processing by AuthenticationsController#callback as HTML
|
1623
|
+
Parameters: {"code"=>"mc9tvDPRt34yjVFlxzpW1YeypbgXVYHwDDBHub84G2ZjNCBh"}
|
1624
|
+
Authenticating with gds_sso strategy
|
1625
|
+
Redirected to http://www.example-client.com/restricted
|
1626
|
+
Completed 302 Found in 1ms
|
1627
|
+
|
1628
|
+
|
1629
|
+
Started GET "/restricted" for 127.0.0.1 at 2012-06-12 15:18:26 +0000
|
1630
|
+
Processing by ExampleController#restricted as HTML
|
1631
|
+
Completed 200 OK in 1ms (Views: 0.5ms)
|
1632
|
+
|
1633
|
+
|
1634
|
+
Started GET "/restricted" for 127.0.0.1 at 2012-06-12 15:18:26 +0000
|
1635
|
+
Processing by ExampleController#restricted as JSON
|
1636
|
+
Authenticating with gds_sso_api_access strategy
|
1637
|
+
Completed in 14ms
|
1638
|
+
|
1639
|
+
|
1640
|
+
Started GET "/restricted" for 127.0.0.1 at 2012-06-12 15:18:27 +0000
|
1641
|
+
Processing by ExampleController#restricted as JSON
|
1642
|
+
Authenticating with gds_sso_api_access strategy
|
1643
|
+
Completed 200 OK in 1ms (Views: 0.6ms)
|
1644
|
+
|
1645
|
+
|
1646
|
+
Started GET "/" for 127.0.0.1 at 2012-06-12 15:18:56 +0000
|
1647
|
+
Processing by ExampleController#index as HTML
|
1648
|
+
Rendered text template (0.0ms)
|
1649
|
+
Completed 200 OK in 49ms (Views: 48.2ms)
|
1650
|
+
|
1651
|
+
|
1652
|
+
Started GET "/restricted" for 127.0.0.1 at 2012-06-12 15:18:57 +0000
|
1653
|
+
Processing by ExampleController#restricted as HTML
|
1654
|
+
Authenticating with gds_sso strategy
|
1655
|
+
Completed in 56ms
|
1656
|
+
|
1657
|
+
|
1658
|
+
Started GET "/auth/gds" for 127.0.0.1 at 2012-06-12 15:18:57 +0000
|
1659
|
+
|
1660
|
+
|
1661
|
+
Started GET "/auth/gds/callback?code=69abba163874fae835038e580701ba8f309d1b701c275e715f3b83c0046dcd26" for 127.0.0.1 at 2012-06-12 15:18:57 +0000
|
1662
|
+
Processing by AuthenticationsController#callback as HTML
|
1663
|
+
Parameters: {"code"=>"69abba163874fae835038e580701ba8f309d1b701c275e715f3b83c0046dcd26"}
|
1664
|
+
Authenticating with gds_sso strategy
|
1665
|
+
Redirected to http://www.example-client.com/restricted
|
1666
|
+
Completed 302 Found in 1ms
|
1667
|
+
|
1668
|
+
|
1669
|
+
Started GET "/restricted" for 127.0.0.1 at 2012-06-12 15:18:58 +0000
|
1670
|
+
Processing by ExampleController#restricted as HTML
|
1671
|
+
Completed 200 OK in 1ms (Views: 0.5ms)
|
1672
|
+
|
1673
|
+
|
1674
|
+
Started GET "/restricted" for 127.0.0.1 at 2012-06-12 15:18:58 +0000
|
1675
|
+
Processing by ExampleController#restricted as HTML
|
1676
|
+
Authenticating with gds_sso strategy
|
1677
|
+
Completed in 0ms
|
1678
|
+
|
1679
|
+
|
1680
|
+
Started GET "/auth/gds" for 127.0.0.1 at 2012-06-12 15:18:58 +0000
|
1681
|
+
|
1682
|
+
|
1683
|
+
Started GET "/auth/gds/callback?code=cce3e9f06747fcfc99186a68f9dbf912524d7a187e75de000f7f69a03658ace2" for 127.0.0.1 at 2012-06-12 15:18:58 +0000
|
1684
|
+
Processing by AuthenticationsController#callback as HTML
|
1685
|
+
Parameters: {"code"=>"cce3e9f06747fcfc99186a68f9dbf912524d7a187e75de000f7f69a03658ace2"}
|
1686
|
+
Authenticating with gds_sso strategy
|
1687
|
+
Redirected to http://www.example-client.com/restricted
|
1688
|
+
Completed 302 Found in 1ms
|
1689
|
+
|
1690
|
+
|
1691
|
+
Started GET "/restricted" for 127.0.0.1 at 2012-06-12 15:18:58 +0000
|
1692
|
+
Processing by ExampleController#restricted as HTML
|
1693
|
+
Completed 200 OK in 1ms (Views: 0.5ms)
|
1694
|
+
|
1695
|
+
|
1696
|
+
Started GET "/restricted" for 127.0.0.1 at 2012-06-12 15:18:58 +0000
|
1697
|
+
Processing by ExampleController#restricted as HTML
|
1698
|
+
Authenticating with gds_sso strategy
|
1699
|
+
Completed in 0ms
|
1700
|
+
|
1701
|
+
|
1702
|
+
Started GET "/auth/gds" for 127.0.0.1 at 2012-06-12 15:18:58 +0000
|
1703
|
+
|
1704
|
+
|
1705
|
+
Started GET "/auth/gds/callback?code=a60940acfd9e76e7cedc9d07cf00ddf37fc47b1b38e9f8bc15939cebc09b4a1e" for 127.0.0.1 at 2012-06-12 15:18:58 +0000
|
1706
|
+
Processing by AuthenticationsController#callback as HTML
|
1707
|
+
Parameters: {"code"=>"a60940acfd9e76e7cedc9d07cf00ddf37fc47b1b38e9f8bc15939cebc09b4a1e"}
|
1708
|
+
Authenticating with gds_sso strategy
|
1709
|
+
Redirected to http://www.example-client.com/restricted
|
1710
|
+
Completed 302 Found in 1ms
|
1711
|
+
|
1712
|
+
|
1713
|
+
Started GET "/restricted" for 127.0.0.1 at 2012-06-12 15:18:58 +0000
|
1714
|
+
Processing by ExampleController#restricted as HTML
|
1715
|
+
Completed 200 OK in 1ms (Views: 0.3ms)
|
1716
|
+
|
1717
|
+
|
1718
|
+
Started GET "/restricted" for 127.0.0.1 at 2012-06-12 15:18:58 +0000
|
1719
|
+
Processing by ExampleController#restricted as JSON
|
1720
|
+
Authenticating with gds_sso_api_access strategy
|
1721
|
+
Completed in 12ms
|
1722
|
+
|
1723
|
+
|
1724
|
+
Started GET "/restricted" for 127.0.0.1 at 2012-06-12 15:18:58 +0000
|
1725
|
+
Processing by ExampleController#restricted as JSON
|
1726
|
+
Authenticating with gds_sso_api_access strategy
|
1727
|
+
Completed 200 OK in 1ms (Views: 0.6ms)
|
@@ -8,7 +8,7 @@ describe "authenticating with sign-on-o-tron" do
|
|
8
8
|
|
9
9
|
describe "a protected page" do
|
10
10
|
it "redirects to /auth/gds" do
|
11
|
-
get "/"
|
11
|
+
get "/restricted"
|
12
12
|
|
13
13
|
response.code.should == "302"
|
14
14
|
response.location.should == "http://www.example.com/auth/gds"
|
@@ -20,7 +20,7 @@ describe "authenticating with sign-on-o-tron" do
|
|
20
20
|
get "/auth/gds"
|
21
21
|
|
22
22
|
response.code.should == "302"
|
23
|
-
response.location.should =~ /^http:\/\/localhost:
|
23
|
+
response.location.should =~ /^http:\/\/localhost:4567\/oauth\/authorize/
|
24
24
|
end
|
25
25
|
|
26
26
|
it "authenticates with a username and password and redirects back to the app" do
|
data/test/user_test.rb
CHANGED
@@ -7,13 +7,13 @@ class TestUser < Test::Unit::TestCase
|
|
7
7
|
'provider' => 'gds',
|
8
8
|
'uid' => 'abcde',
|
9
9
|
'credentials' => {'token' => 'abcdefg', 'secret' => 'abcdefg'},
|
10
|
-
'
|
11
|
-
'extra' => {'
|
10
|
+
'info' => {'name' => 'Matt Patterson', 'email' => 'matt@alphagov.co.uk'},
|
11
|
+
'extra' => {'user' => {'uid' => 'abcde', 'name' => 'Matt Patterson', 'email' => 'matt@alphagov.co.uk'}}
|
12
12
|
}
|
13
13
|
end
|
14
14
|
|
15
15
|
def test_user_params_creation
|
16
|
-
expected = {'uid' => 'abcde', '
|
16
|
+
expected = {'uid' => 'abcde', 'name' => 'Matt Patterson', 'email' => 'matt@alphagov.co.uk'}
|
17
17
|
assert_equal expected, GDS::SSO::User.user_params_from_auth_hash(@auth_hash)
|
18
18
|
end
|
19
19
|
end
|
metadata
CHANGED
@@ -2,7 +2,7 @@
|
|
2
2
|
name: gds-sso
|
3
3
|
version: !ruby/object:Gem::Version
|
4
4
|
prerelease:
|
5
|
-
version: 0.
|
5
|
+
version: 0.6.0
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
8
8
|
- Matt Patterson
|
@@ -11,7 +11,7 @@ autorequire:
|
|
11
11
|
bindir: bin
|
12
12
|
cert_chain: []
|
13
13
|
|
14
|
-
date: 2012-
|
14
|
+
date: 2012-06-12 00:00:00 Z
|
15
15
|
dependencies:
|
16
16
|
- !ruby/object:Gem::Dependency
|
17
17
|
name: rails
|
@@ -29,48 +29,26 @@ dependencies:
|
|
29
29
|
requirement: &id002 !ruby/object:Gem::Requirement
|
30
30
|
none: false
|
31
31
|
requirements:
|
32
|
-
- -
|
32
|
+
- - ~>
|
33
33
|
- !ruby/object:Gem::Version
|
34
|
-
version: 1.
|
34
|
+
version: "1.2"
|
35
35
|
type: :runtime
|
36
36
|
prerelease: false
|
37
37
|
version_requirements: *id002
|
38
38
|
- !ruby/object:Gem::Dependency
|
39
|
-
name:
|
39
|
+
name: omniauth-gds
|
40
40
|
requirement: &id003 !ruby/object:Gem::Requirement
|
41
41
|
none: false
|
42
42
|
requirements:
|
43
43
|
- - "="
|
44
44
|
- !ruby/object:Gem::Version
|
45
|
-
version: 0.
|
45
|
+
version: 0.0.2
|
46
46
|
type: :runtime
|
47
47
|
prerelease: false
|
48
48
|
version_requirements: *id003
|
49
|
-
- !ruby/object:Gem::Dependency
|
50
|
-
name: oa-oauth
|
51
|
-
requirement: &id004 !ruby/object:Gem::Requirement
|
52
|
-
none: false
|
53
|
-
requirements:
|
54
|
-
- - ~>
|
55
|
-
- !ruby/object:Gem::Version
|
56
|
-
version: 0.3.2
|
57
|
-
type: :runtime
|
58
|
-
prerelease: false
|
59
|
-
version_requirements: *id004
|
60
|
-
- !ruby/object:Gem::Dependency
|
61
|
-
name: oa-core
|
62
|
-
requirement: &id005 !ruby/object:Gem::Requirement
|
63
|
-
none: false
|
64
|
-
requirements:
|
65
|
-
- - ~>
|
66
|
-
- !ruby/object:Gem::Version
|
67
|
-
version: 0.3.2
|
68
|
-
type: :runtime
|
69
|
-
prerelease: false
|
70
|
-
version_requirements: *id005
|
71
49
|
- !ruby/object:Gem::Dependency
|
72
50
|
name: rack-accept
|
73
|
-
requirement: &
|
51
|
+
requirement: &id004 !ruby/object:Gem::Requirement
|
74
52
|
none: false
|
75
53
|
requirements:
|
76
54
|
- - ~>
|
@@ -78,10 +56,10 @@ dependencies:
|
|
78
56
|
version: 0.4.4
|
79
57
|
type: :runtime
|
80
58
|
prerelease: false
|
81
|
-
version_requirements: *
|
59
|
+
version_requirements: *id004
|
82
60
|
- !ruby/object:Gem::Dependency
|
83
61
|
name: rack
|
84
|
-
requirement: &
|
62
|
+
requirement: &id005 !ruby/object:Gem::Requirement
|
85
63
|
none: false
|
86
64
|
requirements:
|
87
65
|
- - "="
|
@@ -89,10 +67,10 @@ dependencies:
|
|
89
67
|
version: 1.3.5
|
90
68
|
type: :runtime
|
91
69
|
prerelease: false
|
92
|
-
version_requirements: *
|
70
|
+
version_requirements: *id005
|
93
71
|
- !ruby/object:Gem::Dependency
|
94
72
|
name: rake
|
95
|
-
requirement: &
|
73
|
+
requirement: &id006 !ruby/object:Gem::Requirement
|
96
74
|
none: false
|
97
75
|
requirements:
|
98
76
|
- - ~>
|
@@ -100,10 +78,10 @@ dependencies:
|
|
100
78
|
version: 0.9.2
|
101
79
|
type: :development
|
102
80
|
prerelease: false
|
103
|
-
version_requirements: *
|
81
|
+
version_requirements: *id006
|
104
82
|
- !ruby/object:Gem::Dependency
|
105
83
|
name: mocha
|
106
|
-
requirement: &
|
84
|
+
requirement: &id007 !ruby/object:Gem::Requirement
|
107
85
|
none: false
|
108
86
|
requirements:
|
109
87
|
- - ~>
|
@@ -111,10 +89,10 @@ dependencies:
|
|
111
89
|
version: 0.9.0
|
112
90
|
type: :development
|
113
91
|
prerelease: false
|
114
|
-
version_requirements: *
|
92
|
+
version_requirements: *id007
|
115
93
|
- !ruby/object:Gem::Dependency
|
116
94
|
name: capybara
|
117
|
-
requirement: &
|
95
|
+
requirement: &id008 !ruby/object:Gem::Requirement
|
118
96
|
none: false
|
119
97
|
requirements:
|
120
98
|
- - ~>
|
@@ -122,10 +100,10 @@ dependencies:
|
|
122
100
|
version: 1.1.2
|
123
101
|
type: :development
|
124
102
|
prerelease: false
|
125
|
-
version_requirements: *
|
103
|
+
version_requirements: *id008
|
126
104
|
- !ruby/object:Gem::Dependency
|
127
105
|
name: rspec-rails
|
128
|
-
requirement: &
|
106
|
+
requirement: &id009 !ruby/object:Gem::Requirement
|
129
107
|
none: false
|
130
108
|
requirements:
|
131
109
|
- - ~>
|
@@ -133,10 +111,10 @@ dependencies:
|
|
133
111
|
version: 2.9.0
|
134
112
|
type: :development
|
135
113
|
prerelease: false
|
136
|
-
version_requirements: *
|
114
|
+
version_requirements: *id009
|
137
115
|
- !ruby/object:Gem::Dependency
|
138
116
|
name: capybara-mechanize
|
139
|
-
requirement: &
|
117
|
+
requirement: &id010 !ruby/object:Gem::Requirement
|
140
118
|
none: false
|
141
119
|
requirements:
|
142
120
|
- - ~>
|
@@ -144,10 +122,10 @@ dependencies:
|
|
144
122
|
version: 0.3.0
|
145
123
|
type: :development
|
146
124
|
prerelease: false
|
147
|
-
version_requirements: *
|
125
|
+
version_requirements: *id010
|
148
126
|
- !ruby/object:Gem::Dependency
|
149
127
|
name: combustion
|
150
|
-
requirement: &
|
128
|
+
requirement: &id011 !ruby/object:Gem::Requirement
|
151
129
|
none: false
|
152
130
|
requirements:
|
153
131
|
- - ~>
|
@@ -155,10 +133,10 @@ dependencies:
|
|
155
133
|
version: 0.3.2
|
156
134
|
type: :development
|
157
135
|
prerelease: false
|
158
|
-
version_requirements: *
|
136
|
+
version_requirements: *id011
|
159
137
|
- !ruby/object:Gem::Dependency
|
160
138
|
name: gem_publisher
|
161
|
-
requirement: &
|
139
|
+
requirement: &id012 !ruby/object:Gem::Requirement
|
162
140
|
none: false
|
163
141
|
requirements:
|
164
142
|
- - ~>
|
@@ -166,10 +144,10 @@ dependencies:
|
|
166
144
|
version: 1.0.0
|
167
145
|
type: :development
|
168
146
|
prerelease: false
|
169
|
-
version_requirements: *
|
147
|
+
version_requirements: *id012
|
170
148
|
- !ruby/object:Gem::Dependency
|
171
149
|
name: thor
|
172
|
-
requirement: &
|
150
|
+
requirement: &id013 !ruby/object:Gem::Requirement
|
173
151
|
none: false
|
174
152
|
requirements:
|
175
153
|
- - "="
|
@@ -177,7 +155,7 @@ dependencies:
|
|
177
155
|
version: 0.14.6
|
178
156
|
type: :development
|
179
157
|
prerelease: false
|
180
|
-
version_requirements: *
|
158
|
+
version_requirements: *id013
|
181
159
|
description: Client for GDS' OAuth 2-based SSO
|
182
160
|
email:
|
183
161
|
- matt@constituentparts.com
|
@@ -199,14 +177,11 @@ files:
|
|
199
177
|
- lib/gds-sso/user.rb
|
200
178
|
- lib/gds-sso/warden_config.rb
|
201
179
|
- lib/gds-sso/api_access.rb
|
202
|
-
- lib/gds-sso/omniauth_strategy.rb
|
203
180
|
- lib/gds-sso/version.rb
|
204
181
|
- README.md
|
205
182
|
- Gemfile
|
206
183
|
- Rakefile
|
207
184
|
- test/test_helper.rb
|
208
|
-
- test/omniauth_strategy_test.rb
|
209
|
-
- test/gds_sso_strategy_test.rb
|
210
185
|
- test/user_test.rb
|
211
186
|
- spec/requests/end_to_end_spec.rb
|
212
187
|
- spec/requests/authentication_soot2.rb
|
@@ -239,7 +214,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
239
214
|
requirements:
|
240
215
|
- - ">="
|
241
216
|
- !ruby/object:Gem::Version
|
242
|
-
hash:
|
217
|
+
hash: 2754881002430173909
|
243
218
|
segments:
|
244
219
|
- 0
|
245
220
|
version: "0"
|
@@ -248,7 +223,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
248
223
|
requirements:
|
249
224
|
- - ">="
|
250
225
|
- !ruby/object:Gem::Version
|
251
|
-
hash:
|
226
|
+
hash: 2754881002430173909
|
252
227
|
segments:
|
253
228
|
- 0
|
254
229
|
version: "0"
|
@@ -261,8 +236,6 @@ specification_version: 3
|
|
261
236
|
summary: Client for GDS' OAuth 2-based SSO
|
262
237
|
test_files:
|
263
238
|
- test/test_helper.rb
|
264
|
-
- test/omniauth_strategy_test.rb
|
265
|
-
- test/gds_sso_strategy_test.rb
|
266
239
|
- test/user_test.rb
|
267
240
|
- spec/requests/end_to_end_spec.rb
|
268
241
|
- spec/requests/authentication_soot2.rb
|
@@ -1,54 +0,0 @@
|
|
1
|
-
require 'omniauth/oauth'
|
2
|
-
require 'multi_json'
|
3
|
-
|
4
|
-
# Authenticate to GDS with OAuth 2.0 and retrieve
|
5
|
-
# basic user information.
|
6
|
-
#
|
7
|
-
# @example Basic Usage
|
8
|
-
# use OmniAuth::Builder :gds, 'API Key', 'Secret Key'
|
9
|
-
|
10
|
-
class OmniAuth::Strategies::Gds < OmniAuth::Strategies::OAuth2
|
11
|
-
|
12
|
-
# @param [Rack Application] app standard middleware application parameter
|
13
|
-
# @param [String] api_key the application id as [provided by GDS]
|
14
|
-
# @param [String] secret_key the application secret as [provided by Bitly]
|
15
|
-
def initialize(app, api_key = nil, secret_key = nil, options = {}, &block)
|
16
|
-
client_options = {
|
17
|
-
:site => "#{GDS::SSO::Config.oauth_root_url}/",
|
18
|
-
:authorize_url => "#{GDS::SSO::Config.oauth_root_url}/oauth/authorize",
|
19
|
-
:token_url => "#{GDS::SSO::Config.oauth_root_url}/oauth/access_token",
|
20
|
-
:access_token_url => "#{GDS::SSO::Config.oauth_root_url}/oauth/access_token",
|
21
|
-
:ssl => {
|
22
|
-
:verify => false
|
23
|
-
}
|
24
|
-
}
|
25
|
-
|
26
|
-
super(app, :gds, api_key, secret_key, client_options, options, &block)
|
27
|
-
end
|
28
|
-
|
29
|
-
def call(env)
|
30
|
-
if GDS::SSO::ApiAccess.api_call?(env)
|
31
|
-
@app.call(env)
|
32
|
-
else
|
33
|
-
super
|
34
|
-
end
|
35
|
-
end
|
36
|
-
|
37
|
-
protected
|
38
|
-
|
39
|
-
def fetch_user_data
|
40
|
-
@access_token.get('/user.json').body
|
41
|
-
end
|
42
|
-
|
43
|
-
def user_hash
|
44
|
-
@user_hash ||= MultiJson.decode(fetch_user_data)['user']
|
45
|
-
end
|
46
|
-
|
47
|
-
def build_auth_hash
|
48
|
-
{'uid' => user_hash['uid'], 'user_info' => {'name' => user_hash['name'], 'email' => user_hash['email']}, 'extra' => {'user_hash' => user_hash}}
|
49
|
-
end
|
50
|
-
|
51
|
-
def auth_hash
|
52
|
-
OmniAuth::Utils.deep_merge(super, build_auth_hash)
|
53
|
-
end
|
54
|
-
end
|
@@ -1,19 +0,0 @@
|
|
1
|
-
require 'test_helper'
|
2
|
-
require 'json'
|
3
|
-
require 'gds-sso'
|
4
|
-
require 'gds-sso/omniauth_strategy'
|
5
|
-
require 'capybara/dsl'
|
6
|
-
|
7
|
-
class TestGdsSsoStrategy < Test::Unit::TestCase
|
8
|
-
include OmniAuth::Test::StrategyTestCase
|
9
|
-
include Capybara::DSL
|
10
|
-
|
11
|
-
def strategy
|
12
|
-
# return the parameters to a Rack::Builder map call:
|
13
|
-
[OmniAuth::Strategies::Gds.new, 'client_id', 'client_secret']
|
14
|
-
end
|
15
|
-
|
16
|
-
def setup
|
17
|
-
# post '/auth/gds_sso/callback', :user => { 'name' => 'Dylan', 'id' => '445' }
|
18
|
-
end
|
19
|
-
end
|
@@ -1,35 +0,0 @@
|
|
1
|
-
require 'test_helper'
|
2
|
-
require 'json'
|
3
|
-
require 'gds-sso'
|
4
|
-
require 'gds-sso/omniauth_strategy'
|
5
|
-
|
6
|
-
class TestOmniAuthStrategy < Test::Unit::TestCase
|
7
|
-
def setup
|
8
|
-
@app = stub("app")
|
9
|
-
@strategy = OmniAuth::Strategies::Gds.new(@app, :gds, 'client_id', 'client_secret')
|
10
|
-
@strategy.stubs(:fetch_user_data).returns({ 'user' => {
|
11
|
-
'uid' => 'abcde',
|
12
|
-
'version' => 1,
|
13
|
-
'name' => 'Matt Patterson',
|
14
|
-
'email' => 'matt@alphagov.co.uk',
|
15
|
-
'github' => 'fidothe',
|
16
|
-
'twitter' => 'fidothe'
|
17
|
-
}}.to_json)
|
18
|
-
end
|
19
|
-
|
20
|
-
def test_build_auth_hash_returns_name_and_email
|
21
|
-
assert_equal 'Matt Patterson', @strategy.send(:build_auth_hash)['user_info']['name']
|
22
|
-
assert_equal 'matt@alphagov.co.uk', @strategy.send(:build_auth_hash)['user_info']['email']
|
23
|
-
end
|
24
|
-
|
25
|
-
def test_build_auth_hash_contains_extra_info
|
26
|
-
expected = {'uid' => 'abcde', 'version' => 1, 'name' => 'Matt Patterson', 'email' => 'matt@alphagov.co.uk', 'github' => 'fidothe', 'twitter' => 'fidothe'}
|
27
|
-
assert_equal expected, @strategy.send(:build_auth_hash)['extra']['user_hash']
|
28
|
-
end
|
29
|
-
|
30
|
-
def test_oauth_bypassed_if_json_is_accepted_by_request
|
31
|
-
@app.expects(:call)
|
32
|
-
rack_env = { "HTTP_ACCEPT" => 'application/json' }
|
33
|
-
@strategy.call(rack_env)
|
34
|
-
end
|
35
|
-
end
|