<?xml version="1.0" encoding="UTF-8"?><rss xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:atom="http://www.w3.org/2005/Atom" version="2.0" xmlns:cc="http://cyber.law.harvard.edu/rss/creativeCommonsRssModule.html">
    <channel>
        <title><![CDATA[Stories by A. Vatsaev on Medium]]></title>
        <description><![CDATA[Stories by A. Vatsaev on Medium]]></description>
        <link>https://medium.com/@avatsaev?source=rss-13ff76523e5d------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/1*_m6wSd0hmwZISQ_QTM4Lhw.jpeg</url>
            <title>Stories by A. Vatsaev on Medium</title>
            <link>https://medium.com/@avatsaev?source=rss-13ff76523e5d------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Thu, 03 Dec 2026 21:34:46 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@avatsaev/feed" rel="self" type="application/rss+xml"/>
        <webMaster><![CDATA[yourfriends@medium.com]]></webMaster>
        <atom:link href="http://medium.superfeedr.com/" rel="hub"/>
        <item>
            <title><![CDATA[Create efficient Angular Docker images with Multi Stage Builds]]></title>
            <link>https://medium.com/@avatsaev/create-efficient-angular-docker-images-with-multi-stage-builds-907e2be3008d?source=rss-13ff76523e5d------2</link>
            <guid isPermaLink="false">https://medium.com/p/907e2be3008d</guid>
            <category><![CDATA[angular]]></category>
            <category><![CDATA[docker]]></category>
            <dc:creator><![CDATA[A. Vatsaev]]></dc:creator>
            <pubDate>Sun, 16 Jul 2017 23:39:04 GMT</pubDate>
            <atom:updated>2018-11-13T19:38:39.423Z</atom:updated>
            <content:encoded><![CDATA[<blockquote>In this write up we’ll see how to dockerize an Angular app in an efficient manner with Docker’s Multi-Stage Builds.</blockquote><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*GeGazytoczNAQSsPb-gHSw.png" /></figure><h4>Prerequisites</h4><ul><li>NodeJS +6.9</li><li>Angular CLI (<em>npm i -g @angular/cli@latest</em>)</li><li>Docker 17.05</li><li>Basic understanding of Docker and Angular CLI commands</li></ul><h4>The plan</h4><p>To Dockerize a basic Angular app built with Angular CLI we need to do the following:</p><ol><li>npm install the dependencies (Dev dependencies included)</li><li>ng build with --prod flag</li><li>move the artifacts from dist folder to a publicly accessible folder (via an an nginx server)</li><li>Setup an an nginx config file, and spin up the http server</li></ol><p><strong>We’ll do this in 2 stages:</strong></p><ol><li>Build stage: will depend on a Node alpine Docker image</li><li>Setup Stage: will depend on NGINX alpine Docker image and use the artifacts from the build stage, and the nginx config from our project.</li></ol><h4>Initialize an empty Angular project</h4><p>$ ng new myapp</p><h4>Add a default nginx config</h4><p>At the root of your angular project create nginx folder and create a file named default.conf with the following contents (./nginx/default.conf):</p><pre>server {<br><br>  listen 80;<br><br>  sendfile on;<br><br>  default_type application/octet-stream;<br><br><br>  gzip on;<br>  gzip_http_version 1.1;<br>  gzip_disable      &quot;MSIE [1-6]\.&quot;;<br>  gzip_min_length   1100;<br>  gzip_vary         on;<br>  gzip_proxied      expired no-cache no-store private auth;<br>  gzip_types        text/plain text/css application/json application/javascript application/x-javascript text/xml application/xml application/xml+rss text/javascript;<br>  gzip_comp_level   9;<br><br><br>  root /usr/share/nginx/html;<br><br><br>  location / {<br>    try_files $uri $uri/ /index.html =404;<br>  }<br><br>}</pre><h4>Create the Docker file</h4><pre>### STAGE 1: Build ###<br><br># We label our stage as ‘builder’<br><strong>FROM </strong>node:10<strong>-</strong>alpine as builder<br><br><strong>COPY </strong>package.json package-lock.json ./<br><br>## Storing node modules on a separate layer will prevent unnecessary npm installs at each build<br><strong>RUN </strong>npm i <strong>&amp;&amp; </strong>mkdir <strong>/</strong>ng-app <strong>&amp;&amp; </strong>mv .<strong>/</strong>node_modules .<strong>/</strong>ng-app<br><br><strong>WORKDIR /</strong>ng-app<br><br><strong>COPY </strong>. .<br><br>## Build the angular app in production mode and store the artifacts in dist folder<br><strong>RUN </strong>$(npm bin)<strong>/</strong>ng build <strong>--</strong>prod --output-path=dist<br><br><br>### STAGE 2: Setup ###<br><br><strong>FROM </strong>nginx:1.14.1<strong>-</strong>alpine<br><br>## Copy our default nginx config<br><strong>COPY </strong>nginx<strong>/</strong>default.conf <strong>/</strong>etc<strong>/</strong>nginx<strong>/</strong>conf.d<strong>/<br><br></strong>## Remove default nginx website<br><strong>RUN </strong>rm <strong>-</strong>rf <strong>/</strong>usr<strong>/</strong>share<strong>/</strong>nginx<strong>/</strong>html<strong>/*<br><br></strong>## From ‘builder’ stage copy over the artifacts in dist folder to default nginx public folder<br><strong>COPY --</strong>from=builder <strong>/</strong>ng-app<strong>/</strong>dist<strong> /</strong>usr<strong>/</strong>share<strong>/</strong>nginx<strong>/</strong>html<strong><br><br>CMD </strong>[&quot;nginx&quot;, &quot;-g&quot;, &quot;daemon off;&quot;]</pre><h4>Build the image</h4><pre>$ docker build -t myapp .</pre><h4>Run the container</h4><pre>$ docker run -p 8080:80 myapp</pre><p>And done, your dockerized app will be accessible at <a href="http://localhost:8080/">http://localhost:8080</a></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/978/1*CqjGyFrui6XgC6YSCG-HDg.png" /></figure><p>And the size of the image is only 15.8MB, which will be even less once pushed to a Docker repository.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*K9tWnozvSVTI2RQq9YXyBA.png" /></figure><blockquote><strong>You can see a full example in this GitHub repository: </strong><a href="https://github.com/avatsaev/angular-contacts-app-example"><strong>https://github.com/avatsaev/angular-contacts-app-example</strong></a></blockquote><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=907e2be3008d" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Angular 2+ and Ruby on Rails user authentication Part 4]]></title>
            <link>https://medium.com/hackernoon/angular-2-and-ruby-on-rails-user-authentication-part-4-49d550c5869a?source=rss-13ff76523e5d------2</link>
            <guid isPermaLink="false">https://medium.com/p/49d550c5869a</guid>
            <category><![CDATA[angularjs]]></category>
            <category><![CDATA[router]]></category>
            <category><![CDATA[javascript]]></category>
            <category><![CDATA[angular]]></category>
            <dc:creator><![CDATA[A. Vatsaev]]></dc:creator>
            <pubDate>Thu, 02 Mar 2017 23:26:32 GMT</pubDate>
            <atom:updated>2019-04-22T11:11:54.829Z</atom:updated>
            <content:encoded><![CDATA[<h4>This article is the follow up of <a href="https://medium.com/@avatsaev/angular-2-and-ruby-on-rails-user-authentication-fde230ddaed8#.tfr6zstyp">Angular 2+ and Ruby on Rails user authentication Part 1: Backend</a></h4><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*EVCbusTvl_CBlfa96EhvYg.png" /></figure><h3>User Profile, Auth Service and Auth Router Guard</h3><h3>Intro</h3><p>The premise is to show user profile info (name, nickname, email, etc) on <strong>/profile</strong> route and make a guard for it, so when someone tries to reach it without being authenticated, gets redirected to <strong>home</strong> route, we’ll also write an <strong>Auth Service</strong> to wrap all of our auth related stuff in one place.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/888/1*NMOpRPtOi4yOwLTSxL2i7g.png" /></figure><h3>Auth Service</h3><p>First and foremost, we need to create an<strong> Authetication Service</strong> which will wrap all of Auth related states and actions in one place, in particular <strong>login/logout actions</strong> and user <strong>authentication status</strong> (user is logged in/out), and all off it<strong> asynchronously as a stream </strong>(brace yourselves RxJS is incoming)<strong>.</strong></p><pre>ng g s services/auth</pre><blockquote>s = service</blockquote><p>This is our authentication service (<strong>./src/app/services/auth.service.ts</strong>):</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/8be2e491c433d1294ea9c84b10df9828/href">https://medium.com/media/8be2e491c433d1294ea9c84b10df9828/href</a></iframe><p>Looks intimidating at first glance, but trust me, there is nothing complicated, so let’s break it down:</p><p><strong>Line 9: </strong>userSignedIn$ is a <a href="https://github.com/Reactive-Extensions/RxJS/blob/master/doc/gettingstarted/subjects.md"><strong>RxJs Subject</strong></a> (of type boolean), which means it is an<strong> Observer</strong> and an <strong>Observable</strong> at the same time, which means we can control its value in our service, and observe its changes outside of it.</p><p>Our constructor will initialize the login state by using TokenService’s<strong> validateToken() </strong>method, which will validate current token (if exists) against the Rails backend, this operation is asynchronous and returns in its body an object that looks like this:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/574/1*HKYlNO7aQ4lpYDpKzt9x9A.png" /></figure><p>So we can use <strong><em>success</em></strong> key to determine wether the user is logged in with a valid token or not (line 14).</p><p><em>Dollar sign ($) at the end of the name is a convention to specify that this is not a simple variable, but an observable stream of data which changes in time.</em></p><ul><li>Our <strong>logOutUser()</strong> method takes no params and returns an <strong>Observable of Response</strong>, we’ll call <strong>signOut()</strong> on <strong>Angular2TokenService</strong>, but before returning its response, we’ll map though it to change <strong>userSignedIn$</strong> value to <strong>false </strong>(line 19)<strong> </strong>in order<strong> </strong>to notify our observers that user successfully logged out, and then return the response to whomever is observing the result of <strong>logOutUser() </strong>method<strong> </strong>(line 20).</li><li>The<strong> logInUser</strong> method takes an object with email and password keys, and uses it to sign in from Angular2TokenService signIn() method. And again, before returning the response we will modify <strong>userSignedIn$ </strong>value to<strong> true,</strong> which will notify the observers that user logged in successfully<strong>.</strong></li><li>The<strong> registerUser</strong> method is similar to loginUser, but we have an additional password confirmation attribute in the input object.</li></ul><p>Let’s not forget to inject it into our main AppModule’s providers (<strong>./src/app/app.module.ts</strong>):</p><pre>...</pre><pre><strong>import {AuthService} from &quot;./services/auth.service&quot;;</strong></pre><pre>@NgModule({<br>  declarations: [<br>    AppComponent,<br>    HomeComponent,<br>    ToolbarComponent,<br>    AuthDialogComponent,<br>    LoginFormComponent,<br>    RegisterFormComponent,<br>    ProfileComponent<br>  ],<br>  imports: [<br>    BrowserModule,<br>    FormsModule,<br>    HttpModule,<br>    AppRoutingModule,<br>    MaterializeModule,<br>  ],<br>  providers: [ Angular2TokenService, <strong>AuthService</strong>],<br>  bootstrap: [AppComponent]<br>})<br>export class AppModule { }</pre><h3>Refactoring Login and Toolbar components to use AuthService</h3><p>Now we need to make some small changes to our <strong>Login</strong> and <strong>Toolbar</strong> components in order to use AuthService instead of Angular2TokenService directly.</p><h4>Refactoring the Toolbar</h4><p>Let’s start with ToolBarComponent class (<strong>./src/app/toolbar/toolbar.component.ts</strong>):</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/45dffad3fc40cadf2c291b0e1dd3d259/href">https://medium.com/media/45dffad3fc40cadf2c291b0e1dd3d259/href</a></iframe><p>As you can see, we got rid of <strong>Angular2TokenService</strong> and injected our custom <strong>AuthService</strong> instead (line 16), we also created a <strong>logOut()</strong> method which will call <strong>logOutUser</strong> action on our <strong>AuthService</strong>, and using Angular Router, redirect the user to <strong>home</strong> when logout action completes (line 21).</p><p>Now let’s change Toolbar’s template (<strong>./src/app/toolbar/toolbar.component.html</strong>):</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/f2325c25565c7bd7d8b68189d4ecf166/href">https://medium.com/media/f2325c25565c7bd7d8b68189d4ecf166/href</a></iframe><p>Now we are using our AuthService’s <strong>userSignedIn$ </strong>Subject to change the state of the toolbar when user logs in or out, considering that <strong>userSignedIn$ </strong>is not a simple value, but an asynchrnous stream of values chaning in time, we need to use Angular’s async pipe to listen to its changes (lines 11, 12, 14, 15). We’ll also link the click event on <strong>logout button</strong> to toobar component’s <strong>logOut()</strong> method we created earlier (line 15).</p><h4>Refactoring the Login From</h4><p>Changes on login form will be extremely minimal, we just need to change the LoginFormComponent class (<strong>./src/app/login-form/login-form.component.ts</strong>)</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/1ae77ae7f3f8e28891252f8d6f98c8c3/href">https://medium.com/media/1ae77ae7f3f8e28891252f8d6f98c8c3/href</a></iframe><p>The only thing we needed to do is getting rid of <strong>Angular2TokenService</strong> and replacing it with our <strong>AuthService </strong>and its<strong> logInUser </strong>method.</p><blockquote><strong>Don’t forget to apply the same changes to RegisterFormComponent</strong></blockquote><p>And that’s it, refactoring is over.</p><h3>User profile page</h3><h4>Profile component</h4><p>First step is obvious, let’s generate our <strong>ProfileComponent</strong> that will display current user’s info:</p><pre>ng g c profile</pre><p>The component should be automatically imported in AppModule’s declarations.</p><h4>Profile route</h4><p>In our router module (<strong>./src/app/app-routing.module.ts</strong>), let’s declare the profile route:</p><p>Import the profile component:</p><pre>import {ProfileComponent} from &quot;./profile/profile.component&quot;;</pre><p>Declare the route:</p><pre>...</pre><pre>const routes: Routes = [<br>  {<br>    path: &#39;&#39;,<br>    component: HomeComponent,<br>    pathMatch: &#39;full&#39;<br>  },<br>  {<br>    path: &#39;home&#39;,<br>    component: HomeComponent<br>  },<br>  <strong>{<br>    path: &#39;profile&#39;,<br>    component: ProfileComponent<br>  }</strong><br>];<br>...</pre><h4>UI</h4><p>As for the design of profile page, it’ll be pretty simple, we’ll display user’s email, name, and user name in a <a href="http://materializecss.com/cards.html">Materialize Card</a> and use its footer to add a logout button.</p><p>Let’s inject Angular2TokenService into our ProfileComponent, and add a logout method (<strong>./app/profile/profile.component.ts</strong>):</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/bc8de497a4ff4fc251ae08241dd41d44/href">https://medium.com/media/bc8de497a4ff4fc251ae08241dd41d44/href</a></iframe><p>We’ll be making use of <strong>Angular2TokenService</strong> to display user’s personal information, <strong>AuthService</strong> to implment the logout action, and the <strong>Router</strong> to redirect after logout completes, so we need to inject these in our <strong>ProfileComponent</strong> (lines 14–16)</p><p>Nn line 18, we have a <strong>logOut</strong> action which redirects the user to home when it completes.</p><blockquote>Reimplementing the <strong>logOut</strong> action for each component seems repetitive, but this is actually useful, because we can implement different post-logout behaviours for each component, for example redirecting to some other route instead of home.</blockquote><p>Profile Component’s template, (<strong>./src/app/profile/profile.component.html)</strong></p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/57d95d5782deb08c7d8e89dfd5160505/href">https://medium.com/media/57d95d5782deb08c7d8e89dfd5160505/href</a></iframe><p>Angular2TokenService’s <strong>currentUserData</strong> attribute provides information about our user if he is logged in (email, name, nickname, etc.), its value is <em>undefined</em> when user is not logged in.</p><p>One line 15, we are usign <strong>*ngIf</strong> structural directive to test if there is any data to display, if not we will not show the user info card.</p><p>On line 31 we also have a logout button, linked to <strong>logOut</strong> method of our <strong>ProfileComponent</strong> class.</p><p>Be sure to add a cleafix class to <strong>./src/app/profile/profile.component.sass </strong>because Materialize doesn’t implement it.</p><pre>.clearfix<br>  overflow: auto</pre><p>And this is what we get when we navigate to <strong>/profile </strong>route while being logged in:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*pDmxaMm2I8SgV3bIF43c1A.png" /><figcaption>User info card</figcaption></figure><h3>Auth Route Guard</h3><p>Now the problem is, we still can navigate to <strong>/profile</strong> route even if we are not logged in:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*GCWmvl9VD9jX20MjJqAuMg.png" /></figure><p>Angular’s Route Guards can help us to fix this issue.</p><p>Route Guards are pretty easy to understand, it’s a simple class which implements <strong>CanActivate</strong> interface, this interface demands us to implement a <strong>canActivate() </strong>method<strong>, </strong>which returns a single boolean value (<em>or an Observable of type boolean, although I couldn’t manage to make them work properly</em>), and depending on that boolean value the Router will allow or forbid the activation of a route, the logic is up to us to implement, so let’s do that.</p><p>Create an AuthGuard class in (<strong>./src/app/guards/auth.guard.ts</strong>):</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/5af9c906584d2fc01714fefbdff66115/href">https://medium.com/media/5af9c906584d2fc01714fefbdff66115/href</a></iframe><p>As you can see, our AuthGuard class implements <strong>CanActivate</strong> interface and its <strong>canActivate()</strong> method, the logic is simple, Angular2TokenService’s userSignedIn() method returns a signle boolean value, we’ll use it to determine if user is signed in, if so, we allow the activation by returning true, of not, we’ll redirect to home and forbid the activation by returning false.</p><p>Don’t forget to inject it in our AppModule’s providers:</p><pre>...</pre><pre><strong>import {AuthGuard} from &quot;./guards/auth.guard&quot;;</strong><br><br>@NgModule({<br>  declarations: [<br>    AppComponent,<br>    HomeComponent,<br>    ToolbarComponent,<br>    AuthDialogComponent,<br>    LoginFormComponent,<br>    RegisterFormComponent,<br>    ProfileComponent<br>  ],<br>  imports: [<br>    BrowserModule,<br>    FormsModule,<br>    HttpModule,<br>    AppRoutingModule,<br>    MaterializeModule,<br>  ],<br>  providers: [ Angular2TokenService, AuthService, <strong>AuthGuard</strong>],<br>  bootstrap: [AppComponent]<br>})<br>export class AppModule { }</pre><p>Now let’s protect our <strong>/profile </strong>route, open <strong>./src/app/app-routing.module.ts </strong>and set profile route’s guard:</p><pre>import { NgModule } from &#39;@angular/core&#39;;<br>import { Routes, RouterModule } from &#39;@angular/router&#39;;<br>import {HomeComponent} from &quot;./home/home.component&quot;;<br>import {ProfileComponent} from &quot;./profile/profile.component&quot;;<br>import {AuthGuard} from &quot;./guards/auth.guard&quot;;<br><br>const routes: Routes = [<br>  {<br>    path: &#39;&#39;,<br>    component: HomeComponent,<br>    pathMatch: &#39;full&#39;<br>  },<br>  {<br>    path: &#39;home&#39;,<br>    component: HomeComponent<br>  },<br>  {<br>    path: &#39;profile&#39;,<br>    component: ProfileComponent,<br>    <strong>canActivate: [AuthGuard]</strong><br>  }<br>];<br><br>@NgModule({<br>  imports: [RouterModule.forRoot(routes)],<br>  exports: [RouterModule],<br>  providers: []<br>})<br><br>export class AppRoutingModule { }</pre><p><strong>canActivate</strong> key takes an array of guards, in case you have several guards on a single route, all of them must return <strong>true</strong> in order for the route to be activated.</p><p>Now, when we go to <strong>/profile</strong> without being logged in, we’ll get redirected to home, and any Router Link with /profile as a route, will produce no effect when clicked on.</p><p>And there you go, a profile page, protected by a Route Guard.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1000/1*Bn_fyEwreT7EN18bkp7tqw.gif" /></figure><blockquote>You can get the final code for this part on GitHub: <a href="https://github.com/avatsaev/angular-token-auth-seed/tree/profile"><strong>https://github.com/avatsaev/angular-token-auth-seed/tree/profile</strong></a></blockquote><p>Let me know if you have any remarks about the tutorial, I’ll be happy to help and correct it if something isn’t clear enough :)</p><blockquote>Thank you for reading this series, follow me on Twitter (<a href="https://twitter.com/avatsaev">https://twitter.com/avatsaev</a>) for more interesting stuff on Angular 2+ and Rails.</blockquote><figure><a href="http://bit.ly/HackernoonFB"><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*0hqOaABQ7XGPT-OYNgiUBg.png" /></a></figure><figure><a href="https://goo.gl/k7XYbx"><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*Vgw1jkA6hgnvwzTsfMlnpg.png" /></a></figure><figure><a href="https://goo.gl/4ofytp"><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*gKBpq1ruUi0FVK2UM_I4tQ.png" /></a></figure><blockquote><a href="http://bit.ly/Hackernoon">Hacker Noon</a> is how hackers start their afternoons. We’re a part of the <a href="http://bit.ly/atAMIatAMI">@AMI</a> family. We are now <a href="http://bit.ly/hackernoonsubmission">accepting submissions</a> and happy to <a href="/service/mailto:partners@amipublications.com">discuss advertising &amp; sponsorship</a> opportunities.</blockquote><blockquote>If you enjoyed this story, we recommend reading our <a href="http://bit.ly/hackernoonlatestt">latest tech stories</a> and <a href="https://hackernoon.com/trending">trending tech stories</a>. Until next time, don’t take the realities of the world for granted!</blockquote><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*35tCjoPcvq6LbB3I6Wegqw.jpeg" /></figure><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=49d550c5869a" width="1" height="1" alt=""><hr><p><a href="https://medium.com/hackernoon/angular-2-and-ruby-on-rails-user-authentication-part-4-49d550c5869a">Angular 2+ and Ruby on Rails user authentication Part 4</a> was originally published in <a href="https://medium.com/hackernoon">HackerNoon.com</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Check if a domain name is affected by CloudBleed]]></title>
            <link>https://medium.com/@avatsaev/check-if-a-domain-name-is-affected-by-cloudbleed-e9bb928ca30?source=rss-13ff76523e5d------2</link>
            <guid isPermaLink="false">https://medium.com/p/e9bb928ca30</guid>
            <category><![CDATA[cloudbleed]]></category>
            <category><![CDATA[cloudflare]]></category>
            <dc:creator><![CDATA[A. Vatsaev]]></dc:creator>
            <pubDate>Fri, 24 Feb 2017 17:04:58 GMT</pubDate>
            <atom:updated>2017-02-24T17:05:39.768Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*FjSy6MtoU319GgytvSHZFA.png" /></figure><p><a href="http://cloudbleedcheck.com/"><strong>http://cloudbleedcheck.com</strong></a> is an online tool that allows you to check if a domain name is affected by recent <a href="http://www.csoonline.com/article/3173639/security/bleeding-clouds-cloudflare-server-errors-blamed-for-leaked-customer-data.html">CloudBleed bug</a>.</p><p>If a service you use is affected by CloudBleed, I recomment to logout from all active sessions, change your passwords, and enable 2FA.</p><blockquote>Source code of this tool is available on GitHub: <a href="https://github.com/avatsaev/cloudbleedcheck">https://github.com/avatsaev/cloudbleedcheck</a></blockquote><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=e9bb928ca30" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Angular 2+ and Ruby on Rails user authentication Part 3]]></title>
            <link>https://medium.com/hackernoon/angular-2-and-ruby-on-rails-user-authentication-part-3-d938fcb7a334?source=rss-13ff76523e5d------2</link>
            <guid isPermaLink="false">https://medium.com/p/d938fcb7a334</guid>
            <category><![CDATA[javascript]]></category>
            <category><![CDATA[rails]]></category>
            <category><![CDATA[angular]]></category>
            <category><![CDATA[angular2]]></category>
            <dc:creator><![CDATA[A. Vatsaev]]></dc:creator>
            <pubDate>Sun, 12 Feb 2017 18:11:33 GMT</pubDate>
            <atom:updated>2019-04-22T11:10:43.487Z</atom:updated>
            <content:encoded><![CDATA[<h4>This article is the follow up of <a href="https://medium.com/@avatsaev/angular-2-and-ruby-on-rails-user-authentication-fde230ddaed8#.p1u4kqz5e">Angular 2+ and Ruby on Rails user authentication</a></h4><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*EVCbusTvl_CBlfa96EhvYg.png" /></figure><h3>App Architecture</h3><h4>Components</h4><ul><li><em>Home component (Welcome Page)</em></li><li><em>Toolbar component</em></li><li><em>Auth dialog component</em></li><li><em>Login from component</em></li><li><em>Register form component</em></li><li><em>Profile component</em></li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*HqBWKwqRXK500Qy_uVbvFg.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*HXHkx2qwrdUD7RHfuw6Jzw.png" /></figure><p>Separating Login and Register forms into different components is useful, because we can reuse them in other pages if needed (for example dedicated login and register pages without a dialog)</p><h4>Routes</h4><ul><li><em>Home route</em></li><li><em>Profile route</em></li></ul><h4>Route Guards</h4><ul><li><em>Profile route guard</em>: will check if user is logged in, if not, will redirect to home</li></ul><h4>Services</h4><ul><li><em>TokenAuthService</em>: will manage login, register, logout, user profile data, verify token authenticity, and check wether the user is logged in or not</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/888/1*NMOpRPtOi4yOwLTSxL2i7g.png" /></figure><h3>Home Component and Home Route</h3><p>Let’s start by generating our first component, Home, with Angular CLI:</p><pre>$ ng g c home</pre><blockquote>g = generate and c = component</blockquote><p>This will create ./src/app/<strong>home </strong>folder with home component class, its template and stylesheet, Angular CLI will also add it to Main App Module’s declarations array automatically.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*MzzSc0ENTvJ8z46rXwojhg.png" /></figure><p>Now we need to create a route for it, open <strong>./src/app/app-routing.module.ts</strong></p><p>Import the HomeComponent:</p><pre>import {HomeComponent} from &quot;./home/home.component&quot;;</pre><p>and add home route to routes array:</p><pre>const routes: Routes = [<br>  {<br>    path: &#39;&#39;,<br>    children: []<br>  },<br>  <strong>{<br>    path: &#39;home&#39;,<br>    component: HomeComponent<br>  }</strong><br>];</pre><p>We’ll also make it the default route:</p><pre>const routes: Routes = [<br>  {<br>    path: &#39;&#39;,<br>    component: HomeComponent,<br>    pathMatch: &#39;full&#39;<br>  },<br>  {<br>    path: &#39;home&#39;,<br>    component: HomeComponent<br>  }<br>];</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/748/1*Uv6b_YMLmM4n_QUIzcF_fw.png" /></figure><p>Now if we go to <a href="http://localhost:4200/">http://localhost:4200</a> HomeComponent will be displayed by default</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/806/1*RuYrI2Bf0NsPzUEFd3HtlQ.png" /></figure><h3>Toolbar Component</h3><p>Same procedure for Toolbar Component:</p><pre>$ ng g c toolbar</pre><p>Setup toolbar’s html template:</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/6b8d1e863647836a2aaa42554d99f33c/href">https://medium.com/media/6b8d1e863647836a2aaa42554d99f33c/href</a></iframe><p>For now we’ll display all actions, we’ll implement the conditional state later.</p><p>Change <strong>./src/app/home/home.component.html</strong> to something more appealing:</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/f9fd1e46a44249d823803ab493396689/href">https://medium.com/media/f9fd1e46a44249d823803ab493396689/href</a></iframe><p>Edit <strong>./src/app/app.component.html</strong> as follows to display our toolbar and wrap the router outlet in <em>container</em> class:</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/350508a6c12740732b1fdc022c751738/href">https://medium.com/media/350508a6c12740732b1fdc022c751738/href</a></iframe><p>And here’s what we get so far:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*5pqNQB9cRAaGL_f7bCEGUA.png" /></figure><h3><strong>Auth Dialog</strong></h3><p>Now we need to create the <strong>AuthDialogComponent</strong> which will display Login/Register forms:</p><pre>$ ng g c auth-dialog</pre><p>Let’s edit the AuthDialogComponent file in <strong>./src/app/auth-dialog/auth-dialog.component.ts</strong></p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/d8b66107c9da7732a77b3bd056dad279/href">https://medium.com/media/d8b66107c9da7732a77b3bd056dad279/href</a></iframe><p>Auth Dialog Component will have an <strong>Input</strong> decorator (line 11) <strong>authMode</strong>, it takes 2 possible values, ‘login’ or ‘register’, this will allow us to pick the initial form to display when the dialog shows up (login or register form). The default value of this input is ‘login’.</p><p><strong>modalActions </strong>(line 12)<strong> </strong>is an event emitter, required by Materialize Dialog Directive, we’ll emit events on it to open or close our dialog.</p><p><strong>openDialog</strong> (line 18) method takes a <strong>mode</strong> as its parameter, will set the current auth mode and display the dialog, if no parameter is passed, login will be the default.</p><p><strong>isLoginMode</strong> and <strong>isRegisterMode </strong>methods<strong> </strong>will help us to display the login or register forms conditionally.</p><p>Edit this dialog’s template, <strong>./src/app/auth-dialog/auth-dialog.component.html</strong>:</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/153946f074fe2c6956aec2fafc229009/href">https://medium.com/media/153946f074fe2c6956aec2fafc229009/href</a></iframe><p>On line 2, we are using <strong>materialize modal directive</strong>, and passing <strong>modalActions</strong> event emitter for its <strong>materializeActions</strong> input to be able to control the dialog by emitting events on it.</p><p>For now all this dialog is displaying is its current mode on line 17, and the ability to switch modes on lines 23 and 26. The <strong>*ngIf</strong> structural directive takes a boolean expression, if the expression is <em>true</em>, it will display the node, or hide it otherwise (remove it from the DOM).</p><p>Let’s display this dialog when we click on register or login actions in the toolbar.</p><p>In<strong> ./src/app/toolbar/toolbar.component.html</strong> include the auth-dialog component, and create click events on Login and Register actions to open the Auth Dialog:</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/56d8cac4a1736a467d0118498e846768/href">https://medium.com/media/56d8cac4a1736a467d0118498e846768/href</a></iframe><p><strong>#authDialog </strong>(line 24)<strong> </strong>is a reference to the AuthDialogComponent of our ToolbarComponent view, it will allow us to access the AuthDialogComponent class from the ToolbarComponent class.</p><p><strong>./src/app/toolbar/toolbar.component.ts:</strong></p><pre>import {Component, OnInit, <strong>ViewChild</strong>} from &#39;@angular/core&#39;;<br><strong>import {AuthDialogComponent} from &quot;../auth-dialog/auth-dialog.component&quot;;</strong><br><br>@Component({<br>  selector: &#39;app-toolbar&#39;,<br>  templateUrl: &#39;./toolbar.component.html&#39;,<br>  styleUrls: [&#39;./toolbar.component.sass&#39;]<br>})<br>export class ToolbarComponent implements OnInit {<br><br>  <strong>@ViewChild(&#39;authDialog&#39;) authDialog: AuthDialogComponent;</strong><br><br>  constructor() { }<br><br>  ngOnInit() {<br>  }<br><br><strong>  presentAuthDialog(mode?: &#39;login&#39;| &#39;register&#39;){<br>    this.authDialog.openDialog(mode);<br>  }</strong><br><br>}</pre><p><strong>ViewChild</strong> decorator will reference the <strong>AuthDialogComponent</strong> from our template so we can access its methods and attributes directly from our <strong>ToolbarComponent</strong> class.</p><p><strong>presentAuthDialog</strong> method takes an <strong>optional </strong><em>mode</em> parameter<strong> (notice the question mark)</strong>, AuthDialogComponenet’s <strong>openDialog</strong> method defaults the mode to ‘login’, so if we want to open the login dialog, we can just call <strong>presentAuthDialog() </strong>without any params.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*oe7U0kGBduoKGnjupW1aZw.png" /></figure><p>So this is what we get for the Auth Dialog so far:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1000/1*fwDLU3tGdFkPkZF1IRPYRw.gif" /></figure><p>We’ll use the <strong>Token Service</strong> to display the correct actions in the toolbar depending on wether or not the user is authenticated, for that, we can use <a href="https://github.com/neroniaky/angular2-token#usersignedin"><strong>the userSignedIn() method</strong></a><strong> </strong>which returns true of the user is logged in.</p><p>Import and inject <strong>Angular2TokenService</strong> into our <strong>ToolbarComponent</strong>:</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/26e62ba650ecf607ef7d745f985bef14/href">https://medium.com/media/26e62ba650ecf607ef7d745f985bef14/href</a></iframe><p>Now we can use it on our toolbar template to hide/show actions conditionally, we’ll also attach the <strong>signOut</strong> method to its action:</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/07c4ccda4265cbac30f9bf8cb29bfba0/href">https://medium.com/media/07c4ccda4265cbac30f9bf8cb29bfba0/href</a></iframe><h3>Login &amp; Register forms</h3><p>We’re almost finished. Let’s generate login and register form components.</p><pre>$ ng g c login-form</pre><pre>$ ng g c register-form</pre><h4>Login form template</h4><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/13cf71319054450c487e71d9cf22d869/href">https://medium.com/media/13cf71319054450c487e71d9cf22d869/href</a></iframe><p>We have two text inputs (email &amp; password) both of which are required for form to have a valid state. We are using Angular’s two way data binding on line 12 and 24 to bind the input values to signInUser object in our component class, which means the values will be updated when they are modified in the HTML form by the user, and also updated in the view if they are modified programatically in the component class.</p><p>Submit button (line 31) will be in disabled state unless the form becomes valid (line 32).</p><h4>Login form component</h4><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/9f7a3725e6ee97dcf636ce40c1141521/href">https://medium.com/media/9f7a3725e6ee97dcf636ce40c1141521/href</a></iframe><p>Login form will have an output <strong>onFormResult </strong>(line 16), which is an event fired when login request completes, so the parent components can listen and act on it.</p><p>We’ll inject the <strong>Token Service</strong> into our component (line 17) and use its <strong>signIn </strong>method when the form is submitted. When the login action completes, we’ll emit an event on <strong>onFormResult</strong> output, with a payload containing the result (lines 31 and 37), this will notify the parent components.</p><h4>Register form template</h4><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/04982eae2c25a15788d0c334fd453777/href">https://medium.com/media/04982eae2c25a15788d0c334fd453777/href</a></iframe><p>Pretty similar to login from, but have have an additional password confirmation text field and its validation.</p><h4>Register form component</h4><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/da46863d4cb13cd54be9d174090d6ad0/href">https://medium.com/media/da46863d4cb13cd54be9d174090d6ad0/href</a></iframe><p>Similar to login form, register form has an Output event emitter, <strong>onFormResult</strong>, that fires when register request completes.</p><h4>Hooking up the outputs in auth dialog</h4><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/ea40e7f5fbbd8a66039b7a931b487c19/href">https://medium.com/media/ea40e7f5fbbd8a66039b7a931b487c19/href</a></iframe><p>In the auth dialog component class, create the event handlers for <strong>onFormResult</strong> events emitted by <strong>login</strong> and <strong>register</strong> form components, if the the login/register was successful, close the dialog, otherwise display the error returned by our RoR server in an alert window:</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/390fe33e4c9eb5e10e2b46c9f6d5d9d3/href">https://medium.com/media/390fe33e4c9eb5e10e2b46c9f6d5d9d3/href</a></iframe><h4>Final Auth Dialog</h4><p>Notice the toolbar actions updating their state automatically when user logs in and out.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1000/1*nEqOfQzwmVXIVdNmCS-B7g.gif" /></figure><blockquote>Final source code for this part is available on Github: <a href="https://github.com/avatsaev/angular-token-auth-seed/tree/final">https://github.com/avatsaev/angular-token-auth-seed/tree/final</a></blockquote><p><a href="https://medium.com/@avatsaev/angular-2-and-ruby-on-rails-user-authentication-part-4-49d550c5869a#.bpxr54ano"><strong>Part 4: User Profile, Auth Service and Auth Router Guard.</strong></a></p><figure><a href="http://bit.ly/HackernoonFB"><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*0hqOaABQ7XGPT-OYNgiUBg.png" /></a></figure><figure><a href="https://goo.gl/k7XYbx"><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*Vgw1jkA6hgnvwzTsfMlnpg.png" /></a></figure><figure><a href="https://goo.gl/4ofytp"><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*gKBpq1ruUi0FVK2UM_I4tQ.png" /></a></figure><blockquote><a href="http://bit.ly/Hackernoon">Hacker Noon</a> is how hackers start their afternoons. We’re a part of the <a href="http://bit.ly/atAMIatAMI">@AMI</a> family. We are now <a href="http://bit.ly/hackernoonsubmission">accepting submissions</a> and happy to <a href="/service/mailto:partners@amipublications.com">discuss advertising &amp; sponsorship</a> opportunities.</blockquote><blockquote>If you enjoyed this story, we recommend reading our <a href="http://bit.ly/hackernoonlatestt">latest tech stories</a> and <a href="https://hackernoon.com/trending">trending tech stories</a>. Until next time, don’t take the realities of the world for granted!</blockquote><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*35tCjoPcvq6LbB3I6Wegqw.jpeg" /></figure><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=d938fcb7a334" width="1" height="1" alt=""><hr><p><a href="https://medium.com/hackernoon/angular-2-and-ruby-on-rails-user-authentication-part-3-d938fcb7a334">Angular 2+ and Ruby on Rails user authentication Part 3</a> was originally published in <a href="https://medium.com/hackernoon">HackerNoon.com</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Angular 2+ and Ruby on Rails user authentication Part 2]]></title>
            <link>https://medium.com/hackernoon/angular-2-and-ruby-on-rails-user-authentication-part-2-a0c40f427145?source=rss-13ff76523e5d------2</link>
            <guid isPermaLink="false">https://medium.com/p/a0c40f427145</guid>
            <category><![CDATA[angular2]]></category>
            <category><![CDATA[rails]]></category>
            <category><![CDATA[javascript]]></category>
            <category><![CDATA[angular]]></category>
            <dc:creator><![CDATA[A. Vatsaev]]></dc:creator>
            <pubDate>Sun, 12 Feb 2017 18:05:51 GMT</pubDate>
            <atom:updated>2019-04-22T11:10:05.570Z</atom:updated>
            <content:encoded><![CDATA[<h4>This article is the follow up of <a href="https://medium.com/@avatsaev/angular-2-and-ruby-on-rails-user-authentication-fde230ddaed8#.tfr6zstyp">Angular 2+ and Ruby on Rails user authentication Part 1: Backend</a></h4><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*EVCbusTvl_CBlfa96EhvYg.png" /></figure><h3>Intro</h3><p>I will separate the frontend section into 3 different subsections:</p><ol><li>Conception &amp; Bootstrapping/Configuring the project</li><li>Building login/register</li><li>Building Profile View and its Router Guard</li></ol><p>So in this part we’ll do some conception, then bootstrap and configure our project with <a href="https://cli.angular.io/">Angular CLI</a>, <a href="http://materializecss.com/">Materialize</a> for UI, and <a href="https://github.com/neroniaky/angular2-token">Angular2Token</a> for user management on the frontend.</p><p>If you don’t want/need to do any of this, I prepared a bootstrapped and fully configured project for you ready to go, just pull this repo <a href="https://github.com/avatsaev/angular-token-auth-seed">https://github.com/avatsaev/angular-token-auth-seed</a> and jump straight to <a href="https://medium.com/@avatsaev/angular-2-and-ruby-on-rails-user-authentication-part-3-d938fcb7a334#.itibi1vqc"><strong>part 3</strong></a>.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/888/1*NMOpRPtOi4yOwLTSxL2i7g.png" /></figure><h3><strong>Layout/UI</strong></h3><p>The UI of our application will be pretty simple, with a classic toolbar encapsulating the title &amp; actions, and an area to display the current page’s content:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*TiyCo-WPydbGdShldK4mxA.png" /></figure><h3><strong>Application behaviour</strong></h3><p>Initially, the application will display a welcome page in the content zone.</p><p>The <strong>actions zone</strong> will have two states, display <strong>Login &amp; Register</strong> actions when user is not logged in, or display <strong>Show profile &amp; Logout</strong> actions when the user is logged in, these states will switch in real time when the user logs in or out.</p><p>When the user clicks on <strong>Login </strong>or<strong> Register</strong> we’ll display a Modal Dialog with the appropriate form (Login or Register from).</p><p>When the user clicks on <strong>Profile </strong>action, we’ll display his profile data in the <strong>content zone.</strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*y5A6lIU6gNsNS64dsPKFIg.png" /></figure><p>When the user switches between Login and register modes, we’ll display the appropriate form in the same dialog.</p><p>When the user successfully logs in or registers, we’ll automatically close the dialog and redirect him to his profile page.</p><p>Pretty simple and straightforward stuff, so let’s dive right in.</p><h3>Bootstrapping and configuring the frontend</h3><h4>Installing Angular CLI</h4><figure><img alt="" src="https://cdn-images-1.medium.com/max/800/1*yS2MA7tY-4a_l2j9ayheNQ.png" /></figure><p>Angular Team has created a very handy tool called <a href="https://cli.angular.io/">Angular CLI</a> that allows us to bootstrap and manage an Angular app easily from within terminal, install it globally via NPM:</p><pre>$ npm install -g @angular/cli</pre><h4>Bootstrapping an Angular CLI project</h4><pre>$ ng new angular-token-auth --style=sass --skip-tests=true --routing=true</pre><p>This command will generate a new Angular CLI project named <strong>angular-devise-token-auth,</strong> will use SASS as default styling format, for the purpose of this tutorial we’ll disable unit test files, and initialise the project with a routing module, because we’ll need at least 2 routes in our app, <strong>Welcome Page</strong> and <strong>Profile Page</strong>.</p><h4>Using MaterializeCSS with Angular</h4><figure><img alt="" src="https://cdn-images-1.medium.com/max/260/1*xfMmP4cfcooS0lr-p5SKYQ.png" /></figure><p>To build our UI, we’ll use <a href="http://materializecss.com/">MaterializeCSS</a>, good news is, Materialize components are available for Angular with <a href="https://github.com/InfomediaLtd/angular2-materialize">angular2-materialize</a> library, so let’s install it with its dependencies:</p><pre>$ npm install materialize-css angular2-materialize jquery@^2.2.4 hammerjs font-awesome --save</pre><p>Include dependencies and styles in <strong>./.angular-cli.json</strong> file:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*-ECg_pxStXi1QTKJ-P8nAA.png" /></figure><p>In <strong>styles</strong> array we’ll need the materialize stylesheet:</p><pre>&quot;styles&quot;: [<br>  &quot;styles.sass&quot;,<br><strong>  &quot;../node_modules/materialize-css/dist/css/materialize.css&quot;,<br>  &quot;../node_modules/font-awesome/css/font-awesome.css&quot;</strong><br>],</pre><p>And in <strong>scripts</strong> array we’ll need jquery, hammerjs and materializejs:</p><pre>&quot;scripts&quot;: [<br>  <strong>&quot;../node_modules/jquery/dist/jquery.js&quot;,<br>  &quot;../node_modules/hammerjs/hammer.js&quot;,<br>  &quot;../node_modules/materialize-css/dist/js/materialize.js&quot;</strong><br>]</pre><p>That way, Angular CLI will know what additional 3rd party libs to compile into our final bundle.</p><p>Next, we’ll need to <strong>MaterializeModule</strong> into our M<strong>ain App Module </strong>so we can use Materialize Components in our app<strong>, </strong>open <strong>./src/app/app.module.ts</strong> and import MaterializeModule</p><pre>import { MaterializeModule } from &#39;angular2-materialize&#39;;</pre><p>Then add it to <strong>imports</strong> array of our <strong>AppModule</strong>:</p><pre>@NgModule({<br>  declarations: [<br>    AppComponent<br>  ],<br>  imports: [<br>    BrowserModule,<br>    FormsModule,<br>    HttpModule,<br>    AppRoutingModule,<br>    <strong>MaterializeModule</strong><br>  ],<br>  providers: [],<br>  bootstrap: [AppComponent]<br>})<br>export class AppModule { }</pre><h3><strong>Installing and Configuring Angular2 Token</strong></h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/260/1*gpqheFyLotOh4OLktbxVfg.png" /></figure><p>To make user management on the frontend easier, we’ll use <a href="https://github.com/neroniaky/angular2-token">angular2-token</a> library, it was designed to work with <a href="https://github.com/lynndylanhurley/devise_token_auth">DeviseAuthToken</a> gem that we used on our RoR backend for user management. Let’s install and configure it:</p><pre>npm install angular2-token --save</pre><p>Import and inject it into our <strong>Main App Module (./src/app/app.module.ts):</strong></p><pre><strong>import { Angular2TokenService } from &#39;angular2-token&#39;;</strong></pre><pre>@NgModule({<br>  declarations: [<br>    AppComponent<br>  ],<br>  imports: [<br>    BrowserModule,<br>    FormsModule,<br>    HttpModule,<br>    AppRoutingModule,<br>    MaterializeModule,<br>  ],<br>  <strong>providers: [ Angular2TokenService ],</strong><br>  bootstrap: [AppComponent]<br>})<br>export class AppModule { }</pre><p>Next we’ll need to create a default configuration for it, considering configurations might be different in production and development environments, we’ll use Angular CLI’s env config files in <strong>./src/environments</strong> folder.</p><p>In this folder we have two files, <strong>environment.ts</strong> which will be used as default configuration store during development process and <strong>environment.prod.ts </strong>will be used<strong> </strong>for production when you build your app with Angular CLI’s <strong>prod</strong> flag (<em>ng build --prod</em>)</p><p>Angular2Token offers different configuration keys, you can check them out <a href="https://github.com/neroniaky/angular2-token#configuration">here</a>, but we will need only one,<strong> apiBase, </strong>which is the address of our backend server, considering Rails is running on port 3000 by default, the address will be <strong>http://localhost:3000</strong>.</p><p>Let’s create the config in<strong> ./src/app/environments/environment.ts</strong></p><pre>export const environment = {<br>  production: false,<br>  <strong>token_auth_config: {<br>    apiBase: &#39;http://localhost:3000&#39;<br>  }</strong><br>};</pre><h3><strong>Initialize Angular2Token</strong></h3><p>Now we need to initialize the Token Service with this configuration, open <strong>./src/app/app.component.ts</strong> and import Angular2TokenService:</p><pre>import {Angular2TokenService} from &quot;angular2-token&quot;;</pre><p>then import the environement configuration:</p><pre>import {environment} from &quot;../environments/environment&quot;;</pre><p>Inject the Token Service into our <strong>ApplicationComponent</strong> and initialize it with our config:</p><pre>export class AppComponent {<br>  title = &#39;app works!&#39;;<br>  <strong>constructor(private authToken: Angular2TokenService){<br>    this.authToken.init(environment.token_auth_config);<br>  }</strong><br>}</pre><p>Your <strong>AppComponent</strong> should look something like this:</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/5eaff221e44766f297adb4abb4c447e7/href">https://medium.com/media/5eaff221e44766f297adb4abb4c447e7/href</a></iframe><h3>Testing the Token Service</h3><p>Let’s now see if we can login with our default user, if you remember his email was <strong>user@example.com</strong> and password <strong>monkey67.</strong></p><p>Let’s use <strong>signIn</strong> method of the <strong>Token Service</strong> which takes an object with <strong>email</strong> and <strong>password </strong>keys<strong> </strong>as parameter, and returns an Obesevable&lt;Response&gt;, to which we can subscribe and log out the result (don’t forget to start our RoR Backend if it’s not already running):</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/faa999cbb374a9acb073432575629a33/href">https://medium.com/media/faa999cbb374a9acb073432575629a33/href</a></iframe><p>Start our Angular app by running:</p><pre>$ ng serve</pre><p>The server will start on <a href="http://localhost:4200/">http://localhost:4200</a></p><p>If you look into the console, you will see the auth token in the response headers and user data in the the body:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*npEtG5wkXb1_gPejEzpWrw.png" /></figure><p>Before continuing don’t forget to remove this Sign In test and clean up your browser cache to remove the auth token from the local storage.</p><p>Now that we have our frontend up and running, we can start building our Angular application,<strong> </strong><a href="https://medium.com/@avatsaev/angular-2-and-ruby-on-rails-user-authentication-part-3-d938fcb7a334#.u9pzluw9j"><strong>let’s head out to part 3</strong></a><strong> </strong>for the fun stuff.</p><blockquote><a href="https://medium.com/@avatsaev/angular-2-and-ruby-on-rails-user-authentication-part-3-d938fcb7a334#.itibi1vqc">Part 3: Frontend, login/register</a></blockquote><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=a0c40f427145" width="1" height="1" alt=""><hr><p><a href="https://medium.com/hackernoon/angular-2-and-ruby-on-rails-user-authentication-part-2-a0c40f427145">Angular 2+ and Ruby on Rails user authentication Part 2</a> was originally published in <a href="https://medium.com/hackernoon">HackerNoon.com</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Angular 2+ and Ruby on Rails user authentication]]></title>
            <link>https://medium.com/@avatsaev/angular-2-and-ruby-on-rails-user-authentication-fde230ddaed8?source=rss-13ff76523e5d------2</link>
            <guid isPermaLink="false">https://medium.com/p/fde230ddaed8</guid>
            <category><![CDATA[rails]]></category>
            <category><![CDATA[ruby-on-rails]]></category>
            <category><![CDATA[angular]]></category>
            <category><![CDATA[angular2]]></category>
            <dc:creator><![CDATA[A. Vatsaev]]></dc:creator>
            <pubDate>Sun, 12 Feb 2017 17:58:54 GMT</pubDate>
            <atom:updated>2019-04-22T11:09:27.065Z</atom:updated>
            <content:encoded><![CDATA[<h4>How to setup an Angular 2+ frontend with User Register/Login capabilities using Ruby on Rails backend and Devise Token Auth gem</h4><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*EVCbusTvl_CBlfa96EhvYg.png" /></figure><h3>Intro</h3><p>TD;DR: We’ll create a simple Rails &amp; Angular (2+) web application that allows a user to create an account, login with it and view his profile using <a href="https://github.com/plataformatec/devise">Devise</a> and token authentication.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1000/1*Bn_fyEwreT7EN18bkp7tqw.gif" /><figcaption>Final result</figcaption></figure><h3>Prerequisites</h3><p>This tutorial assumes you’re comfortable with <a href="http://rubyonrails.org/">Ruby on Rails</a> (RoR), more precisely with the version 5 and Rails API Mode, and somewhat familiar with <a href="https://angular.io/">Angular 2+</a>. This is not exactly a “Getting Started with Rails and Angular” kind of tutorial for absolute beginners, but I’ll go into as much details as I can.</p><p>I’ll also assume you have <a href="https://nodejs.org/en/">NodeJS 6.9+, NPM</a> and <a href="https://www.postgresql.org/">Postgres</a> installed on your system, if not, there are great tutorials online if you Google around.</p><p>Frontend and backend will be running on separate servers, communicating with each other via a REST API.</p><figure><a href="https://ultimatecourses.com/ref/azero79/"><img alt="" src="https://cdn-images-1.medium.com/max/888/1*NMOpRPtOi4yOwLTSxL2i7g.png" /></a></figure><h3>Angular features we’ll use</h3><ul><li>Components</li><li>Services</li><li>Dependency injection</li><li>Forms and form validations</li><li>Component inputs</li><li>Component outputs</li><li>View Children</li><li>Router and Router Guards</li></ul><h3><strong>Part 1: Backend</strong></h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/316/1*EQxwCzxLAihsv6O3AK-KVw.png" /></figure><h4>Rough plan</h4><ol><li>Bootstrap and configure a RoR app in API mode</li><li>Link to Postgres database</li><li>Install, configure devise-token-auth gem</li><li>Create and Configure our Devise User model</li><li>Seed the DB with a default test user</li><li>Create, Migrate and Seed our database</li><li>Run the server and test the API</li></ol><p><em>If you don’t want/need to go through this process, you can just download the final code from this repo: </em><a href="https://github.com/avatsaev/rails-devise-token-seed"><em>https://github.com/avatsaev/rails-devise-token-seed</em></a><em> and jump straight to </em><a href="https://medium.com/@avatsaev/angular-2-and-ruby-on-rails-user-authentication-part-2-a0c40f427145#.ihueixn1i"><strong><em>Part 2: Bootstrapping and configuring the frontend</em></strong></a><em>.</em></p><p>Let’s get started.</p><h4>Setup</h4><p>First let’s bootstrap a new Rails project in API mode and Postgres database (DB) config:</p><pre>$ rails new rails_devise_token_auth --api --database=postgresql</pre><p>This will create a barebones Rails 5 app in API mode (without views and without the asset pipeline, JSON will be the default response format)</p><p>Next, we’ll add a few useful gems to our Gemfile:</p><pre>gem &#39;devise_token_auth&#39;<br>gem &#39;omniauth&#39;<br>gem &#39;rack-cors&#39;, :require =&gt; &#39;rack/cors&#39;</pre><p><a href="https://github.com/lynndylanhurley/devise_token_auth">Devise Token Auth</a> leverages <a href="https://github.com/plataformatec/devise">Devise</a> and will allow us to do user management via a REST API, omniauth is a devise_token_auth dependency.</p><p>We need rack-cors, which allows us to do cross domain AJAX requests (because we are running in API mode, so the backend will most certainly run on a separate server and domain when in production).</p><p>Install the gems:</p><pre>$ bundle install </pre><p>Let’s configure cors, edit the file <strong>./config/initializers/cors.rb</strong> (create if doesn’t exist), replace its contents with the following:</p><pre>Rails.application.config.middleware.use Rack::Cors do</pre><pre>  allow do</pre><pre>    origins &#39;*&#39;</pre><pre>    resource &#39;*&#39;,</pre><pre>    :headers =&gt; :any,</pre><pre>    :expose  =&gt; [&#39;access-token&#39;, &#39;expiry&#39;, &#39;token-type&#39;, &#39;uid&#39;, &#39;client&#39;],</pre><pre>    :methods =&gt; [:get, :post, :options, :delete, :put]</pre><pre>  end</pre><pre>end</pre><p>For this tutorial we’ll allow all domains to contact our server, expose some custom headers retuned by Devise Token Auth, and allow the most commonly used http request methods, although we won’t need all of them.</p><h4>Database configuration</h4><p>Assuming you already have a Postgres server installed and running on your system, <strong>we do not have to change anything,</strong> because Postgres is already initialised with a public postgres user and database, and initial Rails DB config uses postgres as default user and localhost as default host, but <strong>if your Postgres server has a custom password protected user</strong>, don’t forget to edit the <strong>./config/database.yml </strong>file:</p><pre>default: &amp;default<br>  adapter: postgresql<br>  encoding: unicode<em><br>  </em>pool: &lt;%= ENV.fetch(&quot;RAILS_MAX_THREADS&quot;) { 5 } %&gt;</pre><pre>development:<br>  &lt;&lt;: *default<br>  database: rails_devise_token_seed_development<br>  username: YOUR_CUSTOM_USERNAME<br>  password: YOUR_PASSWORD</pre><pre>test:<br>  &lt;&lt;: *default<br>  database: rails_devise_token_seed_test<br>  username: YOUR_CUSTOM_USERNAME<br>  password: YOUR_PASSWORD</pre><h4>Create the database</h4><pre>$ rails db:create</pre><p>This command will create our development and test databases.</p><h4>Initialise Devise User Model</h4><p>If you read the <a href="https://github.com/lynndylanhurley/devise_token_auth#configuration-tldr">DeviseTokenAuth README</a> you’ll see how to initialise our user model:</p><pre>$ rails generate devise_token_auth:install <strong>User</strong> <strong>auth</strong></pre><p><strong>User </strong>will be our model name, and <strong>auth </strong>will be the endpoint of our user management rest api (ex: /<strong>auth</strong>/sign_in, /<strong>auth</strong>/sign_out)</p><p>Generated output of this command should look something like this:</p><pre>create  config/initializers/devise_token_auth.rb</pre><pre>create  <strong>db/migrate/20170131161242_devise_token_auth_create_users.rb</strong></pre><pre>create  <strong>app/models/user.rb</strong></pre><pre>insert  app/controllers/application_controller.rb</pre><pre>gsub  <strong>config/routes.rb</strong></pre><p>The most interesting files for us are highlighted in bold.</p><p>The first one is a database migration file that will initialise the <strong>users</strong> table for us with all required fields.</p><p>We also have <strong>User</strong> model initialised, as well as the <strong>auth </strong>endpoint<strong> </strong>mounted in<strong> routes.rb</strong></p><h4><strong>Configure User Model</strong></h4><p>For this tutorial, we’ll disable account email validation by opening the User model (<strong>./app/models/user.rb</strong>) file and removing <em>confirmable </em>module<em> </em>from the devise configuration, so the User model should look something like this:</p><pre>class User &lt; ActiveRecord::Base<br><em><br><br>  </em>devise :database_authenticatable, <br>         :registerable,<br>         :recoverable, <br>         :rememberable, <br>         :trackable,  <br>         :validatable, <br>         :omniauthable</pre><pre>  include DeviseTokenAuth::Concerns::User</pre><pre>end</pre><h4><strong>Create a default User seed</strong></h4><p>We’ll initialise the <strong>users</strong> table with a default user that will allow us to test our API as we go. In <strong>./db/seeds.rb </strong>add the following line:</p><pre>User.create(email: &#39;user@example.com&#39;, nickname: &#39;UOne&#39;, name: &#39;User One&#39;, password: &quot;monkey67&quot;)</pre><p>Our login will be<strong> user@example.com </strong>with password<strong> monkey67</strong></p><h4><strong>Migrate and Seed the DB</strong></h4><pre>rails db:migrate &amp;&amp; rails db:seed</pre><p>This one liner will migrate the <strong>users</strong> table, and create our default user in it:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*3kjFEGCX02pwSHBGy7bCHw.png" /></figure><h4><strong>Test the API</strong></h4><p>Now we can finally start our backend server and test the API, start the Rails server by issuing the following command:</p><pre>$ rails s</pre><p>And we’ll try to login with our default user credentials, to test REST APIs I use the <a href="https://paw.cloud/">Paw App for macOS</a> (which is a great tool btw, you if you work with REST APIs, I can’t recommend it enough) but you can use whatever tool you like or just curl in your terminal.</p><p>By reading the <a href="https://github.com/lynndylanhurley/devise_token_auth#usage-tldr">Devise Token Auth documentation</a> we can see that we need to make a <strong>POST</strong> request to <strong>/auth/sign_in</strong> endpoint with <strong>email</strong> and <strong>password</strong> parameters in order to login and get our auth token, so we’ll do just that:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*9C1i0rakZYaTdTsCVYXQpg.png" /><figcaption>Response body</figcaption></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*3oqv7jqrNiCqqFP0UhdRtw.png" /><figcaption>Response headers</figcaption></figure><p>It’s alive! (Paw Print of the request and response: <a href="https://paw.pt/b4LiggBt">https://paw.pt/b4LiggBt</a>)</p><p>The server will return the user data in response body, and the auth token in response headers (acess-token key)</p><p>Alternatively you can use this curl command to test it in the terminal:</p><pre>curl -v -X &quot;POST&quot; &quot;<a href="http://localhost:3000/auth/sign_in">http://localhost:3000/auth/sign_in</a>&quot; \<br>     -H &quot;Content-Type: application/json; charset=utf-8&quot; \<br>     -d $&#39;{<br>  &quot;email&quot;: &quot;<a href="/service/mailto:user@example.fr">user@example.</a>com&quot;,<br>  &quot;password&quot;: &quot;monkey67&quot;<br>}&#39;</pre><p>So now that our backend have the minimal functionality, let’s attack the frontend.</p><blockquote><a href="https://medium.com/@avatsaev/angular-2-and-ruby-on-rails-user-authentication-part-2-a0c40f427145#.ihueixn1i"><strong>Click here for the Part 2: Setting up Angular frontend</strong></a></blockquote><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=fde230ddaed8" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Secure your macOS and iOS]]></title>
            <link>https://medium.com/@avatsaev/secure-your-shit-os-x-and-ios-edition-aa9812c4acfa?source=rss-13ff76523e5d------2</link>
            <guid isPermaLink="false">https://medium.com/p/aa9812c4acfa</guid>
            <category><![CDATA[ios]]></category>
            <category><![CDATA[security]]></category>
            <category><![CDATA[os-x]]></category>
            <dc:creator><![CDATA[A. Vatsaev]]></dc:creator>
            <pubDate>Mon, 22 Feb 2016 21:20:02 GMT</pubDate>
            <atom:updated>2017-02-04T13:10:54.922Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*tcvkw_dE4Z-aU1rrQ9rmqg.png" /></figure><h3>iOS</h3><h4>Prevent the brute force</h4><p>Let’s start with iOS.</p><p>First, we need to understand what kind of backdoor FBI is making Apple to implement, they’re not asking for encryption keys (for now), they want to buypass some of the security functions which prevent the brute force attacks on iPhones. When you type in the wrong passcode several times in a row, there is a cool down period during which you can’t unlock the phone, even with your fingerprint (1 minute, 5 minutes, etc.)</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1004/1*019G1-ljX2sri8AMoaCgPA.jpeg" /></figure><p>FBI is asking Apple to build a version of iOS without this cool down period, they are also asking for a way to type the password programatically by hooking up the iPhone to a machine running a brute force software. After this, your 4 digit passcode (or even 6 digit used in recent versions of iOS) could be cracked on modern hardware in a matter of few instants. Imagine the consequences if this version of iOS is somehow leaked into the wild, FBI will not be the only one using it.</p><blockquote>Watch this video to better understand the demands of FBI: <a href="https://www.youtube.com/watch?v=YG0bUmuj4tg&amp;feature=youtu.be&amp;t=5356">https://www.youtube.com/watch?v=YG0bUmuj4tg&amp;feature=youtu.be&amp;t=5356</a></blockquote><p>But the solution to brute force attacks is pretty straight forward, the problem here is the fact that only digits are used (from 0 to 9, 4 or 6 times), which makes it VERY easy to iterate through without the cool down period, and find the correct passcode, to counter the brute force attacks we need to use alphanumeric passcodes.</p><p>To enable it go into <strong>Settings</strong>, then <strong>Touch ID and Passcode:</strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/500/1*deYXQ3HW4_g1gxIOZqUWAQ.png" /><figcaption>It’s still the same settings category if your device doesn’t have Touch ID</figcaption></figure><p>The tap <strong>Change Passcode:</strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/500/1*J2LclxUiqzfL4B7Ye4A7HA.png" /><figcaption>Require passcode option should always remain on “Immediately”</figcaption></figure><p>Tap on <strong>Passcode Options:</strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/500/1*M_TK9SNUfWNSb0M7ixBYLw.png" /></figure><p>And chose <strong>Custom Alphanumeric Passcode:</strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/500/1*tckTyci9neXqJQ8UMpVCpg.png" /></figure><p>A good recipe for a strong Alphanumeric Passcode in my opinion is 1 Capital letter, 2 digits (minimum), at least one special character, and the length should be minimum 8 characters, something like this for example: <strong>Crazyhorse!1991</strong></p><p>I understand that typing this every time you want to unlock your phone could get annoying pretty fast, but if you have Touch ID on your device, this shouldn’t be an issue.</p><p>Another good security mesure would be to enable “Erase Data” option in “Touch ID and Passcode” settings, after 10 failed attempts all data on the phone will be erased forever, a little radical, but better than letting someone else obtain your personal data.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/500/1*UuhEzHckCeHycnT_eabvDg.jpeg" /></figure><h3><strong>OS X</strong></h3><h4>Enable the FileVault</h4><p>So the first reflex on OS X is to enable FileVault of course, some people claim that startup times are going up after you enable it, not true, especially not on modern hardware, with hardware accelerated encryption on Intel CPUs and modern SSDs, on older hardware the difference is negligible (if any).</p><p>Go to <strong>System Preferences, Security and Privacy, FileVault tab, </strong>unlock the settings by clicking on a little Lock on the bottom-left side of the window, and entering your andmin password (which also should be compliant to the recipe of Good Alphanumeric Passwords, you know, the one I mentioned above)<strong>:</strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/665/1*NAgBlFIwHD8zLcvtT7o4dA.png" /></figure><p>OS X will ask you if you want the ability to reset the encryption password from iCloud, do not enable it, because, well, FBI could ask Apple to give acces to your iCloud account, to which they have to comply.</p><p>Instead you’ll be given a long encryption key which will be used to decrypt the hard drive if you ever want to move your data and/or clean reinstall OS X and restore form backup. I would recommend writing it down somewhere on a piece of paper, or saving it on a trusted system. Please do not lose it, I’m not responsible if you lose your data forever.</p><h4>Enable the Firmware Password</h4><p>Enabling the firmware password prevents others from installing, erasing or switching to another OS (if you have dualboot or bootcamp enabled), it also prevents unauthorised access to recovery mode.</p><p>To enable it, restart your Mac and hold down the <strong>⌘</strong> and <strong>R </strong>keys at the same time during the boot sequence, the machine will boot into recovery mode.</p><p>From there, click on <strong>Utilities</strong>, then <strong>Firmware Password Utility</strong>, (again, follow the recipe of <em>Good Alphanumeric Passwords™</em>)<em>, </em>preferably make it different from the one you’re using on your OS X account,<strong> <em>and do not forget it</em></strong>.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*jJbjCOwvuBenwQlWrjBz-A.jpeg" /></figure><p>Don’t touch anything else here if your don’t know what your’re, just reboot by clicking on the little Apple logo on top-left side of the screen, then hit restart.</p><p>Here are some of the mesures I’m using to add additional layers of security to my devices, if you have any segguestions, please let me know in the comment section (or whatever the hell it’s called on Medium.com)</p><p>Thank you for reading, and always remember to keep your personal data safe.</p><blockquote>A. Vatsaev</blockquote><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=aa9812c4acfa" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Sideloading feature on iOS 9 and recent release of F.lux]]></title>
            <link>https://medium.com/@avatsaev/sideloading-feature-on-ios-9-and-recent-release-of-f-lux-347b0bcf72f0?source=rss-13ff76523e5d------2</link>
            <guid isPermaLink="false">https://medium.com/p/347b0bcf72f0</guid>
            <category><![CDATA[apple]]></category>
            <category><![CDATA[ios]]></category>
            <category><![CDATA[xcode]]></category>
            <dc:creator><![CDATA[A. Vatsaev]]></dc:creator>
            <pubDate>Fri, 13 Nov 2015 12:57:42 GMT</pubDate>
            <atom:updated>2015-11-14T10:14:30.906Z</atom:updated>
            <content:encoded><![CDATA[<h3>Sideloading feature on iOS 9 and recent release of F.lux for iOS might lead to piracy on iOS without jailbreak</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*R5H27f-m7h1q1mkuyteADg.png" /></figure><p>With latest Apple’s iOS 9 update, developers are no longer required to have a <em>Developer Certificate </em>to test their apps on real devices. Which is great, especially for students and beginners who want to learn iOS programming but don’t necessarily want to pay $100/year to be able to test their work.</p><p>This alone doesn’t enable piracy, but the recent release of <a href="https://justgetflux.com/">F.lux</a> for iOS revealed a method of installing any iOS app/game on iOS9 without jailbreak.</p><p><a href="https://justgetflux.com/sideload/">F.lux recently published their iOS app</a> as an Xcode project for people to sideload, apparently disclosing the source code in the Xcode project wasn’t an option, so they did it by precompiling the app into an IPA archive, and putting it into an empty Xcode project, <a href="http://www.macrumors.com/2015/11/12/flux-for-ios-pulled-no-side-loading/">Apple contacted them shortly after and they pulled the app from their website</a>.</p><blockquote>Apple has contacted us to say that the f.lux for iOS download (previously available on this page) is in violation of the Developer Program Agreement, so this method of install is no longer available.</blockquote><blockquote>We understood that the new Xcode signing was designed to allow such use, but Apple has indicated that this should not continue.</blockquote><p>The real reason for this was more than a simple violation of Developer Program Agreement. By removing the precompiled F.lux IPA from the Xcode project and replacing it with the contents extracted from the IPA archive of another iOS app, Xcode can install it on a device running iOS 9 (or 9.1).</p><p>This is what the F.lux Xcode project looks like:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*3tnzHuctcxMzpaWdi19Gtg.png" /><figcaption>Notice the iflux file which is precompiled F.lux IPA</figcaption></figure><p>By replacing everything selected with the contents of any other app, I was able to run them on my iPhone in one click (I was terrified after realising how easy it was).</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*o0zYjZNvOgmfHbA5r5p9wA.png" /></figure><p>I re-tested with a few other apps just to be sure I wasn’t hallucinating, and each time I was able to install and run them on my iPhone without any errors.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/750/1*-XzNmdJzjf783Z0yWa4RJg.jpeg" /></figure><p>Of course I deleted the apps right after making sure they launch successfully.</p><p>I’m pretty sure this wasn’t F.lux’s initial intention, all they wanted was to get their wonderful app out there without revealing their intellectual property. But until Apple fixes this problem we might see people taking advantage of the situation by installing paid apps on their devices without buying them on the App Store, a lot of developers will be loosing money.</p><p>This also means that Apple will not take any more risks and remove the sideloading feature completely from iOS and Xcode.</p><p>EDIT: You still need to sign the application, my Xcode project was configured to not use a Signature, but turns out build settings section automatically sets a Certificate to run the app on the device. Sorry for the misinformation.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=347b0bcf72f0" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Multitasking stress test on a MacBook Pro 2013]]></title>
            <link>https://medium.com/@avatsaev/multitasking-stress-test-on-a-macbook-pro-2013-9728810f9a82?source=rss-13ff76523e5d------2</link>
            <guid isPermaLink="false">https://medium.com/p/9728810f9a82</guid>
            <category><![CDATA[os-x]]></category>
            <category><![CDATA[apple]]></category>
            <category><![CDATA[macbook]]></category>
            <dc:creator><![CDATA[A. Vatsaev]]></dc:creator>
            <pubDate>Thu, 22 Oct 2015 17:20:15 GMT</pubDate>
            <atom:updated>2015-10-22T17:21:00.152Z</atom:updated>
            <content:encoded><![CDATA[<p>Wanted to know how my MacBook Pro would hold up to some heavy multitasking, so I did a very quick and dirty stress test.</p><p>Specs:</p><ul><li>MacBook Pro 15&quot; Late 2013 Model</li><li>Intel i7 Quad Core</li><li>8GB Ram</li><li>Iris Pro Graphics chip</li><li>250 GiBs on IDE SSD</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*P7ZkmREfChqknbmQSEZeyA.png" /></figure><iframe src="https://cdn.embedly.com/widgets/media.html?src=https%3A%2F%2Fwww.youtube.com%2Fembed%2FxlpM3-KN0bM%3Ffeature%3Doembed&amp;url=https%3A%2F%2Fwww.youtube.com%2Fwatch%3Fv%3DxlpM3-KN0bM&amp;image=https%3A%2F%2Fi.ytimg.com%2Fvi%2FxlpM3-KN0bM%2Fhqdefault.jpg&amp;key=d04bfffea46d4aeda930ec88cc64b87c&amp;type=text%2Fhtml&amp;schema=youtube" width="854" height="480" frameborder="0" scrolling="no"><a href="https://medium.com/media/d1aab246aecb88639f333e22446f1798/href">https://medium.com/media/d1aab246aecb88639f333e22446f1798/href</a></iframe><p>OSX Running: Photoshop, Xcode, Safari, Popcorn Time, Atom.io, Terminal, Playing South Park (720p) on VLC, emulating iOS on iPhone 6s simulator and compiling some code</p><p>Running windows 10 on Parallels with Skype, Chrome, EA Origin, Downloading Counter Strike on Steam, etc.</p><p>Running Debian: Running Gimp, htop, and few other programs</p><p>As you can see MacBook was tearing through everything I was throwing at it and I’m pretty sure I could do some light gaming in the Windows 10 VM and still get pretty good perfomances.</p><p>Don’t know about you, but I’m impressed.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=9728810f9a82" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Do this on your parents’ Mac if you don’t want them to make you deal with MacKeeper]]></title>
            <link>https://medium.com/@avatsaev/do-this-on-your-parents-mac-if-you-dan-t-want-them-to-make-you-deal-with-mackeeper-651f5343355f?source=rss-13ff76523e5d------2</link>
            <guid isPermaLink="false">https://medium.com/p/651f5343355f</guid>
            <category><![CDATA[terminal]]></category>
            <category><![CDATA[mac]]></category>
            <category><![CDATA[mackeeper]]></category>
            <dc:creator><![CDATA[A. Vatsaev]]></dc:creator>
            <pubDate>Sat, 17 Oct 2015 13:53:15 GMT</pubDate>
            <atom:updated>2015-10-17T19:57:49.480Z</atom:updated>
            <content:encoded><![CDATA[<p>I had to deal with MacKeeper not a long time ago, and it wasn’t fun, my mom somehow managed to install MacKeeper on her MacBook and it wrecked the whole system; started to get slow, heating, and draining the battery like there’s no tomorrow.</p><h4>Fix the problem by avoiding it in the first place</h4><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*iXchQ4mDOE8TOGLGKPssrw.png" /></figure><p>I decided to create a very simple script that will block all mackeeper domains (that I know of in any case) so every time some shady website your parents visit redirects them to Mackeeper it won’t even load, and the crisis will be averted in first place.</p><p>GitHub (source): <a href="https://github.com/avatsaev/mackeeper_blocker">https://github.com/avatsaev/mackeeper_blocker</a>[1]</p><p>The script simply adds mackeeper domains to the /etc/hosts file to redirect all requests to the localhost.</p><p>Mackeeper wants to sell their malware by agressive marketing with false advertising, and they think they can get away with it, well we can counter this nonsense by massive awareness spreading and domain blocking.</p><p><a href="http://appleinsider.com/articles/15/08/10/mackeeper-to-pay-out-2m-in-proposed-class-action-settlement">Just a few months ago Mackeeper was slapped with class action lawsuit over false advertising in which they have agreed to a $2 million settlement.</a></p><p>For those of you who have no idea what to do, nor how to use terminal, here is a simple step by step tutorial:</p><h4>1: Open the terminal</h4><p>Open the Terminal.app by typing “terminal” into Spotligh (⌘+Spacebar)</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*3geEL14BuH9u9y-U2-eqiw.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*znfXHEXU8MVRyk0kh5OLow.png" /><figcaption>Your teminal might look a little bit different from mine, but it doesn’t matter.</figcaption></figure><h4>2: Execute</h4><p>Copy paste this one liner command into the terminal:</p><pre>curl -sSL https://raw.githubusercontent.com/avatsaev/mackeeper_blocker/master/mackeeper_blocker &gt; mackeeper_blocker &amp;&amp; sudo ruby ./mackeeper_blocker</pre><blockquote><em>This command downloads the latest version of the script that contains the list of all known mackeeper domains, and then executes it in privileged mode. If you are not sure, go to the link (</em><a href="https://raw.githubusercontent.com/avatsaev/mackeeper_blocker/master/mackeeper_blocker">https://raw.githubusercontent.com/avatsaev/mackeeper_blocker/master/mackeeper_blocker</a><em>) to view the contents of the script before executing this command.</em></blockquote><p>When you hit ENTER, you’ll be asked to type in your password (because sudo), and the script will automatically add all necessary entries to your hosts file:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*-CHrDCJcr8O-eLvc_876UA.png" /><figcaption>In this example I added “ &amp;&amp; rm ./mackeeper_blocker” at the end, it deletes the downloaded file after execution, but rm is pretty dangerous to use if you don’t know what you’re doing so don’t take unnecessary risks.</figcaption></figure><h3>Testing</h3><p>Now when you go to mackeeper.com the page won’t even load. This will work across all browsers, not only in Safari.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*GCziPvvgQ5TRF7J8EhGl0Q.png" /></figure><blockquote>PS: If you want the same system info in your terminal, checkout my other GitHub repo called Mavericksey (forked from OSXey and adapted for El Capitan): <a href="https://github.com/avatsaev/Mavericksey">https://github.com/avatsaev/Mavericksey</a></blockquote><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=651f5343355f" width="1" height="1" alt="">]]></content:encoded>
        </item>
    </channel>
</rss>