Upgrade to Pro
— share decks privately, control downloads, hide ads and more …
Speaker Deck
Features
Speaker Deck
PRO
Sign in
Sign up for free
Search
Search
Materia.pdf
Search
TakutoYoshimura
January 25, 2019
Technology
240
1
Share
Materia.pdf
TakutoYoshimura
January 25, 2019
More Decks by TakutoYoshimura
See All by TakutoYoshimura
gcp_gke_infla_design.pdf
takutoyoshimura
0
300
Other Decks in Technology
See All in Technology
MCPで決済に楽にする
mu7889yoon
0
160
出版記念イベントin大阪「書籍紹介&私がよく使うMCPサーバー3選と社内で安全に活用する方法」
kintotechdev
0
120
自分をひらくと次のチャレンジの敷居が下がる
sudoakiy
2
850
FASTでAIエージェントを作りまくろう!
yukiogawa
4
180
GitHub Advanced Security × Defender for Cloudで開発とSecOpsのサイロを超える: コードとクラウドをつなぐ、開発プラットフォームのセキュリティ
yuriemori
1
120
OPENLOGI Company Profile for engineer
hr01
1
61k
How to install a gem
indirect
0
2k
Bref でサービスを運用している話
sgash708
0
210
トイルを超えたCREは何屋になるのか
bengo4com
0
110
Blue/Green Deployment を用いた PostgreSQL のメジャーバージョンアップ
kkato1
0
170
MIX AUDIO EN BROADCAST
ralpherick
0
140
GitHub Actions侵害 — 相次ぐ事例を振り返り、次なる脅威に備える
flatt_security
11
6.9k
Featured
See All Featured
The AI Search Optimization Roadmap by Aleyda Solis
aleyda
1
5.5k
Responsive Adventures: Dirty Tricks From The Dark Corners of Front-End
smashingmag
254
22k
How People are Using Generative and Agentic AI to Supercharge Their Products, Projects, Services and Value Streams Today
helenjbeal
1
140
First, design no harm
axbom
PRO
2
1.2k
Building a A Zero-Code AI SEO Workflow
portentint
PRO
0
420
Bootstrapping a Software Product
garrettdimon
PRO
307
120k
Kristin Tynski - Automating Marketing Tasks With AI
techseoconnect
PRO
0
210
Design of three-dimensional binary manipulators for pick-and-place task avoiding obstacles (IECON2024)
konakalab
0
390
Leveraging Curiosity to Care for An Aging Population
cassininazir
1
200
[SF Ruby Conf 2025] Rails X
palkan
2
870
The Myth of the Modular Monolith - Day 2 Keynote - Rails World 2024
eileencodes
26
3.4k
実際に使うSQLの書き方 徹底解説 / pgcon21j-tutorial
soudai
PRO
199
73k
Transcript
サービスバックエンドOSS Materia Takuto Yoshimura
[email protected]
自己紹介 本名 吉村 拓人 カラビナテクノロジー株式会社 社内のあだ名は つちろー 元はJava の金融系SIer 昨年より顧問エンジニアとしてElixir
でWeb システ ム開発はじめました
顧問エンジニアとは 月額定額で0 からのシステム開発をサポート Web サービス立ち上げのビジネスモデル構築など からお供いたします 数名の担当で複数のお客様のサービスを開発
2018 年の私
複数のお客様へ向けてWeb システム 開発を平行で行う日々
Phoenix が標準で担保しない、業務 システムでの必須機能 ユーザー認証機構(guardian) トランザクションスコープ 楽観/ 悲観排他ロジック etc
毎回実装するのがめんどくさ・・・
もとい、もっと開発生産性あげたい
共通機能作って再利用しよう
どうせならOSS として公開しよう
Materia とは 弊社カラビナテクノロジーで開発中の Elixir/Phoenix 製サービスバックエンドライブラリ SPA(Single Page Application) での開発を想定した バックエンドAPI
を提供 サービスとして特色のないユーザー管理や認証と いった部分のバックエンド機能を個別開発せず に、本来実装したいサービスの特色となる機能の 開発に注力 Qiita 記事: Web サービスバックエンドライブラリー Materia
Materia ファイミリー構成 MateriaUtils: 日付変換、Ector ラッパー実装など各 種ユーティリティ Materia: アカウント管理、JWT 認証、権限管理 MateriaCommerce:
商品・価格・税情報、購入契 約管理 他追加開発中
サービス構築時の構成 OriginalService = MateriaUtils + Materia + MateriaHogeHoge + OriginalElixirCode
導入のステップ |> deps.get |> config 設定 |> migration ファイル生成 |>
router.ex で必要な認証機構とAPI を定義 materia README
deps.get mix.exs defp deps do [ {:phoenix, "~> 1.3.2"}, ~
中略 ~ {:cowboy, "~> 1.0"}, {:materia, "~> 0.1.2"} # add here ] > mix deps.get
con g 設定 jwt 認証(guardian) の設定 Repo の設定 参考 materia
README Materia を導入してログイン認証してみる
migration ファイル作成 > mix guardian.db.gen.migration > mix materia.gen.migration > mix
ecto.create > mix ecto.migrate > mix run priv/repo/seeds.exs
ルーティング設定 pipeline で認証ロジックの設定 pipeline :user_auth do plug Materia.UserAuthPipeline end pipe_through
でAPI 毎にパイプラインを指定 scope "/api", MateriaWeb do pipe_through [ :api, :user_auth] get "/user", UserController, :show_me post "/grant", GrantController, :get_by_role end
ログインAPI リクエスト POST http://localhost:4000/api/sign-in HTTP/1.1 Content-Type: application/json { "email": "
[email protected]
",
"password": "hogehoge" }
ログインAPI レスポンス HTTP/1.1 201 Created server: Cowboy date: Fri, 14
Dec 2018 08:16:32 GMT content-length: 740 content-type: application/json; charset=utf-8 cache-control: max-age=0, private, must-revalidate { "refresh_token": "hogehoge", "id": 1, "access_token": "fugafuga" }