Sorcery Gem

586ce0917803045728b59ccd78f82171?s=47 ebi
November 07, 2016

Sorcery Gem

Presentation about sorcery gem.

586ce0917803045728b59ccd78f82171?s=128

ebi

November 07, 2016
Tweet

Transcript

  1. Sorcery Gem @ebihara99999

  2. ࣗݾ঺հ • LICTOORגࣜձࣾͱ͍͏ελʔτΞοϓۈ຿ɻ • ΫϩʔϥʔΛΑ͘ॻ͍͍ͯ·͢ɻ • ਓ਺͕গͳ͍ͷͰΠϯϑϥߏஙʢओʹ"84ʣ͔Β ϑϩϯτΤϯυ·Ͱ৭ʑ৮͍ͬͯ·͢ɻ

  3. Sorceryͱ͸ • ೝূػೳΛఏڙ͢Δ gem • ActiveRecordɾDataMapperɾMongoidɾ MongoMapperΛαϙʔτ • ઃఆϑΝΠϧ͸ config/initializers/sorcery.rb

    ͷΈ • ॕʂ organizationԽ
  4. Installation • جຊܗ $ rails generate sorcery:install app/models/user.rb db/migrate/***_sorcery_core.rb config/initializers/sorcery.rb

    • ࡞੒͞ΕΔϑΝΠϧ
  5. # db/migrate/20161024063842_sorcery_core.rb class SorceryCore < ActiveRecord::Migration def change create_table :users

    do |t| t.string :email, :null => false t.string :crypted_password t.string :salt t.timestamps end add_index :users, :email, unique: true end end
  6. Installation • ػೳʢޙड़ʣΛ௥Ճ͍ͨ͠৔߹ $ rails generate sorcery:install external --only-submodules •

    ModelΛมߋ͍ͨ͠৔߹ $ rails generate sorcery:install --model Person
  7. ೝূʹ࢖༻͢ΔΧϥϜͷมߋ • σϑΥϧτ͸FNBJMͱDSZQUFE@QBTTXPSE • migrationϑΝΠϧͱconfig/initializers/sorcery.rbΛฤू ʢҎԼ͸emailͱusernameΛೝূʹ࢖͏৔߹ʣ # config/initializers/sorcery.rb user.username_attribute_names =

    [:email, :username] /* log */ SELECT `users`.* FROM `users` WHERE (`users`.`username` = 'b@hoge.com' OR `users`.`email` = 'b@hoge.com') ORDER BY `users`.`id` ASC LIMIT 1
  8. ෳ਺ϞσϧରԠ • STIରԠ • config/initializers/sorcery.rbΛฤू # config/initializers/sorcery.rb user.subclasses_inherit_config = true

    • ͦͷޙɺ45*Λ࣮૷͢Δ • ৄ͘͠͸චऀ࡞੒ͷαϯϓϧΞϓϦΛ͝ཡ͍ͩ͘͞ʢhttps:// github.com/ebihara99999/sorcery-presentation-app/tree/ presentationʣ
  9. ෳ਺ϞσϧରԠ • STIͰରԠͰ͖ͳ͍ʢ͠ͳ͍ʣ৔߹ɺSorceryͱͯ͠ఏڙ͢Δศརػೳ͸ ͳ͠ • ཁ͕݅ෳࡶͳ৔߹͸ɺࣗ෼ͰΧελϚΠζ͢Δඞཁ͕͋Δ • adminͱuser͕͍Δ৔߹ɺrails generate sorcery:install

    --model AdminΛͯ͠ɺadminϞσϧ΋࡞੒͠ɺཁ݅ʹԠͯ͡migrationϑΝΠ ϧΛमਖ਼͢Δ • adminͱuserΛඥ෇͚͍ͨ৔߹ɺuserϞσϧʹadmin_idΛ࣋ͬͨΓɺ admin_usersςʔϒϧʢதؒςʔϒϧʣΛ࡞੒ͨ͠Γ͢Δ • ൺֱతΧελϚΠζ͠қ͍͠ɺTPSDFSZͷBQJ͸࢖͑ΔͷͰศར
  10. ϞδϡʔϧҰཡ • ػೳ͝ͱͰ module ʹ෼ׂ͞Ε͍ͯΔ Core / User Activation /

    Reset Password / Remember Me / Session Timeout / Brute Force Protection / Basic HTTP Authentication / Activity Logging / External
  11. ֤Ϟδϡʔϧͷઆ໌ • Core • جຊػೳͷఏڙ • ιϧτͷઃఆɾ௥ՃՄೳ • Ϣʔβʔ໊ɾFNBJMɾύεϫʔυଐੑͷ໊শΛมߋՄೳ •

    User Activation • ϝʔϧೝূʢೝূϝʔϧΛૹ৴͠ϦϯΫΛ౿ΜͰ΋Β͏ʣ • Reset Password • ύεϫʔυϦηοτ
  12. ֤Ϟδϡʔϧͷઆ໌ • Remember Me • ࣗಈϩάΠϯ • Session Timeout •

    ઃఆϑΝΠϧͷΈͰઃఆՄ • Brute Force Protection • ύεϫʔυ߈ܸ΁ͷରԠɻ • ϩοΫ·Ͱͷࣦഊճ਺ɾϩοΫ࣌ؒΛઃఆՄɻ
  13. ֤Ϟδϡʔϧͷઆ໌ • Basic HTTP Authentication • Basicೝূ • Activity Logging

    • ࠷ऴϩάΠϯ೔࣌ • ࠷ऴϩάΞ΢τ೔࣌ • ࠷ऴΞΫςΟϏςΟ೔࣌ • ࠷ऴϩάΠϯ࣌ͷ*1
  14. • External • ֎෦αʔϏεϩάΠϯ ରԠαʔϏε Twitter / Facebook / Github

    / Google / Heroku / LinkedIn / VKʢϩγΞ࠷େͷSNSʣ / LiveID / XingʢυΠπͷLinkedInͷΑ͏ͳSNSʣ / Salesforce / JIRA / PayPal / slack
  15. ࠷ޙʹ • wikiʹ֤Ϟδϡʔϧͷ࣮૷ํ๏͕ஸೡʹॻ͍ͯ͋Δ ͷͰɺੋඇҰ౓৮ͬͯΈ͍ͯͩ͘͞ɻ • ࡞ऀʹΑΔαϯϓϧΞϓϦ΋ެ։͞Ε͍ͯ·͢ɻ https://github.com/Sorcery/sorcery-example- app • NoamB/sorcery

    Ͱ͸ͳ͘ Sorcery/sorcery ͳͷͰ ͝஫ҙ͍ͩ͘͞ɻ
  16. ࢀߟ • https://github.com/Sorcery/sorcery • https://github.com/Sorcery/sorcery/wiki