{"id":4290,"date":"2018-09-10T21:34:19","date_gmt":"2018-09-10T19:34:19","guid":{"rendered":"https:\/\/blog.mi.hdm-stuttgart.de\/?p=4290"},"modified":"2023-06-09T12:03:27","modified_gmt":"2023-06-09T10:03:27","slug":"web-server-with-user-registration-and-guestbook-with-image-upload","status":"publish","type":"post","link":"https:\/\/blog.mi.hdm-stuttgart.de\/index.php\/2018\/09\/10\/web-server-with-user-registration-and-guestbook-with-image-upload\/","title":{"rendered":"Web server with user registration and guestbook with image upload"},"content":{"rendered":"<h3>Overview<\/h3>\n<p>The users access the website where they have the option to the view the guest book, register or log in. To register the user has to provide a username, an email address and a secure password (more than 8 characters, upper and lowercase characters, numbers and special characters). Then an email with a verification link will be sent to the provided email address. Clicking this link will enable the user to login.<\/p>\n<p>Upon login the user can post messages in the guest book, which will be saved to the MySQL database. In addition to a text message the user can also upload an image which will be transferred to an S3 Bucket, which in turn will trigger a Lambda. Here the image will be resized to make it suitable for displaying in the guest book and it will be transferred to another S3 Bucket and permissions will be set to make in publicly accessible. The URL to this image will also be saved in the MySQL database.<\/p>\n<p><figure id=\"attachment_4295\" aria-describedby=\"caption-attachment-4295\" style=\"width: 656px\" class=\"wp-caption aligncenter\"><a href=\"https:\/\/blog.mi.hdm-stuttgart.de\/wp-content\/uploads\/2018\/09\/cloudcraft1.png\"><img loading=\"lazy\" decoding=\"async\" data-attachment-id=\"4295\" data-permalink=\"https:\/\/blog.mi.hdm-stuttgart.de\/index.php\/2018\/09\/10\/web-server-with-user-registration-and-guestbook-with-image-upload\/cloudcraft1\/\" data-orig-file=\"https:\/\/blog.mi.hdm-stuttgart.de\/wp-content\/uploads\/2018\/09\/cloudcraft1.png\" data-orig-size=\"1280,720\" data-comments-opened=\"1\" data-image-meta=\"{&quot;aperture&quot;:&quot;0&quot;,&quot;credit&quot;:&quot;&quot;,&quot;camera&quot;:&quot;&quot;,&quot;caption&quot;:&quot;&quot;,&quot;created_timestamp&quot;:&quot;0&quot;,&quot;copyright&quot;:&quot;&quot;,&quot;focal_length&quot;:&quot;0&quot;,&quot;iso&quot;:&quot;0&quot;,&quot;shutter_speed&quot;:&quot;0&quot;,&quot;title&quot;:&quot;&quot;,&quot;orientation&quot;:&quot;0&quot;}\" data-image-title=\"Project architecture\" data-image-description=\"\" data-image-caption=\"&lt;p&gt;Project architecture (created with Cloudcraft.co)&lt;\/p&gt;\n\" data-large-file=\"https:\/\/blog.mi.hdm-stuttgart.de\/wp-content\/uploads\/2018\/09\/cloudcraft1-1024x576.png\" class=\"size-large wp-image-4295\" src=\"https:\/\/blog.mi.hdm-stuttgart.de\/wp-content\/uploads\/2018\/09\/cloudcraft1-1024x576.png\" alt=\"Project architecture\" width=\"656\" height=\"369\" srcset=\"https:\/\/blog.mi.hdm-stuttgart.de\/wp-content\/uploads\/2018\/09\/cloudcraft1-1024x576.png 1024w, https:\/\/blog.mi.hdm-stuttgart.de\/wp-content\/uploads\/2018\/09\/cloudcraft1-300x169.png 300w, https:\/\/blog.mi.hdm-stuttgart.de\/wp-content\/uploads\/2018\/09\/cloudcraft1-768x432.png 768w, https:\/\/blog.mi.hdm-stuttgart.de\/wp-content\/uploads\/2018\/09\/cloudcraft1.png 1280w\" sizes=\"auto, (max-width: 656px) 100vw, 656px\" \/><\/a><figcaption id=\"caption-attachment-4295\" class=\"wp-caption-text\">Project architecture (created with Cloudcraft.co)<\/figcaption><\/figure><br \/>\n<!--more--><\/p>\n<h3>EC2 Instance<\/h3>\n<p>The OS running on the EC2 instance is Amazon Linux which is based on Red Hat Enterprise Linux. This is because I created the EC2 instance at the time when I was working through the AWS tutorials and this was the recommended distribution. By the time I started with the project, I decided to stick with it, although I had no prior experience with this distribution.<\/p>\n<p>With &#8216;yum&#8217;, the packet manager of this distribution I was only able to install PHP 5.4 with in turn only enabled me to install version 2 of the AWS SDK for PHP which led to major problems later on with Cognito.<\/p>\n<p>After a long search for a possibility to install a newer version of PHP (most advise suggested adding additional repositories, which never succeeded) I\u00a0 found the following solution.<\/p>\n<pre class=\"prettyprint lang-sh\" data-start-line=\"1\" data-visibility=\"visible\" data-highlight=\"\" data-caption=\"\">sudo amazon-linux-extras install php7.2<\/pre>\n<p>With this command I could finally upgrade to PHP 7.2. This in turn required an upgrade to Apache 2.4 which could be achieved with the same command.<\/p>\n<h3>RDS<\/h3>\n<p>For a database system I decided on MySQL. The setup was straightforward with the exception of the firewall. My EC2 instance wouldn&#8217;t connect to the RDS instance even after I setup the security group to allow port 3306 from the public IP address of the EC2. The search for a solution led me to create another MySQL user and checking various configuration files (as sometimes the remote access for the root user may be disabled), all to no avail. In the end it turned out I had used the wrong IP address, as the public IP address isn&#8217;t the one which connects to the RDS. The correct one can be found by running the &#8216;ifconfig&#8217; command on the EC2 instance.<\/p>\n<h3>Lambda<\/h3>\n<p>For the resize Lambda function I built upon a function from the AWS examples. This function is triggered by uploading a file to a S3 Bucket. The image will then be downsized if necessary, transferred to another S3 Bucket, from which it can be publicly read and subsequently deleted from the first bucket. After setting everything up and testing it I found it didn&#8217;t work.<\/p>\n<p>I used CloudWatch to debug, which show an access denied error. After much testing and searching I discovered that the process of making an object publicly available requires a separate action, called &#8220;s3:PutObjectAcl&#8221;\u00a0 to be allowed in the policy.<\/p>\n<h3>Cognito &amp; SES<\/h3>\n<p>Originally I had planned to do the user registration myself and just use the SES (Simple Email Service) for the verification email, but upon discovering the Cognito feature, which has the verification system built-in,\u00a0 I decided to use this instead.<\/p>\n<p>As I had installed an old version of PHP (see above), the packet manager of PHP (Composer) installed the only compatible version of the AWS SDK, which was 2.x. This didn&#8217;t have the\u00a0 necessary &#8216;CognitoIdentityProvider&#8217; methods but instead the easy to confuse &#8220;CognitoIdentity&#8221; methods, which is used for the Federated Identities feature of Cognito instead.<\/p>\n<p>After some time of trying I spotted my mistake and after some other time installing a current version of PHP I could upgrade to AWS SDK v3.<\/p>\n<p>Here I discovered the needed methods for user registration and login but was unable to execute them due to a required &#8216;SecretHash&#8217;\u00a0 attribute which wasn&#8217;t documented on how to be generated.<\/p>\n<p>Eventually I found <a href=\"https:\/\/github.com\/pmill\/aws-cognito\">aws-cognito<\/a> on GitHub. This is a PHP library which provides the Cognito functionality in simpler methods.<\/p>\n<h3>S3 Buckets<\/h3>\n<p>Working with S3 Buckets was pretty straightforward with the AWS SDK for PHP. The only real problem I&#8217;ve encountered was the constructor. In the documentation are to possible methods for creating the client.<\/p>\n<p>The first and recommended one was this:<\/p>\n<pre class=\"prettyprint lang-php\" data-start-line=\"1\" data-visibility=\"visible\" data-highlight=\"\" data-caption=\"\">use Aws\\S3\\S3Client;\n$client = S3Client::factory($config);<\/pre>\n<p>This method refused to accept my config file, no matter how I reformatted it.After I changed my code to the second method everything worked fine.<\/p>\n<pre class=\"prettyprint lang-php\" data-start-line=\"1\" data-visibility=\"visible\" data-highlight=\"\" data-caption=\"\">$s3 = new Aws\\S3\\S3Client($config);<\/pre>\n<p>&nbsp;<\/p>\n<p>The source code is available <a href=\"https:\/\/github.com\/ok043\/dev4cloud\">here<\/a><\/p>\n","protected":false},"excerpt":{"rendered":"<p>Overview The users access the website where they have the option to the view the guest book, register or log in. To register the user has to provide a username, an email address and a secure password (more than 8 characters, upper and lowercase characters, numbers and special characters). Then an email with a verification [&hellip;]<\/p>\n","protected":false},"author":904,"featured_media":0,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"_jetpack_memberships_contains_paid_content":false,"footnotes":""},"categories":[120,650],"tags":[],"ppma_author":[772],"class_list":["post-4290","post","type-post","status-publish","format-standard","hentry","category-cloud-technologies","category-scalable-systems"],"aioseo_notices":[],"jetpack_featured_media_url":"","jetpack-related-posts":[{"id":4190,"url":"https:\/\/blog.mi.hdm-stuttgart.de\/index.php\/2018\/08\/31\/yourtube-a-simple-video-platform-in-you-personal-amazon-cloud\/","url_meta":{"origin":4290,"position":0},"title":"YourTube &#8211; A simple video platform in you personal amazon cloud","author":"nk078","date":"31. August 2018","format":false,"excerpt":"During the Dev4Cloud Levture i created a simple static webpage that uses Amazons S3 service for Hosting and video storage and amazons cognito for user authentification and role managemant. Design considerations. The platform was designed with simplicity in mind and there for i decided to go with as few services\u2026","rel":"","context":"In &quot;Allgemein&quot;","block_context":{"text":"Allgemein","link":"https:\/\/blog.mi.hdm-stuttgart.de\/index.php\/category\/allgemein\/"},"img":{"alt_text":"","src":"","width":0,"height":0},"classes":[]},{"id":28282,"url":"https:\/\/blog.mi.hdm-stuttgart.de\/index.php\/2026\/02\/22\/building-a-cloud-native-web-application-for-case-based-file-sharing-on-aws\/","url_meta":{"origin":4290,"position":1},"title":"Developing a cloud-native web application for case-based file sharing on AWS","author":"Philipp Treupel","date":"22. February 2026","format":false,"excerpt":"Motivation Professional file sharing is a significant challenge in sectors such as healthcare, insurance, and consulting. Practitioners routinely need to exchange sensitive documents with clients, yet existing solutions such as Google Drive and OneDrive can quickly become disorganized when managing multiple cases. Users struggle with scattered links, having to manually\u2026","rel":"","context":"In &quot;Cloud Technologies&quot;","block_context":{"text":"Cloud Technologies","link":"https:\/\/blog.mi.hdm-stuttgart.de\/index.php\/category\/scalable-systems\/cloud-technologies\/"},"img":{"alt_text":"","src":"https:\/\/i0.wp.com\/blog.mi.hdm-stuttgart.de\/wp-content\/uploads\/2026\/02\/user-journey-essencis-en.png?resize=350%2C200&ssl=1","width":350,"height":200,"srcset":"https:\/\/i0.wp.com\/blog.mi.hdm-stuttgart.de\/wp-content\/uploads\/2026\/02\/user-journey-essencis-en.png?resize=350%2C200&ssl=1 1x, https:\/\/i0.wp.com\/blog.mi.hdm-stuttgart.de\/wp-content\/uploads\/2026\/02\/user-journey-essencis-en.png?resize=525%2C300&ssl=1 1.5x, https:\/\/i0.wp.com\/blog.mi.hdm-stuttgart.de\/wp-content\/uploads\/2026\/02\/user-journey-essencis-en.png?resize=700%2C400&ssl=1 2x, https:\/\/i0.wp.com\/blog.mi.hdm-stuttgart.de\/wp-content\/uploads\/2026\/02\/user-journey-essencis-en.png?resize=1050%2C600&ssl=1 3x, https:\/\/i0.wp.com\/blog.mi.hdm-stuttgart.de\/wp-content\/uploads\/2026\/02\/user-journey-essencis-en.png?resize=1400%2C800&ssl=1 4x"},"classes":[]},{"id":21653,"url":"https:\/\/blog.mi.hdm-stuttgart.de\/index.php\/2021\/09\/17\/studidash-a-serverless-web-application\/","url_meta":{"origin":4290,"position":2},"title":"&#8220;Studidash&#8221; | A serverless web application","author":"dk119","date":"17. September 2021","format":false,"excerpt":"by Oliver Klein (ok061), Daniel Koch (dk119), Luis B\u00fchler (lb159), Micha Huhn (mh334) Abstract You are probably familiar with the HdM SB-Funktionen. After nearly four semesters we were tired of the boring design and decided to give it a more modern look with a bit more functionality then it currently\u2026","rel":"","context":"In &quot;Allgemein&quot;","block_context":{"text":"Allgemein","link":"https:\/\/blog.mi.hdm-stuttgart.de\/index.php\/category\/allgemein\/"},"img":{"alt_text":"","src":"https:\/\/i0.wp.com\/blog.mi.hdm-stuttgart.de\/wp-content\/uploads\/2021\/09\/grafik-1.png?resize=350%2C200&ssl=1","width":350,"height":200,"srcset":"https:\/\/i0.wp.com\/blog.mi.hdm-stuttgart.de\/wp-content\/uploads\/2021\/09\/grafik-1.png?resize=350%2C200&ssl=1 1x, https:\/\/i0.wp.com\/blog.mi.hdm-stuttgart.de\/wp-content\/uploads\/2021\/09\/grafik-1.png?resize=525%2C300&ssl=1 1.5x"},"classes":[]},{"id":28034,"url":"https:\/\/blog.mi.hdm-stuttgart.de\/index.php\/2025\/09\/12\/naniwa-not-actually-nutzlos-image-converter-with-aws\/","url_meta":{"origin":4290,"position":3},"title":"NANIWA &#8211; Not Actually Nutzlos Image-converter With AWS","author":"Kei Lam","date":"12. September 2025","format":false,"excerpt":"Introduction This is written as part of the assignment for Software Development for Cloud Computing. NANIWA, which stands for Not Actually Nutzlos Image-converter With AWS, or the name of the region which would become the city of Osaka today, is an image-conversion service hosted solely on Amazon Web Services. It\u2026","rel":"","context":"In &quot;Allgemein&quot;","block_context":{"text":"Allgemein","link":"https:\/\/blog.mi.hdm-stuttgart.de\/index.php\/category\/allgemein\/"},"img":{"alt_text":"","src":"https:\/\/i0.wp.com\/blog.mi.hdm-stuttgart.de\/wp-content\/uploads\/2025\/09\/image.png?resize=350%2C200&ssl=1","width":350,"height":200,"srcset":"https:\/\/i0.wp.com\/blog.mi.hdm-stuttgart.de\/wp-content\/uploads\/2025\/09\/image.png?resize=350%2C200&ssl=1 1x, https:\/\/i0.wp.com\/blog.mi.hdm-stuttgart.de\/wp-content\/uploads\/2025\/09\/image.png?resize=525%2C300&ssl=1 1.5x, https:\/\/i0.wp.com\/blog.mi.hdm-stuttgart.de\/wp-content\/uploads\/2025\/09\/image.png?resize=700%2C400&ssl=1 2x, https:\/\/i0.wp.com\/blog.mi.hdm-stuttgart.de\/wp-content\/uploads\/2025\/09\/image.png?resize=1050%2C600&ssl=1 3x"},"classes":[]},{"id":3788,"url":"https:\/\/blog.mi.hdm-stuttgart.de\/index.php\/2018\/07\/31\/building-a-fully-scalable-architecture-with-aws\/","url_meta":{"origin":4290,"position":4},"title":"Building a fully scalable architecture with\u00a0AWS","author":"Tim Grossmann","date":"31. July 2018","format":false,"excerpt":"What I learned in building the StateOfVeganism ? By now, we all know that news and media shape our viewson these discussed topics. Of course, this is different from person to person. Some might be influenced a little more than others, but there always is some opinion communicated. Considering this,\u2026","rel":"","context":"In &quot;Cloud Technologies&quot;","block_context":{"text":"Cloud Technologies","link":"https:\/\/blog.mi.hdm-stuttgart.de\/index.php\/category\/scalable-systems\/cloud-technologies\/"},"img":{"alt_text":"","src":"https:\/\/i0.wp.com\/blog.mi.hdm-stuttgart.de\/wp-content\/uploads\/2023\/08\/1fwRRc2V_eXU8mHyFk9n6Jw.png?resize=350%2C200&ssl=1","width":350,"height":200,"srcset":"https:\/\/i0.wp.com\/blog.mi.hdm-stuttgart.de\/wp-content\/uploads\/2023\/08\/1fwRRc2V_eXU8mHyFk9n6Jw.png?resize=350%2C200&ssl=1 1x, https:\/\/i0.wp.com\/blog.mi.hdm-stuttgart.de\/wp-content\/uploads\/2023\/08\/1fwRRc2V_eXU8mHyFk9n6Jw.png?resize=525%2C300&ssl=1 1.5x, https:\/\/i0.wp.com\/blog.mi.hdm-stuttgart.de\/wp-content\/uploads\/2023\/08\/1fwRRc2V_eXU8mHyFk9n6Jw.png?resize=700%2C400&ssl=1 2x, https:\/\/i0.wp.com\/blog.mi.hdm-stuttgart.de\/wp-content\/uploads\/2023\/08\/1fwRRc2V_eXU8mHyFk9n6Jw.png?resize=1050%2C600&ssl=1 3x, https:\/\/i0.wp.com\/blog.mi.hdm-stuttgart.de\/wp-content\/uploads\/2023\/08\/1fwRRc2V_eXU8mHyFk9n6Jw.png?resize=1400%2C800&ssl=1 4x"},"classes":[]},{"id":21683,"url":"https:\/\/blog.mi.hdm-stuttgart.de\/index.php\/2021\/09\/18\/ynstagram-cloud-computing-mit-aws-serverless\/","url_meta":{"origin":4290,"position":5},"title":"Ynstagram &#8211; Cloud Computing mit AWS &amp; Serverless","author":"ns144","date":"18. September 2021","format":false,"excerpt":"Im Rahmen der Vorlesung \u201cSoftware Development for Cloud Computing\u201d haben wir uns hinsichtlich des dortigen Semesterprojektes zum Ziel gesetzt einen einfachen Instagram Klon zu entwerfen um uns die Grundkenntnisse des Cloud Computings anzueignen. Grundkonzeption \/ Ziele des Projektes Da wir bereits einige Erfahrung mit React aufgrund anderer studentischer Projekte sammeln\u2026","rel":"","context":"In &quot;Cloud Technologies&quot;","block_context":{"text":"Cloud Technologies","link":"https:\/\/blog.mi.hdm-stuttgart.de\/index.php\/category\/scalable-systems\/cloud-technologies\/"},"img":{"alt_text":"","src":"https:\/\/i0.wp.com\/blog.mi.hdm-stuttgart.de\/wp-content\/uploads\/2021\/09\/Prasentation_CC_01.png?resize=350%2C200&ssl=1","width":350,"height":200,"srcset":"https:\/\/i0.wp.com\/blog.mi.hdm-stuttgart.de\/wp-content\/uploads\/2021\/09\/Prasentation_CC_01.png?resize=350%2C200&ssl=1 1x, https:\/\/i0.wp.com\/blog.mi.hdm-stuttgart.de\/wp-content\/uploads\/2021\/09\/Prasentation_CC_01.png?resize=525%2C300&ssl=1 1.5x, https:\/\/i0.wp.com\/blog.mi.hdm-stuttgart.de\/wp-content\/uploads\/2021\/09\/Prasentation_CC_01.png?resize=700%2C400&ssl=1 2x, https:\/\/i0.wp.com\/blog.mi.hdm-stuttgart.de\/wp-content\/uploads\/2021\/09\/Prasentation_CC_01.png?resize=1050%2C600&ssl=1 3x, https:\/\/i0.wp.com\/blog.mi.hdm-stuttgart.de\/wp-content\/uploads\/2021\/09\/Prasentation_CC_01.png?resize=1400%2C800&ssl=1 4x"},"classes":[]}],"jetpack_sharing_enabled":true,"authors":[{"term_id":772,"user_id":904,"is_guest":0,"slug":"ok043","display_name":"ok043","avatar_url":"https:\/\/secure.gravatar.com\/avatar\/1c6bc3c4e0e309be95209c3a325e4f371f4ead7c05613dba978bc08f6adad004?s=96&d=mm&r=g","0":null,"1":"","2":"","3":"","4":"","5":"","6":"","7":"","8":""}],"_links":{"self":[{"href":"https:\/\/blog.mi.hdm-stuttgart.de\/index.php\/wp-json\/wp\/v2\/posts\/4290","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/blog.mi.hdm-stuttgart.de\/index.php\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/blog.mi.hdm-stuttgart.de\/index.php\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/blog.mi.hdm-stuttgart.de\/index.php\/wp-json\/wp\/v2\/users\/904"}],"replies":[{"embeddable":true,"href":"https:\/\/blog.mi.hdm-stuttgart.de\/index.php\/wp-json\/wp\/v2\/comments?post=4290"}],"version-history":[{"count":5,"href":"https:\/\/blog.mi.hdm-stuttgart.de\/index.php\/wp-json\/wp\/v2\/posts\/4290\/revisions"}],"predecessor-version":[{"id":11473,"href":"https:\/\/blog.mi.hdm-stuttgart.de\/index.php\/wp-json\/wp\/v2\/posts\/4290\/revisions\/11473"}],"wp:attachment":[{"href":"https:\/\/blog.mi.hdm-stuttgart.de\/index.php\/wp-json\/wp\/v2\/media?parent=4290"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/blog.mi.hdm-stuttgart.de\/index.php\/wp-json\/wp\/v2\/categories?post=4290"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/blog.mi.hdm-stuttgart.de\/index.php\/wp-json\/wp\/v2\/tags?post=4290"},{"taxonomy":"author","embeddable":true,"href":"https:\/\/blog.mi.hdm-stuttgart.de\/index.php\/wp-json\/wp\/v2\/ppma_author?post=4290"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}