IT |
気になる、記になる… |
Google、より小型のディスプレイを採用したフラッグシップスマホを準備中か |
https://taisy0.com/2022/09/14/162046.html
|
digitalchatstation |
2022-09-14 11:45:58 |
Linux |
Ubuntuタグが付けられた新着投稿 - Qiita |
ubuntu 20.04 VNC Server のインストール |
https://qiita.com/hoshianaaa/items/52a52a0457db08b6cf91
|
stall |
2022-09-14 20:41:48 |
AWS |
AWSタグが付けられた新着投稿 - Qiita |
【初心者】CSVファイルをRedshiftにインポートするまでの軌跡 |
https://qiita.com/Toyo_m/items/03ed83708ea3d4975e37
|
mysqlworkbench |
2022-09-14 20:47:35 |
AWS |
AWSタグが付けられた新着投稿 - Qiita |
有料のEIPが削除できないので原因を特定してみた |
https://qiita.com/mmurm/items/068f8510019016880f5f
|
一つひとつ |
2022-09-14 20:45:50 |
Docker |
dockerタグが付けられた新着投稿 - Qiita |
Docker 版 Redmine の主副サーバ運用(Mac) |
https://qiita.com/bunzaemon/items/29fbb0c1d03f04bb5fd2
|
docker |
2022-09-14 20:47:09 |
Git |
Gitタグが付けられた新着投稿 - Qiita |
Homebrew 版 GitBucket の移植(Mac) |
https://qiita.com/bunzaemon/items/aca599bbd8b023125ffa
|
gitbucket |
2022-09-14 20:46:14 |
技術ブログ |
Developers.IO |
【登壇資料】 「aws-nuke + GithubActoinsで AWSアカウントのクリーンアップを 自動化した話」#自動化エンジニアのLT会 |
https://dev.classmethod.jp/articles/automation-lt-aws-nuke-gha-cleanup/
|
awsnukegithubactoins |
2022-09-14 11:01:03 |
海外TECH |
DEV Community |
Adding Authentication to full stack MERN web application |
https://dev.to/itsrakesh/adding-authentication-to-full-stack-mern-web-application-9mm
|
Adding Authentication to full stack MERN web applicationThis article is part of Let s build and deploy a full stack MERN web application In that tutorial we created an application called Productivity Tracker that allows you to log your daily activities However there is a problem with our app Can you figure it out Your hint is in the title of this article In this tutorial let s see the problem and how to tackle it Let s get started The ProblemSince your application is currently available online anyone can use it and add activities to your database That is not good is it Here authentication steps in to save the day To prevent unauthorized access to your app add authentication Adding AuthenticationWe had to develop front end and back end authentication separately because we separated the two Once more for the sake of simplicity we ll build basic authentication without the use of any libraries Backend authenticationWe need to implement backend authentication and authorize some routes Authentication vs AuthorizationThese two words can be confusing to you Authentication is allowing someone with credentials to access our application and Authorization is giving access to resources to authorized people In our scenario authorization grants access to resources like creating activities and fetching activities whereas authentication entails logging into the application Introduction to JWTJSON Web Token JWT is a compact URL safe means of representing claims to be transferred between two parties The claims in a JWT are encoded as a JSON object that is used as the payload of a JSON Web Signature JWS structure or as the plaintext of a JSON Web Encryption JWE structure enabling the claims to be digitally signed or integrity protected with a Message Authentication Code MAC and or encrypted In simple terms JWT is used is to verify that the user has permission to perform an action Let s implement login authentication with JWT Since you are the only person using your application you don t need a signup functionality and you can store EMAIL and PASSWORD in the env file Open the env file and add these three variables TOKEN KEY somesecrettokenEMAIL youremailPASSWORD yourpasswordHere TOKEN KEY can be any random string It is used by JWT Open up a terminal and install the jsonwebtoken package npm i jsonwebtokenOpen controllers folder and create auth controller js file Copy and paste the below code const jwt require jsonwebtoken require dotenv config const EMAIL process env EMAIL const PASSWORD process env PASSWORD If the email and password are correct then return a token const login req res gt Destructuring the email and password from the request body const email password req body if email EMAIL amp amp password PASSWORD Creating a token const token jwt sign email process env TOKEN KEY expiresIn h return res status json statusCode msg Login successful token return res status json statusCode msg Invalid Credentials module exports login The code above checks to see if the email address and password match and if they do it generates a token and sends it to the front end to implement front end authentication Open the routes folder create auth routes js and register a new route for login const express require express const login require controllers auth controller const router express Router router post login login module exports router Lastly in server js use the registered route const AuthRouter require routes auth route app use api auth AuthRouter We successfully implemented authentication Now only authenticated people can access our application But authenticated people can still access our resources and add activities because we haven t authorized those routes Let s create a middleware to authorize these routes GET api activitiesPOST api activityIn the project root create a folder called middleware and in that folder create the auth js file Copy and paste the below code const jwt require jsonwebtoken require dotenv config It checks if the token is valid and if it is it decodes it and attaches the decoded token to the request object const verifyToken req res next gt const token String req headers authorization replace bearer jwt i replace s s gi try if token return res status json statusCode msg A token is required for authentication Verifying the token const decoded jwt verify token process env TOKEN KEY req userData decoded catch err return res status json statusCode msg Invalid Token return next module exports verifyToken We created a middleware function called verifyToken to verify the token sent by the front end through the header If verification is successful then the user can access the above routes Now open activity route js and modify the code like this router get activities auth getActivities router post activity auth addActivity That s it Backend authentication is done Frontend authenticationIt s time to implement front end authentication First let s create a login page In src folder create Login jsx and Login css files Copy and paste the below code in Login jsx file and use this in Login css import React from react import Login css const Login gt When the user submits the form prevent the default action grab the email and password from the form send a POST request to the backend with the email and password and if the response is successful store the token in local storage and reload the page const handleSubmit async event gt event preventDefault const email password event target const response await fetch process env REACT APP BACKEND URL auth login method POST headers Content Type application json body JSON stringify email email value password password value const data await response json localStorage setItem token data token window location reload return lt div className login gt lt h gt Login lt h gt lt form onSubmit handleSubmit gt lt span gt lt label htmlFor email gt Email lt label gt lt input type email id email name email gt lt span gt lt span gt lt label htmlFor password gt Password lt label gt lt input type password id password name password gt lt span gt lt button type submit gt Login lt button gt lt form gt lt div gt export default Login This will render the login page The handleSubmit gets the email and password from the form makes a POST request and sends email and password values for verification After that server verifies and sends back a token that we can use to access resources Here we are using localStorage to store the value in the browser permanently so that we won t get logged out after closing the application or browser Open the index js file and add this logic If there is a token in localStorage render App jsx otherwise Login jsx const token localStorage getItem token root render lt React StrictMode gt token lt App gt lt Login gt lt React StrictMode gt Now in the App jsx file we need to send token through the header so that backend will verify it and gives access to the routes useEffect gt const fetchData async gt const result await fetch process env REACT APP BACKEND URL activities headers Authorization Bearer token lt HERE const data await result json setActivities data fetchData token const addActivity async event gt event preventDefault const newActivity name event target activity value time event target time value await fetch process env REACT APP BACKEND URL activity method POST headers Content Type application json Authorization Bearer token lt HERE body JSON stringify newActivity event target activity value event target time value window location reload Done We implemented both frontend and backend authentication Now only you can access your application as long as you don t share your credentials Source code productivity appIn the next article we will learn how to write tests for frontend and backend Follow for more |
2022-09-14 11:05:14 |
Apple |
AppleInsider - Frontpage News |
Apple unveils fourth South Korea Apple Store |
https://appleinsider.com/articles/22/09/14/apple-unveils-fourth-south-korea-apple-store?utm_medium=rss
|
Apple unveils fourth South Korea Apple StoreApple Jamsil will open in South Korea s Songpa gu District on September and will be in the Lotte World Mall Following just months after opening Apple Myeongdong store in Seoul Apple has announced another one The announcement was made on Apple s official store website which revealed that Apple Jamsil will open at a m local time Apple Jamsil is situated miles away from the Apple Myeongdong and across the Han River Read more |
2022-09-14 11:27:17 |
海外TECH |
Engadget |
The Morning After: Nintendo’s next Zelda game has a release date |
https://www.engadget.com/the-morning-after-nintendos-next-zelda-game-has-a-release-date-113152235.html?src=rss
|
The Morning After Nintendo s next Zelda game has a release dateThe sequel to The Legend of Zelda Breath of the Wild finally has a name Tears of the Kingdom And it s finally got a release date too May th This was arguably the big reveal of Nintendo s Direct live stream alongside a Pikmin sequel We got an all too brief teaser showcasing the verticality of the BoTW sequel and what appears to be a Link that runs faster Hopefully We re excited We ve got a lot more gaming news today from both Nintendo and PlayStation Mat SmithThe biggest stories you might have missed God of War Ragnarok has a new story trailer Volkswagen ID Buzz first driveHBO and Apple TV win big at the Emmys Zero s DSR X is an adventure e motorcycle with miles of range Twitter whistleblower says company had Chinese agent on payroll Clean Energy Charging is coming to iPhones this year Fire Emblem Engage will arrive on Switch January thWatch nearly minutes of Bayonetta gameplay in a new trailerWhat we bought How the Blue Yeti Nano finally earned a spot on my desk Sonos Sub Mini is a much smaller and cheaper way to add bassThe company is setting it up as a companion for its smaller speakers SonosSonos already offers a wireless subwoofer as part of its home theater It s big and it s expensive at Now for anyone with a smaller room or a smaller budget it was a bit of a stretch Sonos is giving bass lovers a new option today the rumored Sub Mini is real ーand at it costs a lot less than its bigger sibling Continue reading Amazon s Kindle refresh closes the gap between its entry level and premium e readersLonger battery life and a higher resolution display The edition of Amazon s entry level Kindle has enough new stuff that existing Kindle owners might even consider upgrading First up there s a new ppi display up from the ppi on its predecessors giving it the same resolution as the last few Paperwhites However unlike those premium e readers the price is a more palatable Continue reading GoldenEye is coming to Nintendo Switch Online s Expansion PackAnd with online play During today s Nintendo Direct it emerged that GoldenEye is coming to the Nintendo Switch Online Expansion Pack service What s more you ll be able to hop into the iconic multiplayer mode with your friends through online play Nintendo didn t say when the first person shooter will arrive on Switch other than to say it s coming soon And GoldenEye will be available on Xbox Game Pass Rare says the game has been faithfully recreated for Xbox consoles Continue reading Twitter shareholders vote to approve Elon Musk s billion acquisitionAn October trial will determine if Musk is able to terminate the deal A majority of Twitter s shareholders have voted to approve Elon Musk s billion takeover During a special meeting of shareholders that lasted about seven minutes stockholders approved two proposals one to adopt the merger agreement with Musk and one related to how the company s executives will be compensated as a result of the deal However the October trial in Delaware s Court of Chancery will determine whether Musk is able to terminate the agreement Musk initially cited concerns about bots and spam as reasons for ending the merger agreement though Twitter s lawyers argued he was actually concerned about “World War Continue reading |
2022-09-14 11:31:52 |
海外TECH |
WIRED |
The Best Substack Alternatives |
https://www.wired.com/story/best-substack-alternatives/
|
newsletter |
2022-09-14 12:00:00 |
海外TECH |
WIRED |
One of Gaming’s Greatest Writers Is Busy Crafting Romance Novels |
https://www.wired.com/story/jane-jensen-eli-easton-interview/
|
gabriel |
2022-09-14 12:00:00 |
海外TECH |
WIRED |
PlayStation VR2: A First Look at the Next-Gen Headset |
https://www.wired.com/story/sony-psvr2-first-look/
|
arrives |
2022-09-14 12:00:00 |
海外TECH |
WIRED |
The End of Roe Will Spark a Digital Civil War |
https://www.wired.com/story/the-end-of-roe-will-spark-a-digital-civil-war/
|
rights |
2022-09-14 12:00:00 |
医療系 |
医療介護 CBnews |
社保改革メニューに医療・介護DX推進など-諮問会議・民間議員 |
https://www.cbnews.jp/news/entry/20220914203541
|
社会保障 |
2022-09-14 20:55:00 |
金融 |
金融庁ホームページ |
鈴木財務大臣兼内閣府特命担当大臣閣議後記者会見の概要(令和4年9月13日)を掲載しました。 |
https://www.fsa.go.jp/common/conference/minister/2022b/20220913-1.html
|
内閣府特命担当大臣 |
2022-09-14 13:00:00 |
ニュース |
BBC News - Home |
UK inflation: Milk, cheese and eggs push food price rises to 14-year high |
https://www.bbc.co.uk/news/uk-62891168?at_medium=RSS&at_campaign=KARANGA
|
highfood |
2022-09-14 11:36:28 |
ニュース |
BBC News - Home |
Clarence House staff told jobs are at risk |
https://www.bbc.co.uk/news/uk-62897488?at_medium=RSS&at_campaign=KARANGA
|
accession |
2022-09-14 11:08:59 |
ニュース |
BBC News - Home |
Lyra McKee: Niall Sheerin jailed for having gun used to kill journalist |
https://www.bbc.co.uk/news/uk-northern-ireland-60060498?at_medium=RSS&at_campaign=KARANGA
|
belfast |
2022-09-14 11:43:03 |
ニュース |
BBC News - Home |
Anti-obesity strategy to be reviewed due to cost-of-living crisis |
https://www.bbc.co.uk/news/uk-politics-62900076?at_medium=RSS&at_campaign=KARANGA
|
crisisit |
2022-09-14 11:36:29 |
ニュース |
BBC News - Home |
Camping overnight to see Queen's lying-in-state |
https://www.bbc.co.uk/news/uk-62902930?at_medium=RSS&at_campaign=KARANGA
|
coffin |
2022-09-14 11:27:44 |
ニュース |
BBC News - Home |
Queen's lying-in-state: What to know before you join the queue |
https://www.bbc.co.uk/news/uk-62872323?at_medium=RSS&at_campaign=KARANGA
|
queen |
2022-09-14 11:26:50 |
ニュース |
BBC News - Home |
What time is the Queen's funeral? Who will wear military uniform? And other questions. |
https://www.bbc.co.uk/news/uk-62844663?at_medium=RSS&at_campaign=KARANGA
|
daily |
2022-09-14 11:28:02 |
ニュース |
BBC News - Home |
Westminster Hall: Trials, speeches and lying-in-state |
https://www.bbc.co.uk/news/uk-62875864?at_medium=RSS&at_campaign=KARANGA
|
charles |
2022-09-14 11:06:36 |
ニュース |
BBC News - Home |
Queen's lying-in-state: What it will look like |
https://www.bbc.co.uk/news/uk-62878294?at_medium=RSS&at_campaign=KARANGA
|
coffin |
2022-09-14 11:38:10 |
北海道 |
北海道新聞 |
ウクライナ軍、南部も反撃 ロシア世論、「敗退」に動揺 |
https://www.hokkaido-np.co.jp/article/731103/
|
敗退 |
2022-09-14 20:26:00 |
北海道 |
北海道新聞 |
カザフ首都名「アスタナ」復活へ 前大統領引退で、3年で元に |
https://www.hokkaido-np.co.jp/article/731102/
|
前大統領 |
2022-09-14 20:26:00 |
北海道 |
北海道新聞 |
学習支援の場確保へCF 釧路の子育て団体 NPO設立目指す |
https://www.hokkaido-np.co.jp/article/730960/
|
実行委員会 |
2022-09-14 20:24:00 |
北海道 |
北海道新聞 |
スノボ戸塚「挑戦していく年に」 HP、世界2連覇へ |
https://www.hokkaido-np.co.jp/article/731086/
|
連覇 |
2022-09-14 20:12:13 |
北海道 |
北海道新聞 |
妻子殺害容疑の男、鑑定留置 名古屋地検 |
https://www.hokkaido-np.co.jp/article/731093/
|
名古屋地検 |
2022-09-14 20:15:00 |
北海道 |
北海道新聞 |
再エネ普及へ送電網強化 北電ネット、1千億円以上投資 23年度から5年間 |
https://www.hokkaido-np.co.jp/article/731060/
|
再生可能エネルギー |
2022-09-14 20:16:03 |
北海道 |
北海道新聞 |
セクハラ巡査部長減給、群馬県警 パワハラの警部補も注意 |
https://www.hokkaido-np.co.jp/article/731090/
|
巡査部長 |
2022-09-14 20:12:00 |
北海道 |
北海道新聞 |
知床事故21日から集中捜索 道警と1管本部が3日間 |
https://www.hokkaido-np.co.jp/article/731089/
|
kazui |
2022-09-14 20:11:00 |
北海道 |
北海道新聞 |
SBI、アルヒにTOB 住宅ローン販路拡大 |
https://www.hokkaido-np.co.jp/article/731087/
|
住宅ローン |
2022-09-14 20:01:00 |
IT |
週刊アスキー |
バンダイナムコの新作プロジェクト『SYNDUALITY(シンデュアリティ)』が発表 |
https://weekly.ascii.jp/elem/000/004/105/4105549/
|
synduality |
2022-09-14 20:30:00 |
IT |
週刊アスキー |
「龍が如く」新作3本が発表、龍が如く8は桐生一馬&春日一番のダブル主人公! |
https://weekly.ascii.jp/elem/000/004/105/4105550/
|
春日一番 |
2022-09-14 20:30:00 |
コメント
コメントを投稿