<?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 Ugur Cem Ozturk on Medium]]></title>
        <description><![CDATA[Stories by Ugur Cem Ozturk on Medium]]></description>
        <link>https://medium.com/@ugurcemozturk?source=rss-5f14504ab1bb------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/1*YsCtcKVL-kcRTrV599toyA.jpeg</url>
            <title>Stories by Ugur Cem Ozturk on Medium</title>
            <link>https://medium.com/@ugurcemozturk?source=rss-5f14504ab1bb------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Wed, 18 Nov 2026 22:43:35 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@ugurcemozturk/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[Model Context Protocol Servers: The USB-C Port for AI Agent Ecosystem — Part 1]]></title>
            <link>https://ugurcemozturk.medium.com/model-context-protocol-servers-the-usb-c-port-for-ai-agent-ecosystem-part-1-9da76c7da410?source=rss-5f14504ab1bb------2</link>
            <guid isPermaLink="false">https://medium.com/p/9da76c7da410</guid>
            <category><![CDATA[automation]]></category>
            <category><![CDATA[ai]]></category>
            <category><![CDATA[agents]]></category>
            <category><![CDATA[kubernetes]]></category>
            <category><![CDATA[model-context-protocol]]></category>
            <dc:creator><![CDATA[Ugur Cem Ozturk]]></dc:creator>
            <pubDate>Thu, 13 Mar 2025 10:35:57 GMT</pubDate>
            <atom:updated>2025-03-13T10:35:57.043Z</atom:updated>
            <content:encoded><![CDATA[<h3>Model Context Protocol Servers: The USB-C Port for AI Agent Ecosystem — Part 1</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/600/0*O_YYsCyITPUOvMhf.jpg" /></figure><p><em>My first look at the MCP documentation is above.<br>Model Context Protocol (MCP) standardizes the communication between large language models and the external world, much like how USB-C standardized device connections across the tech industry.</em></p><h3>Understanding MCP: The Universal Adapter for AI</h3><p>At its core, MCP is like a universal adapter for AI — a USB-C port that standardizes how language models connect with external tools, data sources, and services. Before MCP, developers faced a fragmented landscape where each integration required custom code, creating an inefficient patchwork of solutions. MCP replaces this with a consistent protocol that makes AI systems more versatile, context-aware, and capable of real-world interactions.</p><p>The architecture follows a client-server model with three main components:</p><ol><li><strong>MCP Host</strong>: The AI-powered application that end-users interact with (like Claude Desktop or custom LLM applications)</li><li><strong>MCP Client</strong>: The intermediary that manages connections between the host and servers while maintaining security</li><li><strong>MCP Server</strong>: The implementation that exposes specific capabilities — typically tools, data resources, and predefined prompts</li></ol><p>This standardized approach ensures interoperability between AI systems and external tools. Developers can create an MCP server once and have it work with any MCP-compatible AI assistant, while users benefit from enhanced AI capabilities without sacrificing privacy or security.</p><p><strong>Thrilling, yet a bit daunting</strong>, <strong>ha</strong>?</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*K-sFtiImRGAEEBeLhTHaSg.png" /></figure><h3>Python Implementation: Building a Kubernetes MCP Server</h3><p>Let’s explore how to build a real-world MCP server in Python that <strong>interfaces with Kubernetes</strong>, providing a powerful tool for developers to <strong>monitor</strong> <strong>and manage their cluster</strong>s through AI assistants. This implementation is far more practical than simple weather examples and <strong>addresses real development needs.</strong></p><h3>Setting Up Your Environment</h3><p>First, let’s set up our Python environment with the necessary packages:</p><pre>pip install mcp kubernetes uvicorn</pre><h3>Creating the Basic Server Structure</h3><p>Our Kubernetes MCP server will provide tools for retrieving logs, managing pods, and monitoring cluster status:</p><pre>from typing import Any, Dict, List, Optional<br>import asyncio<br>import logging<br>from kubernetes import client, config<br>from mcp.server.fastmcp import FastMCP<br># Initialize logging<br>logging.basicConfig(level=logging.INFO)<br>logger = logging.getLogger(&quot;k8s-mcp-server&quot;)<br># Initialize Kubernetes client<br>try:<br>    config.load_kube_config()<br>    logger.info(&quot;Loaded Kubernetes config from default location&quot;)<br>except Exception as e:<br>    logger.warning(f&quot;Could not load kube config: {e}&quot;)<br>    logger.info(&quot;Will attempt to use in-cluster config if running in a pod&quot;)<br>    try:<br>        config.load_incluster_config()<br>        logger.info(&quot;Loaded in-cluster Kubernetes config&quot;)<br>    except Exception as e:<br>        logger.error(f&quot;Failed to load in-cluster config: {e}&quot;)<br># Initialize the MCP server<br>mcp = FastMCP(&quot;kubernetes&quot;)<br>v1_api = client.CoreV1Api()<br>apps_v1_api = client.AppsV1Api()</pre><h3>Implementing Tools for Kubernetes Operations</h3><p>Now let’s create several tools that provide valuable functionality for developers:</p><pre>@mcp.tool<br>async def get_pod_logs(namespace: str, pod_name: str, container: Optional[str] = None, tail_lines: int = 100) -&gt; str:<br>    &quot;&quot;&quot;<br>    Retrieve logs from a specific pod in the specified namespace.<br>    <br>    Args:<br>        namespace: The Kubernetes namespace containing the pod<br>        pod_name: Name of the pod to get logs from<br>        container: Optional container name if pod has multiple containers<br>        tail_lines: Number of log lines to return (default: 100)<br>    <br>    Returns:<br>        Pod logs as text<br>    &quot;&quot;&quot;<br>    try:<br>        if container:<br>            logs = v1_api.read_namespaced_pod_log(<br>                name=pod_name,<br>                namespace=namespace,<br>                container=container,<br>                tail_lines=tail_lines<br>            )<br>        else:<br>            logs = v1_api.read_namespaced_pod_log(<br>                name=pod_name,<br>                namespace=namespace,<br>                tail_lines=tail_lines<br>            )<br>        <br>        if not logs:<br>            return &quot;No logs available for this pod.&quot;<br>        <br>        return logs<br>    except Exception as e:<br>        logger.error(f&quot;Error retrieving logs: {e}&quot;)<br>        return f&quot;Error retrieving logs: {str(e)}&quot;<br></pre><h3>Running the Server</h3><p>Finally, let’s set up the main function to run our server:</p><pre>if __name__ == &quot;__main__&quot;:<br>    try:<br>        logger.info(&quot;Starting Kubernetes MCP server...&quot;)<br>        asyncio.run(mcp.start())<br>    except KeyboardInterrupt:<br>        logger.info(&quot;Server stopped by user&quot;)<br>    except Exception as e:<br>        logger.error(f&quot;Server error: {e}&quot;)</pre><p>This implementation provides a practical tool for developers to interact with their Kubernetes clusters through natural language conversations with AI assistants. Instead of remembering complex kubectl commands or navigating multiple interfaces, developers can simply ask questions like <strong>“What’s the status of deployments in the production namespace?” </strong>or<strong> “Show me the logs from the database pod in the default namespace.”</strong></p><h3>Enhancing Development and Debugging with MCP Servers</h3><p>The Kubernetes MCP server we’ve built demonstrates how MCP can transform development and debugging workflows by connecting AI assistants with specialized tools and services. This approach addresses several common challenges in software development:</p><h3>Streamlined Log Analysis</h3><p>One of the most time-consuming aspects of debugging is sifting through l<strong>ogs to identify the source of an issue.</strong> The Kubernetes MCP server enables developers to use natural language to request and filter logs, making the process more efficient and intuitive. For example, a developer could ask <strong>“Show me error logs from the API service for the last hour” </strong>and receive a filtered view of the relevant information.</p><p>This capability becomes even more powerful when combined with error aggregation services like Sentry. You can analyze MCP server usage with standard logging handlers, Tinybird, and Grafana, creating dashboards that show:</p><ul><li>Total sessions with the server</li><li>Total requests to the server</li><li>Total errors on the server</li><li>Requests/errors by tool</li><li>Error rate by tool</li></ul><h3>Context-Aware Debugging</h3><p>The MCP architecture enables AI assistants to maintain context across multiple interactions, creating a more coherent debugging experience. Instead of switching between tools and losing context, developers can have a continuous conversation with their AI assistant about a particular issue, referring back to previous findings and progressively narrowing down the problem.</p><h3>Proactive Monitoring</h3><p>Beyond reactive debugging, MCP servers can enable proactive monitoring by allowing AI assistants to periodically check system health and alert developers to potential issues before they affect users. This capability transforms AI assistants from passive helpers into active participants in the development process, freeing up developer time and attention for more creative work.</p><h3>Creative Solutions Powered by MCP Servers</h3><p>The flexibility of the Model Context Protocol has inspired developers to create diverse MCP servers that extend AI capabilities in innovative ways. Here are some creative implementations:</p><h3>Database Connectivity with JDBC</h3><p>The JDBC MCP server enables AI assistants to interact with any JDBC-compatible database, including PostgreSQL, MySQL, MariaDB, SQLite, and Oracle. This allows data analysts and developers to retrieve information or generate reports through conversation rather than writing SQL queries manually.</p><h3>Monitoring and Observability with Datadog</h3><p>A Datadog MCP server provides easy access to monitor states and Kubernetes logs through a simple interface. This server enables real-time view of system status and function call logs, allowing developers to maintain visibility into their systems through natural language interactions.</p><h3>Developer Tooling with python_local</h3><p>The python_local MCP Server creates an interactive environment that allows users to run Python code locally, providing a Read-Eval-Print Loop (REPL) experience. This server maintains separate session states, supports multiple sessions simultaneously, and captures both standard and error outputs from executed code, making it a valuable tool for rapid prototyping and debugging.</p><h3>Resources for Learning More</h3><p>The MCP ecosystem is rapidly growing, with new servers, tools, and educational resources appearing regularly. Here are some valuable resources for developers interested in exploring MCP further:</p><h3>MCP Server Repositories</h3><h4>Anthropic’s Official Resources</h4><ul><li><strong>Official MCP Documentation</strong>: <a href="https://docs.anthropic.com/claude/docs/model-context-protocol">https://docs.anthropic.com/claude/docs/model-context-protocol</a></li></ul><h4>Community Resources</h4><ul><li><strong>Quickstart For Server Developers:</strong> <a href="https://modelcontextprotocol.io/quickstart/server">https://modelcontextprotocol.io/quickstart/server</a></li><li><strong>MCP Server Registry</strong>: <br><a href="https://mcp.so/">https://mcp.so</a> (community registry of MCP servers)</li><li><strong>Awesome AI Tools List</strong>: <br><a href="https://github.com/topics/mcp-server">https://github.com/topics/mcp-server</a> (GitHub topic for MCP servers)</li></ul><h3>MCP Server Discovery</h3><ul><li><a href="https://glama.ai/mcp/servers">Glama.ai </a>MCP Server Directory — A directory of MCP servers with detailed information</li><li><a href="https://mcp.so/">MCP.so</a> — A platform for discovering and sharing MCP servers</li></ul><h3>Conclusion</h3><p>Model Context Protocol represents a significant advancement in extending AI capabilities through structured, secure integrations with external systems. By providing a standardized way for AI assistants to interact with tools, data sources, and services, MCP enables more powerful and flexible AI applications without compromising security or privacy.</p><p>The Python implementation of a Kubernetes MCP server we’ve explored demonstrates how developers can create practical, valuable tools that enhance the development and debugging process. By connecting AI assistants with the systems developers use daily, MCP servers reduce context switching, enable more natural interactions with complex systems, and leverage AI capabilities for tasks like pattern recognition and analysis.</p><p>As the MCP ecosystem continues to mature, we can expect to see even more innovative applications that combine AI reasoning with specialized tools and services. The boundary between AI assistants and the digital tools we use daily will increasingly blur, creating more seamless, efficient, and powerful computing experiences.</p><p>The time to explore MCP is now — whether you’re building AI agents, streamlining development workflows, or just curious about the future of AI systems, MCP offers a front-row seat to the next wave of evolution.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=9da76c7da410" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[HTTP Request Journey to Kubernetes: Technical Deep Dive]]></title>
            <link>https://ugurcemozturk.medium.com/http-request-journey-to-kubernetes-technical-deep-dive-c2a7493edf07?source=rss-5f14504ab1bb------2</link>
            <guid isPermaLink="false">https://medium.com/p/c2a7493edf07</guid>
            <category><![CDATA[http-request]]></category>
            <category><![CDATA[web-development]]></category>
            <category><![CDATA[cloudflare]]></category>
            <category><![CDATA[devops]]></category>
            <category><![CDATA[kubernetes]]></category>
            <dc:creator><![CDATA[Ugur Cem Ozturk]]></dc:creator>
            <pubDate>Sun, 29 Sep 2024 20:31:02 GMT</pubDate>
            <atom:updated>2024-09-29T20:39:16.891Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*NhZX3037tDlG-hFq" /></figure><p>Imagine a client sends an HTTP request to api.acme.com, which is hosted on a Kubernetes cluster in AWS. Cloudflare manages DNS, and an AWS Elastic Load Balancer (ELB) is in place to route traffic to the Kubernetes API. Here&#39;s how that request moves through the system, step by step.</p><h3>1. Cloudflare DNS Resolution</h3><p>When the client makes a request to api.acme.com, the browser or application performs a DNS lookup to resolve the domain to an IP address. Since Acme Inc. is using Cloudflare as the DNS provider, Cloudflare plays a pivotal role in this first step.</p><ul><li><strong>Cloudflare DNS</strong> resolves the request using <strong>Anycast routing</strong>, which means the request will hit the nearest Cloudflare edge server.</li><li>Cloudflare DNS uses <strong>TTL (Time To Live)</strong> values to cache and respond quickly with the pre-configured IP address of the AWS Elastic Load Balancer.</li></ul><p><strong>Example Request</strong>:</p><pre>dig api.acme.com</pre><p><strong>Response</strong>:</p><pre>api.acme.com. 300 IN A 203.0.113.10</pre><ul><li>The IP address returned (203.0.113.10) corresponds to the AWS Elastic Load Balancer.</li></ul><blockquote><strong>Optional Optimization (Cloudflare CDN)</strong>: If Cloudflare is also used as a CDN, cached responses could be returned from Cloudflare edge locations, reducing latency. But in this example, we assume the request must go all the way to the Kubernetes cluster.</blockquote><h3>2. AWS Load Balancer: First Entry Point into AWS</h3><p>Once the request is resolved to an IP address, the client sends an HTTP request directly to the AWS Elastic Load Balancer (ELB). The ELB in this architecture is configured as a Layer 7 (Application Layer) load balancer.</p><p><strong>Types of Load Balancers in AWS</strong>:</p><ul><li><strong>Application Load Balancer (ALB)</strong>: Works at Layer 7 and is capable of inspecting HTTP/HTTPS requests, routing based on host/path, and offloading TLS termination.</li><li><strong>Network Load Balancer (NLB)</strong>: Operates at Layer 4 (Transport Layer), primarily for TCP/UDP-based traffic. It forwards traffic based on IP and port.</li></ul><p>In this case, the ALB (Layer 7) is responsible for routing the traffic to the Kubernetes cluster based on its <strong>Target Group</strong> configuration. The target group is made up of Kubernetes worker nodes.</p><p><strong>AWS ALB routing decision</strong>:</p><ol><li><strong>HTTP Host/Path Matching</strong>: The ALB inspects the request to match its <strong>host-based routing rules</strong>. It sees the host is api.acme.com and routes the request to the corresponding target group that points to Kubernetes worker nodes.</li><li><strong>Target Health Checks</strong>: The ALB checks if the worker nodes in the target group are healthy by making periodic health check calls to endpoints exposed by Kubernetes.</li></ol><p><strong>Health Check Example</strong>:</p><pre>GET /healthz HTTP/1.1<br>Host: 203.0.113.10</pre><ul><li><strong>Routing Mechanism</strong>: The ALB forwards the request to a healthy Kubernetes worker node, based on <strong>round-robin</strong>, <strong>least connections</strong>, or other load balancing algorithms, as defined in the target group configuration.</li></ul><h3>3. Kubernetes Worker Nodes: Entry into the Cluster</h3><p>Now that the request has reached one of the Kubernetes worker nodes, the load balancer’s job is done. Inside the cluster, Kubernetes takes over routing.</p><p><strong>Kubernetes API Communication</strong>:</p><ul><li><strong>API Version</strong>: v1</li><li><strong>Component</strong>: kube-proxy</li><li><strong>Kubernetes Service Type</strong>: The service fronting the pods is typically of type <strong>ClusterIP</strong> or <strong>NodePort</strong> when used with an external load balancer like ALB. In this case, we assume <strong>NodePort</strong> is used.</li></ul><p>On the worker node, <strong>kube-proxy</strong> manages networking. It ensures that traffic directed to a specific <strong>NodePort</strong> is forwarded to the appropriate service.</p><p><strong>kube-proxy Routing</strong>:</p><ul><li><strong>Service IP Resolution</strong>: kube-proxy uses iptables (or ipvs in more recent setups) to map incoming requests on a specific <strong>NodePort</strong> to the internal cluster IP of the service.</li></ul><p><strong>NodePort Example</strong>:</p><pre>api-service:<br>  type: NodePort<br>  ports:<br>    - port: 80<br>      targetPort: 8080<br>      nodePort: 30080</pre><ul><li>The NodePort 30080 is open on all worker nodes, and kube-proxy knows to forward requests coming in on this port to the corresponding api-service.</li></ul><h3>4. Ingress Controller: Managing External Access</h3><p>Next, the request reaches the <strong>Ingress Controller</strong>, which is responsible for routing traffic to specific services within the cluster.</p><ul><li><strong>Ingress Controller</strong>: Could be <strong>NGINX</strong>, <strong>Traefik</strong>, or another implementation.</li><li><strong>Ingress Resource Definition</strong>: Defines rules for routing traffic to internal services based on hostnames or paths. For api.acme.com, the Ingress resource may look like:</li></ul><pre>apiVersion: networking.k8s.io/v1<br>kind: Ingress<br>metadata:<br>  name: api-ingress<br>spec:<br>  rules:<br>    - host: api.acme.com<br>      http:<br>        paths:<br>        - path: /<br>          backend:<br>            service:<br>              name: api-service<br>              port:<br>                number: 80</pre><p><strong>Routing Process</strong>:</p><ul><li>The Ingress Controller checks the incoming host (api.acme.com) and forwards the request to the service api-service.</li></ul><h3>5. Kubernetes Service: Traffic Routing to Pods</h3><p>The <strong>api-service</strong> is a Kubernetes resource that abstracts access to a group of pods running the API. It ensures that traffic gets forwarded to one of the available pods.</p><ul><li><strong>Service IP</strong>: The service has a stable cluster-internal IP address (managed by <strong>kube-dns</strong> or <strong>CoreDNS</strong>) to ensure other services or components can communicate with it.</li><li><strong>Pod Selection</strong>: The service selects the correct pod using label selectors. For example, it might route traffic to any pod with the label app: api.</li></ul><pre>apiVersion: v1<br>kind: Service<br>metadata:<br>  name: api-service<br>spec:<br>  selector:<br>    app: api<br>  ports:<br>    - protocol: TCP<br>      port: 80<br>      targetPort: 8080</pre><p><strong>Routing Mechanism</strong>:</p><ul><li>The service distributes traffic between all healthy pods using round-robin or other load balancing strategies.</li><li>Traffic is forwarded to the pod via the cluster network (CNI plugin), such as <strong>Flannel</strong>, <strong>Calico</strong>, or <strong>Weave</strong>.</li></ul><h3>6. The Pod: The Final Destination</h3><p>Finally, the request arrives at the pod. This pod contains a running instance of the API in a container (e.g., a Docker container). The container processes the request, performs the necessary business logic, and generates a response.</p><ul><li><strong>Pod Lifecycle</strong>: The pod is created, scheduled, and monitored by the <strong>kubelet</strong> running on the worker node. It listens for requests on the specified port (e.g., 8080).</li><li><strong>Pod IP</strong>: Each pod gets its own IP address (assigned by the cluster network plugin), and the service forwards traffic to this pod using internal cluster networking.</li></ul><p><strong>Example Pod</strong>:</p><pre>apiVersion: v1<br>kind: Pod<br>metadata:<br>  name: api-pod<br>  labels:<br>    app: api<br>spec:<br>  containers:<br>    - name: api-container<br>      image: acme/api:latest<br>      ports:<br>        - containerPort: 8080</pre><p>The pod receives the HTTP request, processes it, and sends back an HTTP response. This response traverses the same path back — through the service, the ingress, the load balancer, and finally back to the client.</p><h3>Conclusion</h3><p>In this journey, an HTTP request traverses multiple layers: DNS resolution via Cloudflare, load balancing with AWS ELB, Kubernetes node routing via kube-proxy, and finally traffic routing within the cluster via the Ingress Controller and Kubernetes service. Understanding this detailed flow helps you design scalable, resilient, and efficient Kubernetes deployments.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=c2a7493edf07" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[AWS CloudFront CDN Güvenliği 1: Signed URLs]]></title>
            <link>https://medium.com/devopsturkiye/aws-cloudfront-cdn-g%C3%BCvenli%C4%9Fi-1-signed-urls-2c3c9a01cc3a?source=rss-5f14504ab1bb------2</link>
            <guid isPermaLink="false">https://medium.com/p/2c3c9a01cc3a</guid>
            <category><![CDATA[aws]]></category>
            <category><![CDATA[lambda]]></category>
            <category><![CDATA[s3]]></category>
            <category><![CDATA[signed-urls]]></category>
            <category><![CDATA[api-gateway]]></category>
            <dc:creator><![CDATA[Ugur Cem Ozturk]]></dc:creator>
            <pubDate>Mon, 17 Aug 2020 16:10:53 GMT</pubDate>
            <atom:updated>2020-08-18T09:48:26.186Z</atom:updated>
            <content:encoded><![CDATA[<h3>AWS CloudFront ve S3 Veri Güvenliği 1: Signed URLs</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*Lijw-I0VkvFUdI5xSC1OKg.png" /><figcaption>Credits: <a href="https://undraw.co/illustrations">https://undraw.co/illustrations</a></figcaption></figure><p>AWS S3&#39;deki dosyalarınızı bir CDN(AWS CloudFront) üzerinden paylaşırken, iş mantığı, dosya URL’lerinin <em>public</em> ama herkes tarafından erişilemez olmasını gerektirebilir, <em>ironi değil</em>. AWS CloudFront, bunun için CloudFront Signed URL adını verdiği, imza ve expire temelli bir güvenlik yöntemi sunuyor.</p><p>Hikaye kısa ve öz olsun;</p><ul><li>Bir S3 bucketında fotoğraflarım var. Bucket, public olarak erişilemez olmalı. Onun yerine, fotoğraflarım CDN(AWS CloudFront) üzerinden servis edilmeli.</li><li>CDN’e foto.com domaini üzerinden eriştiğimizi varsayalım. Fotoğraflarımın güvenliğini sağlamak için, adresimi bilen herkesin foto.com/mezuniyet.png üzerinden resimlere ulaşmamasını istiyorum.</li></ul><p>AWS CloudFormation, Signed URL ile bunu çözüyor. Bu çözüm basitçe, bir lambda ile istenen fotoğraf URL’ni <em>imzalıyor</em> ve yeniden kullanımı kısıtlamak için <em>son kullanım tarihi </em>atıyor<em>.</em></p><p>Çözümün mimarisi basit ve öz olsun;</p><ol><li>AWS Lambda: İstenen dosya eğer varsa, URL’ini imzalayıp (Signed URL) geri döndüren servis.</li><li>API Gateway: Lambda fonksiyonunun API isteklerini karşılayan, fonksiyonu çağıran/yönlendiren servis.</li><li>S3: Resimlerimizin tutulduğu servis.</li><li>CloudFront: Resimlere, istek atılan konuma bağlı en yakın CDN’den cevap dönen servis. Not: Lambda ve Cloudfront, Lambda@Edge servisiyle beraber mucizeler çıkarıyor.</li></ol><h3>Gereksinimler</h3><ol><li>S3 bucket</li><li>Bu bucket’dan dosya erişimi sağlayan CDN/Cloudfront Distribution</li><li><strong>Root account ile yaratılmış</strong> Cloudfront Key-Pair (<a href="https://docs.aws.amazon.com/AmazonCloudFront/latest/DeveloperGuide/private-content-trusted-signers.html">Böyle</a>)</li></ol><h3>Teori</h3><p>Diyelim ki siz pullara meraklı bir <strong>aşçısınız</strong>.</p><p>Bir <strong>kasanın</strong> içinde <strong>pullar</strong> var. Kasa şifreli ve bu şifre bu her gün değişiyor. Kasayı açmak için gerekli olan <strong>şifreyi</strong> ise, sizi tanıyan bir <strong>bahçıvan</strong> var, ondan öğrenebilirsiniz. Aşçı, pulları görmek için, her gün bu bahçıvana şifreyi sormalı. Aşçıya bahçıvanın yerini söyleyen ve eşlik eden bir de <strong>uşak</strong> var.</p><p><strong>Uşak</strong> = <em>API Gateway</em> — HTTP isteklerini ile lambda fonksiyonunu çalıştıran servis<br><strong>Bahçıvan</strong> = <em>Lambda</em> — Resmin signed URL’ini dönen Lambda fonksiyonu<br><strong>Aşçı</strong> = <em>Client — </em>Uygulamamıza resim alma isteği atan client<br><strong>Kasa </strong>= S3 — Resimleri sakladığımız S3 Bucket<br><strong>Pullar </strong>= S3 Objects — Resimler<br><strong>Şifre</strong> = Signed URL</p><h3>Teknik Açıklama</h3><p><a href="http://d111111abcdef8.cloudfront.net/image.jpg">myApp.cloudfront.net</a> üzerinden resim.png dosyasıni almak için, CDN dosyanın URI’sine ek olarak query string’de signed URL’e ait parametreler beklemektedir.</p><p>Tüm URL’in omurgası: (<a href="https://docs.aws.amazon.com/AmazonCloudFront/latest/DeveloperGuide/private-content-creating-signed-url-custom-policy.html">Resmi dökümandan</a>)</p><p><a href="http://d111111abcdef8.cloudfront.net/image.jpg">http://myApp.cloudfront.net/</a><br>?<strong>img=resim.png</strong><br><strong>Policy</strong>=eyANCiAgICEXAMPLEW1lbnQiOiBbeyANCiAgICAgICJSZXNvdXJjZSI6Imh0dHA 6Ly9kemJlc3FtN3VuMW0wLmNsb3VkZnJvbnQubmV0L2RlbW8ucGhwIiwgDQogICAgICAiQ 29uZGl0aW9uIjp7IA0KICAgICAgICAgIklwQWRkcmVzcyI6eyJBV1M6U291cmNlSXAiOiI yMDcuMTcxLjE4MC4xMDEvMzIifSwNCiAgICAgICAgICJEYXRlR3JlYXRlclRoYW4iOnsiQ VdTOkVwb2NoVGltZSI6MTI5Njg2MDE3Nn0sDQogICAgICAgICAiRGF0ZUxlc3NUaGFuIjp 7IkFXUzpFcG9jaFRpbWUiOjEyOTY4NjAyMjZ9DQogICAgICB9IA0KICAgfV0gDQp9DQo<br>&amp;<strong>Signature</strong>=nitfHRCrtziwO2HwPfWw~yYDhUF5EwRunQA-j19DzZrvDh6hQ73lDx~ -ar3UocvvRQVw6EkC~GdpGQyyOSKQim-TxAnW7d8F5Kkai9HVx0FIu-5jcQb0UEmat EXAMPLE3ReXySpLSMj0yCd3ZAB4UcBCAqEijkytL6f3fVYNGQI6<br>&amp;<strong>Key-Pair-Id</strong>=APKA9ONS7QCOWEXAMPLE</p><p>Parça parça:</p><ol><li><strong>Base URL</strong>=Cloudfront ya da ona bağlı root domain name</li><li><strong>Object key</strong>=İstenilen S3 nesnesinin adı.</li><li><strong>Policy</strong>= Base64 kodlanmış, JSON formatında access policy. Bu policyler, imzalanmış bir URL’nin bir kullanıcıya verdiği erişimi kontrol eder: Bu erişim seçenekleri bayağı bir geniş;<br>- <em>Dosyanın </em><strong><em>URL’i</em></strong><em>,<br>- Geçerliliğinin </em><strong><em>sona erme</em></strong><em> tarihi ve saati, <br>- Geçerliiğinin </em><strong><em>başlama</em></strong><em> tarihi ve saati,<br>- Erişime</em><strong><em> izin verilen IP</em></strong><em> veya IP aralığı.</em></li><li><strong>Signature</strong>= Hashlenmiş ve imzalanmış policy.</li><li><strong>Key-Pair-ID</strong>= Environment variable olarak kaydettiğimiz/kaydedeceğimiz Cloudfront Key-Pair ID.</li></ol><h3>Uygulama</h3><p>Çalışır uygulama çeşitli AWS servisleri (Amazon Web Services servisleri, tezat değil mi?..) içeriyor. Kolayca deploy etmeniz için en sona bir Cloudformation template bırakıyorum. Template’i ve açıklamasını , odaktan kopmamak için en sonda anlatacağım.</p><p>Flow şu şekilde:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*T5NshKyequKZy0zmbrDTFg.jpeg" /></figure><p>Query string (/?img=resim.png) ile istenen resmi, S3 üzerinden alıp, imzalanmış URL’ini dönen lambda fonksiyonumuz basit ve öz olsun:</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/22a1d21be5728c04638c83dfd615ec46/href">https://medium.com/media/22a1d21be5728c04638c83dfd615ec46/href</a></iframe><p>Satır satır açıklama:</p><p><strong>7-</strong> Query string’den istenen resim <strong>dosya/nesne adı</strong>(diyelim ki resim.png),<br><strong>8- </strong>S3 bucket adı ile dosya adını birleştirip, <strong>resmin full path’i,</strong><br><strong>10-</strong> Environment variable olarak tuttuğumuz <strong>Cloudfront key-pair ID’si,</strong><br><strong>11- </strong>Dosya olarak tuttuğumuz <strong>Cloudfront key-pair private key</strong>(production ortamında dosya olarak tutmayın.) Bu private key ile URL imzalanacak ve gelen isteklerdeki URL’in doğruluğu kontrol edilecek,<br><strong>12-</strong> Key-pair ID ve private key ile, AWS’in sunduğu<strong> signer objesi,</strong><br><strong>13- </strong>Environment variable olarak tuttuğumuz Cloudfront domain name ve S3 objesi için, expire’da belirtilen son kullanma süresi ile, bir <strong>signed Cloudfront URL</strong> yarattık.</p><p>Sonrasında başarılı ise 200 durum kodu ile URL döndük ya da hata oldu ise 400 ile hata döndük.</p><p>Bu kadar basit ve belki de ‘managed’ bir çözüm. İşlem developmentdan ziyade operasyonel bir yaklaşım ile çözülüyor.</p><p>Çözümü test edebilmeniz adına, kolayca deploy edebileceğiniz bir Cloudformation template bırakıyorum. Bu template ne içeriyor?</p><ul><li><strong>API Gateway</strong>: İstekleri karşılayıp, Lambda’ya iletmek için.(Varsa authentication, validation, custom response etc..)</li><li><strong>Lambda</strong>: İstenen dosyanın Signed RL’ini yaratmak içim.</li><li><strong>Origin Access Identity(OAI): </strong>S3 Bucket’ına, belirlenen AWS servisleri dışında hiçbir erişim olmaması için(Önemli. Bunun hakkında ayrı bir yazı yazacağım.)</li><li><strong>S3 Bucket Policy</strong>: Bucket erişim için allow/deny policy.</li><li><strong>Cloudfront Distribution</strong>: S3 Bucket için cache server/CDN servisi.</li></ul><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/2585dfe0712ecbec37d74c3c84158f67/href">https://medium.com/media/2585dfe0712ecbec37d74c3c84158f67/href</a></iframe><p>Umarım kısa, öz ve faydalı olmuştur.</p><p>Cem.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=2c3c9a01cc3a" width="1" height="1" alt=""><hr><p><a href="https://medium.com/devopsturkiye/aws-cloudfront-cdn-g%C3%BCvenli%C4%9Fi-1-signed-urls-2c3c9a01cc3a">AWS CloudFront CDN Güvenliği 1: Signed URLs</a> was originally published in <a href="https://medium.com/devopsturkiye">Devops &amp; AI Türkiye☁️ 🐧 🐳 ☸️</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[How to consume 3rd party web services over Ethereum Network?]]></title>
            <link>https://medium.com/coinmonks/how-to-consume-3rd-party-web-services-over-ethereum-network-3363d6ecd301?source=rss-5f14504ab1bb------2</link>
            <guid isPermaLink="false">https://medium.com/p/3363d6ecd301</guid>
            <category><![CDATA[smart-contracts]]></category>
            <category><![CDATA[ethereum]]></category>
            <category><![CDATA[tutorial]]></category>
            <category><![CDATA[solidity]]></category>
            <category><![CDATA[oraclize]]></category>
            <dc:creator><![CDATA[Ugur Cem Ozturk]]></dc:creator>
            <pubDate>Wed, 23 May 2018 11:40:54 GMT</pubDate>
            <atom:updated>2018-05-24T07:20:09.425Z</atom:updated>
            <content:encoded><![CDATA[<p>May sound confusing, but trust me it’s an easy-peasy work to do. So how do I come up with this tutorial? There are tons and millions of Solidity code samples that gives a simple ‘Hello World’ output. It’s cool, at least you work with a new language but not enough, not useful.</p><p>In the era of Web Development, 3rd party API call is like breathing. So I start to do research about making API calls with Solidity over Ethereum network. The solution I come up with is <a href="http://app.oraclize.it/home/features"><strong>Oraclize</strong></a><strong>, </strong><em>-data carrier for decentralized apps.- </em>Unfortunatelly, this is a paid service. Fortunatelly, we will work on Ropsten Network which is a test network that we pay fake ETHs for any kind of transaction.</p><h3>Requirements</h3><ul><li>Ethereum Address on that will work on Ropsten Network</li><li>Some amount of free test Ethereum</li></ul><p>To get free Ropsten ETHs, there are some faucets. Such as: <a href="http://faucet.ropsten.be:3001/">http://faucet.ropsten.be:3001/</a> .Simply paste your ETH address and Test Ethers will be loaded in your account within minutes.</p><h3>Roadmap</h3><p>1 Find a web service to consume. I’ve just build one with Express, simply returns a string. You could wotk with it, feel free to use. (<a href="https://ihk.herokuapp.com/">https://ihk.herokuapp.com/</a>)</p><p>2 Finding which environment fits the best for demo issues. There’re two options to compile and run our smart contract: <a href="http://remix.ethereum.org/"><strong>Remix </strong></a>and <a href="http://dapps.oraclize.it/"><strong>Oraclize IDE</strong></a>. I’ll go with Oraclize IDE.</p><p>If you’ll work with Remix , you have to select <strong>Injected Web3, </strong>otherwise the code won’t work with Javascript VM as expected.</p><h3>Let’s Code!</h3><p>There it is, a Solidity code at its simplest and clearest.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/1abcbc1eadfbc944ee18c7113fd0b5fd/href">https://medium.com/media/1abcbc1eadfbc944ee18c7113fd0b5fd/href</a></iframe><p>So let’s go step by step.</p><p><strong>#6 </strong>We’ll work with version 0.4.19 Compiler. Because Oraclize supports the versions between<strong> 0.4.1</strong> and <strong>0.4.2</strong>. To do this, do not forget the change the compiler version(<em>0.4.19+commit.####</em>) from Settings Tab.</p><p><strong>#7 </strong>Let’s import the Oraclize repository.</p><p><strong>#11 </strong>The only variable that contract stores. The result of the API call will be assigned to this variable.</p><p><strong>#15–17 </strong>Simply, the constructor of our smart contract. We’ll talk about the update method. It’s not built-in, it’s declared by our contract that you can see at the last lines of the contract.</p><p><strong>#19–22 </strong>The callback state that triggers after request execution. We could manipulate the resulted data here. But for this case, we don’t need any kind of manipulation.</p><p><strong>#24–27 </strong>There it is. The place where sun never sets, the place we send the request. There is a extreamly important , life-saver point to modify a method argument based on your MIME type of the services response. We have to re-write second argument based on what our service serves. JSON,XML, etc..</p><blockquote>If it’s <strong>JSON</strong> ; <br>oraclize_query(“URL”, “<strong>json</strong>(https://ihk.herokuapp.com/)&quot;);</blockquote><blockquote>Or <strong>XML</strong>;<br>oraclize_query(“URL”, “<strong>xml</strong>(https://ihk.herokuapp.com/)&quot;);</blockquote><p>Our service will return just a text without a fancy format, simple http/text, so no remove there is casting process.</p><p>Let’s Compile our code. The result screen should seem similar to this:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/800/1*_u1_icRVok7DIvJwjJkdyg.png" /></figure><p>Let’s click to “Create” button. The contract run, mined and done. Now, there should be section that shows the list of method that we can run over our contract. Seems like that:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/526/1*3hmNprWBiAU7hRSOxWJwwA.png" /></figure><p>The update method is the method that we consume the service, we get the data. The request will be done between 10–20 seconds.</p><p>Let’s take a deep breath. Hold it. Hold it. A little bit more. Now, slowly, exhale. Very slow. Perfect. The API call should be done.</p><p>Let’s jump to the 4th section on the top, named “Queries”.</p><p>There it is. The result. Says, “<a href="https://www.reddit.com/r/Turkey/comments/5lgyuq/what_is_imam_hatipler_kapatlisin/">Imam hatipler kapatilsin</a>.” -A famous, funny Turkish meme-.</p><p>See you soon.</p><p>Cheers,<br>Ugur Cem.</p><iframe src="https://cdn.embedly.com/widgets/media.html?type=text%2Fhtml&amp;key=a19fcc184b9711e1b4764040d3dc5c07&amp;schema=reddit&amp;url=https%3A//www.reddit.com/r/Turkey/comments/5lgyuq/what_is_imam_hatipler_kapatlisin/&amp;image=https%3A//i.embed.ly/1/image%3Furl%3Dhttps%253A%252F%252Fwww.redditstatic.com%252Ficon.png%26key%3Da19fcc184b9711e1b4764040d3dc5c07" width="600" height="400" frameborder="0" scrolling="no"><a href="https://medium.com/media/a6905f985d092ae9aae2b50155dbeb3a/href">https://medium.com/media/a6905f985d092ae9aae2b50155dbeb3a/href</a></iframe><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=3363d6ecd301" width="1" height="1" alt=""><hr><p><a href="https://medium.com/coinmonks/how-to-consume-3rd-party-web-services-over-ethereum-network-3363d6ecd301">How to consume 3rd party web services over Ethereum Network?</a> was originally published in <a href="https://medium.com/coinmonks">Coinmonks</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Ethereum Akıllı Sözleşmeleri ile 3. Parti Servislerden Veri Çekmek]]></title>
            <link>https://ugurcemozturk.medium.com/ethereum-ak%C4%B1ll%C4%B1-s%C3%B6zle%C5%9Fmeleri-ile-3-parti-servislerden-veri-%C3%A7ekmek-f2acf6c7a41c?source=rss-5f14504ab1bb------2</link>
            <guid isPermaLink="false">https://medium.com/p/f2acf6c7a41c</guid>
            <category><![CDATA[solidity]]></category>
            <category><![CDATA[smart-contracts]]></category>
            <category><![CDATA[ethereum]]></category>
            <category><![CDATA[blockchain]]></category>
            <dc:creator><![CDATA[Ugur Cem Ozturk]]></dc:creator>
            <pubDate>Fri, 18 May 2018 11:10:58 GMT</pubDate>
            <atom:updated>2018-05-18T11:10:58.455Z</atom:updated>
            <content:encoded><![CDATA[<p>Bir önceki yazıda Ethereum Network’ü üzerinden ERC20 standardı ile kendi tokenımızı yaratmıştık. Ethereum ekibi, geliştiricideki yükü en aza indirmek için sağladığı soyut arayüzler ile bunu bir kaç satırlık kod değişiklikleri ile yapabiliyoruz.</p><blockquote>Ethereum ne yapmak, nereye varmak istemektedir?</blockquote><p>Akıllı sözleşmelerle haşır neşir(neşir?) olmak için örneklere baktığımda, bir çoğu aynı ağ üzerinde yapılan senaryolardan ibaretti, ki bir web servise bağlanıp veri çekmek/itmek de <a href="http://www.adabasini.com/haber/adanada-gunese-silah-sikan-iki-kisi-gozaltina-alindi-366028.html"><em>güneşe silah sıkmak</em></a> kadar normal bir senaryo.</p><p>Şu an ethereum ağından çıkıp ‘hadi bi gez gel’ diyebilmek için, bir adet servis var. <a href="http://app.oraclize.it/"><strong>Oraclize</strong></a><strong>, </strong>dağıtık uygulamalar için veri taşıyıcısı. Oraclize ücretli bir servis ama test networkünde çalışacağımız için problem değil.</p><h3>Requirements</h3><ul><li>MetaMask</li><li>Ethereum Address</li><li>Ropsten Network üzerinde çalışması için adrese yüklenmiş bir kaç Ether</li></ul><p>Nereden ve nasıl yükleneceği için bir önceki ERC20 Token yaratma yazısına göz atabilirsiniz.</p><h3>Roadmap</h3><p>1 Consume edilecek web servisi belirlemek. Demo için bir adet hazırladım. Feel free to use. (<a href="https://ihk.herokuapp.com/">https://ihk.herokuapp.com/</a>)</p><p>2 Platform seçimi. Sözleşmemizi derlemek ve koşturmak için 2 seçeneğimiz var ; <a href="http://remix.ethereum.org/"><strong>Remix </strong></a>ya da <a href="http://dapps.oraclize.it/"><strong>Oraclize IDE</strong></a>.</p><p>Remix üzerinden gidecekseniz Environment olarak Injected Web3 kullanmak zorundasınız, Javascript VM ile ayağa kalkmıyor. İlle de Javascript VM olacak, MetaMask ile uğraşmayacağım diyorsanız sizi Oraclize IDE’ye alalım. Ben Oraclize IDE üzerinden gideceğim.</p><p>Koda geçelim. Sözleşemizin tamamını yapıştırıp üzerinden gideceğim. Kodumuz solidity kodu, ‘.sol’ uzantılı.</p><blockquote>Çare .sol’da. Solidity’de.</blockquote><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/54d12975dc05866726e5ee31e50343af/href">https://medium.com/media/54d12975dc05866726e5ee31e50343af/href</a></iframe><p>Satır satır gidelim;</p><p><strong>#6 </strong>Compiler versiyonu olarak <strong>0.4.19 </strong>kullanacağız. Oraclize şu an için <strong>0.4.1≤<em>version</em>≤0.4.2</strong> aralığını destekliyor. Bunun için aynı anda Oraclize IDE’de <em>Settings tab</em>’ında <em>Compiler Version</em>’u <em>0.4.19+commit.#### </em>yapmayı unutmayın.</p><p><strong>#7 </strong>Oraclize reposunu import ediyoruz.</p><p><strong>#11 </strong>Uygulamadaki tek değişkenim, web servisin döndürdüğü sonucu bu değişkene atayacağız.</p><p><strong>#15–17 </strong>Sözleşmemizin yapıcı methodu. İçeriside birazdan konuşacağımız update methodunu, yaratıldığı anda servisi kullanmak için çağırıyoruz.</p><p><strong>#19–22 </strong>Web servise isteğim yollandıktan sonraki callback state’im. Burada sonucumuzu manipüle de edebilirdik, sadece değişkenimize atadık.</p><p><strong>#24–27 </strong>İşte request’i attığımız yer. <strong>oraclize_query </strong>methodu hakkında çok önemli birşey var. Servisinizin veriyi sunduğu MIME type’a göre ikinci parametreyi düzenlememiz gerekiyor.</p><blockquote>Eğer <strong>JSON </strong>tipinde veri döndürseydi ; <br>oraclize_query(“URL”, “<strong>json</strong>(https://ihk.herokuapp.com/)&quot;);</blockquote><blockquote>Ya da <strong>XML</strong>;<br>oraclize_query(“URL”, “<strong>xml</strong>(https://ihk.herokuapp.com/)&quot;);</blockquote><p>Benim servisim text döndürdüğü için bir type girmedim. Ki en çok vakti de başına text, text/html vs yazarak deneme zamanında kaybettim.</p><p>Şimdi kodumuzu compile edelim. Şöyle bir ekran gelecek;</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*foamZPuDA2QjKGcEUiUKEg.png" /></figure><p>Sağdaki create butonuna basalım. Sözleşmemiz ayağa kalktı, mine edildi ve sonuçlandı. Şimdi uygulamamızda çalıştırılabilecek methodların listelendiği bir sekme gelmiş olmalı, beyle ;</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/526/1*E83JOVfPCpP1uma80mX_Ug.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/480/1*3DknJVOW01Hdt6XKezzCDA.jpeg" /></figure><p>Buradaki update methodu veriyi çektiğimiz yer, ki biz onu constructor’ımızda zaten çağırmıştık, contract ayağa kalkarken requestimiz gitti. Şimdi 10 saniye methodumuzun sonuçlanması için bekleyelim.</p><blockquote><a href="https://www.google.com.tr/search?q=ujjayi+breath&amp;oq=ujai+bre&amp;aqs=chrome.1.69i57j0l4.6613j1j4&amp;sourceid=chrome&amp;ie=UTF-8">Nefes egzersizi</a> için harika fırsat.</blockquote><p>Tamamlanmış olmalı, en üstteki tab’lerden 4.süne gelin, Queries sekmesine.<br>İşte geldi, orada. Bakın ne diyor.</p><blockquote><strong><em>Not</em></strong>: Kapatılmadı.</blockquote><p>Cheers,<br>Uğur Cem.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=f2acf6c7a41c" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Ethereum üzerinden nasıl coin çıkartılır? (Solidity — ERC20)]]></title>
            <link>https://ugurcemozturk.medium.com/m%C3%BCmk%C3%BCn-oldu%C4%9Funda-teknik-detaylar%C4%B1ndan-soyutlayarak-gidiyorum-atlay%C4%B1n-trene-648554ebb896?source=rss-5f14504ab1bb------2</link>
            <guid isPermaLink="false">https://medium.com/p/648554ebb896</guid>
            <category><![CDATA[erc20]]></category>
            <category><![CDATA[ethereum]]></category>
            <category><![CDATA[ethereum-blockchain]]></category>
            <category><![CDATA[blockchain]]></category>
            <category><![CDATA[blockchain-technology]]></category>
            <dc:creator><![CDATA[Ugur Cem Ozturk]]></dc:creator>
            <pubDate>Mon, 14 May 2018 11:07:59 GMT</pubDate>
            <atom:updated>2024-09-29T20:36:02.144Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/415/1*spSQQzz3VU8rLFJB9oKaGg.png" /></figure><blockquote>Dolandırıcı mısınız? Adının başına yerli milli koyup yengeyle Güney Amerika’ya mı gideceksiniz? Hiçbir programlama bilgim yok ama blockchain züper züper mi diyosunuz? Evet, doğru yerdesiniz. Bu kısacık yazı ile siz de kendi ERC20 Token’ınızı çıkarıp ICO başlatabilirsiniz. Ama yapmayın. Bu yasal değil ve bir suç unsurudur. Bu yazıdakiler kimseyi dolandırmanız için bir ön ayak değildir ve hiçbir sorumluluk kabul edilmez. Ethereum elden gidiyor.</blockquote><p>Mümkün olduğunda teknik detaylarından soyutlayarak gidiyorum, atlayın trene;</p><p>Blockchain güzel, monetization ondan güzel, ama sıfırdan blockchain yaratmak zor geliyor, evet. ERC20 tokenları bunun için var. Halihazırda tested/deployed bir sistem üzerinde kendi tokenınızı yaratabiliyorsunuz. Bunları ERC20 standardı üzerinde geliştirdiğiniz için(Bunun için ayrı bir emek sarfetmiyorsunuz), sistem güncellemelerinden tokenınız etkilenmiyor.</p><h3>Good to know:</h3><p>Bu token yaratma işine, Ethereum’u forklama da diyebiliriz.Diyelim. <strong>Smart Contract</strong>lar ile ETH networkü üzerinden token yaratabiliyoruz.</p><p><strong>Smart Contract:</strong> Akıllı Sözleşme. Hatta, insanları kandırmak için bunu okuyorsan, senden bile akıllı. Ve biraz masraflı. Her satırı için bir şey istiyor, adı GAS, GAS Price. O yüzden mümkün olduğunca optimize yazıyoruz bu Akıllı Sözlemeleri. Yazıldığı programlama dilinin adı ise <strong>Solidity.</strong></p><p><strong>MetaMask: </strong>Etherlerimizi saklamak için bir browser uzantısı. Bir nevi online cüzdan. Bu iyi, bu lazım. İndirelim bunu. ( bkz: <a href="https://metamask.io/">https://metamask.io/</a> )</p><p><strong>Ropsten Network: </strong>Bizim evde ayakkabı kutusunda ayakkabı olur. Bu yüzden tüm işlemlerimizi Test Network’de, sahte Ethereumlar ile yapacağız. Ropsten de Ethereum üzerinde bir test ağı. MetaMask’ı indirdiğinizde sağ üstte bağlanabileceğiniz tüm ağları görebilirsiniz.</p><h3>1) Ether Adresi Oluşturma</h3><p>MetaMask’ı indirdik. Contract adından bir cüzdan oluşturalım. Ben Chrome’dan yapıyorum, bunun için sağ üstte bulunan MetaMask logosuna tıklayıp, onun da sağ üstünde bulunan renkli avatara tıklayın. Oradan:</p><p>Hesap Oluştur -&gt; (Hesap Adınızı girin, adı Contract olsun) -&gt; Yarat</p><p>Voila. Hesabımız yaratıldı.</p><h3>2) Sözleşmemizi yaratma</h3><p>Solidity, akıllı sözleşmeler yazmak için kullandığımız dil. Remix’de bunu compile&amp;run etmek için kullandığımız platform. <a href="http://remix.ethereum.com/">http://remix.ethereum.com</a> ‘a gidelim.</p><p>Contract kodumuz şöyle, bir kaç satırı değiştirdik mi herşey tamam. Önce kopyalayıp kullandığınız editöre yapıştırın.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/acbb9a1158d54d1cf16c5cbd222eb73c/href">https://medium.com/media/acbb9a1158d54d1cf16c5cbd222eb73c/href</a></iframe><p>Değişecek satırlar :</p><ul><li>82: contract’tan sonraki kelimeyi istediğiniz token adı ile değiştirin. Bu örnek için MilliCoin yaptık.</li><li>95: function’dan sonraki kelime için de birebir aynı ismi verin.</li><li>96: Symbol olarak istediğimiz 3 harfliyi verelim.</li><li>97: Name bölümünde tokenımızın adını verelim.</li><li>99: _totalSupply, rezerve yarattığımız tokendan kaç tane olacağını belirler.</li><li>100,101: Burası önemli. 0x ile başlayan cüzdan adresleri var. Bunları MetaMask ile yarattığımız kendi adreslerimiz ile değiştireceğiz. Yine sağ üstteki MetaMask simgesine tıklayalım. Sol üstte (başıma birşey gelmeyecekse) paralel 3 çizgi var, menü simgesi. Ona tıklayalım. Şu ekran gelecek;</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/440/1*QZ48wcs2xKTz3GRf1G3Eqg.png" /></figure><p>Ayrıntıların altındaki 0x ile başlayan cüzdan adresine tıklayarak kopyalayalım.</p><ul><li>100 ve 101. satırdaki 0x ile başlayan adreslerle kopyaladığımız adresi değiştirelim.</li><li>Şimdi de test etmek için ücretsiz Ethereum’ları alalım. Bunun için <a href="http://faucet.ropsten.be:3001/"><strong>http://faucet.ropsten.be:3001/</strong></a> adresine gidip az önce kopyaladığımız cüzdan adresini buraya yapıştırın ve <strong>SEND ME 1 TEST ETHER</strong> butonuna tıklayın. Tamamdır, birazdan elimize ulaşır. MetaMask ile gelip gelmediğine bakabilirsiniz.</li></ul><h3>3) Sözleşmemizi Deploy Etme</h3><ul><li><a href="http://remix.ethereum.com/">http://remix.ethereum.com</a> ‘a gidelim. Ekrandaki tum kodları silip düzenlediğimiz sözleşmeyi buraya yapıştırın.</li><li>Sağdaki tablardan Run bölümüne gelin. Deploy bölümünün üzerindeki dropdown’dan adını verdiğiniz tokenı seçin ve deploya tıklayın. Tıklayınca MetaMask bir ekran açacak. İşte beyle:</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/473/1*faXP4lA_Um0kcSMDq4KQ4w.png" /></figure><p>Onaylayın. Ropsten ağında olup olmadığınızı iki kere kontrol edin. İşlemin onaylanması 30 saniye kadar alır. Durumunu kontrol etmek için işlemin TxHash’ini alıp <a href="https://etherscan.com/">https://etherscan.com</a> ile sorgulayabılırsiniz. Ya da metamask’a gelip işlemler listesinden sözleşme kurulumuna tıklayın. Direk etherscan sayfasını açacaktır. Şöyle birşey gözükmeli:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*6BXYCvJmmxLyVmmBD-WzWg.png" /></figure><ul><li>Şimdi ‘to’ satırındaki Contract adresine tıklayalım. Açılan sayfada, ortada, 3 tab var. Transactions, code, event. Code tabına tıklayalım.</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*nExQMxBh90CCm68DIbjpAA.png" /></figure><p>Buradan <strong>Verify And Publish </strong>linkine tıklayalım.</p><h3>4) Sözleşme Sahipliğini Doğrulama</h3><p>4 basit adım var.</p><ol><li>Tokenımızın adını Contract Name alanına yazmak,</li><li>Remix Compiler Versiyonunu yazmak (browser üzerinden url’e bakıp version kısmından öğrenebilirsiniz),</li><li>Optimization alanını ‘NO’ yapmak,</li><li>Remix ile çalıştırdığımız kodu en alttaki alana yapıştırma.</li></ol><p>Böyle Gözükmeli:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*qypCVPgl72N0JI1UuZ7Aig.png" /></figure><p>Eğer her şey tamamsa en alttaki <strong>Verify and Publish </strong>butonuna tıklayalım.</p><p>Bir sorun çıkmadıysa, ki birebir aynı gidiyorsak çıkmaması lazım; Şöyle bir ekran çıkması lazım.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/990/1*ra9zSmUe4cwoLId2bWRW2w.png" /></figure><h3>5) Herşey tamam. Şimdi test edelim.</h3><p>Şimdi MetaMask’a tekrar gelin. Soldaki paralel 3 çizgi olan metu butonuna tıklaıp “Jeton Ekle”ye tıklayalım. Üstteki 2. tab’2, Özel Jeton’a tıklayıp Jeton Adresi’ne sözleşme adresimizi girelim, diğer alanlar otomatik doldurulacak. “Sonraki”ne tıklayıp jetonumuzu tanımlayalım.</p><p>MetaMask’a gelin. Yeni bir hesap yaratın. Yukarıda yaptığımız gibi tekrar içine 2 adet test Ethereum’u yukleyin.</p><p>Bakiyemiz yüklendikten sonra contract adresine 1 ETH yollayıp beklemeye başlayalım. Burada olan şey, sözleşme adresine 1 ETH yolluyoruz. Sözleşme, kendisine ETH yollayan adrese sözleşmede belirlediğimiz miktarda gelen ETH miktarına göre yarattığımız Token’dan yollayacak. That’s it, we’re all set.</p><p>Bebek gibi bir newborn token yarattık. Umarım işinize yaramıştır ve umarım scam işleri için değerli vaktinizi harcamazsınız.</p><p>Teşekkürler,<br>Uğur Cem.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=648554ebb896" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[JSON Web Tokens(JWTs) ile Spring Boot uygulamalarında Authentication & Authorization ]]></title>
            <link>https://ugurcemozturk.medium.com/json-web-tokens-jwts-ile-spring-boot-uygulamas%C4%B1n%C4%B1-g%C3%BCvenceye-alma-38577fb5354b?source=rss-5f14504ab1bb------2</link>
            <guid isPermaLink="false">https://medium.com/p/38577fb5354b</guid>
            <category><![CDATA[authorization]]></category>
            <category><![CDATA[json-web-token]]></category>
            <category><![CDATA[spring-boot]]></category>
            <category><![CDATA[spring-security]]></category>
            <category><![CDATA[jwt]]></category>
            <dc:creator><![CDATA[Ugur Cem Ozturk]]></dc:creator>
            <pubDate>Wed, 06 Dec 2017 23:10:03 GMT</pubDate>
            <atom:updated>2020-08-07T15:21:44.217Z</atom:updated>
            <content:encoded><![CDATA[<blockquote>JWTs, Client-Server arasında tokenize işleminin JSON objesi kullanılarak yapılmasını sağlar. Server tarafında belirlenmiş bir Secret Key ve genellikle HMAC Algoritması kullanarak Token imzalanır.</blockquote><figure><img alt="" src="https://cdn-images-1.medium.com/max/844/1*XOOVVWekLf78yEBHeey3PA.png" /><figcaption>JWTs Workflow</figcaption></figure><p><strong>JWT bir Encryption değil, Encoding işlemidir!😱</strong></p><p>Detaylar ve demo için:</p><p><a href="https://jwt.io/">JSON Web Tokens - jwt.io</a></p><p>Öncelikle üzerinde çalışacağımız backbone’u indirelim.</p><pre>git clone -b backbone <a href="https://github.com/ugurcemozturk/JWT.git">https://github.com/ugurcemozturk/JWT.git</a></pre><p>Basit bir MVC yapısındaki bi modülleri kısaca açıklamak gerekirse:</p><ul><li><strong>Project</strong>: Entitiy modelimiz, data olarak kullanacağımız/kaydedeceğimiz yapı</li><li><strong>ProjectRepository</strong>: Modelimizin database işlemlerinden sorumlu yapı. Şimdilik in-memory DB olan HyperSQL işimizi görecektir.</li><li><strong>ProjectController</strong>: Server’a entity’miz ile ilgili gelen requestleri handle eden ve bir response dönen yapı.</li></ul><p>İlk olarak bir Model sınıfı yazmalıyız. “domain package” içerisinde Developer sınıfını yaratalım. Bu sınıf, giriş yapacak kullanıcıları temsil eden bir Entity sınıfıdır.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/7a08391db7fa77a404be5df20343877d/href">https://medium.com/media/7a08391db7fa77a404be5df20343877d/href</a></iframe><p>Şimdi de bu sınıfın veri kayit işlerinden sorumlu repository’mizi yazalım.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/ba9032aa59b54e5d64d8203e44c86ec4/href">https://medium.com/media/ba9032aa59b54e5d64d8203e44c86ec4/href</a></iframe><p>Bu repo’muz JpaRepositöry’i miras alıyor. Bu sayede save(),delete() gibi methodlar pre-defined geliyor. Bunlar ihtiyaçlarımızı karşılamaya yeterli ama ek olarak findByUsername() methodü ile kullanıcı adını argüman olarak verip ilgili kaydı döndürebiliyoruz, bunun için herhangi bir SQL yazmamıza gerek yok. Jpa Rocks ;)</p><p>Şimdi’de yeni bir developer register olmak istediğinde gideceği endpoint’i ve controller’ini yazalım.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/9350b6a2d1c764ebf1f035ac10cc515f/href">https://medium.com/media/9350b6a2d1c764ebf1f035ac10cc515f/href</a></iframe><p>Burada basitçe <strong>/sign-up</strong> path’ine HTTP POST request’i yapıldığında, gelen request body parse edilip şifre alınır ve encrypt edilir. Kullanıcının bilgileri DB’ye kaydedilir. <br>Encryption işlemini yapan <strong>bCryptPasswordEncoder’in</strong> instance’ını oluşturmamız gerekli. Bunu Application’ı run ettiğimiz base class’ta yapmalıyız. Bende bu sınıfın adı “DemoApplication”. Aşağıdaki kod parçasını ekleyelim.</p><pre>@Bean<br>public BCryptPasswordEncoder bCryptPasswordEncoder() {<br>    return new BCryptPasswordEncoder();<br>}</pre><p>Şu an kullanıcılar register olabiliyor. Şimdi Authorization ve Authentication işlerini halledelim.</p><h3>Authorization ve Authentication Filtreleme</h3><p>Şimdi yapacaklarımız:</p><ul><li>Login olan kullanıcılara JWT assign etmek için Authentication Filter</li><li>Authenticated kullanıcıların yeni requstlerindeki JWT’leri validate etmek için Authorization Filter</li><li>DAO olarak user-spesific verileri yüklemek için Spring Security içinde gelen UserDetailsService interface’inin implementasyonu</li></ul><h4>Authentication Filtreleme</h4><p>Bu sınıfımızın iki görevi var. Başarılı login’lere JWT atama ve yeni authorized requestlerin JWT’sini kontrol etme. İmplementasyonu şu şekilde;</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/d08039cbe08e8a20a5acb918ba3e557a/href">https://medium.com/media/d08039cbe08e8a20a5acb918ba3e557a/href</a></iframe><ul><li><strong>EXPIRATIONITIME</strong> = Token’in geçerlilik süresi</li><li><strong>SECRET</strong>= Token’in HMAC algoritması ile imzalanırken kulladığı secret key, istediğimiz değeri verebiliriz.</li><li><strong>TokenPrefix</strong> =Authorization Header’ındaki auth tipi.(basic, bearer, ..)</li></ul><p>İki fonksiyonumuz var. İlki olan <strong>attemptAuthentication</strong> fonsiyonunda gelen request’teki Header’i parse edip Token’i alıyoruz. Ardından <strong>UsernamePasswordAuthenticationToken</strong> sınıfının bir nesnesini oluşturup JWT’mizi set ediyoruz. Nesnesini oluşturduğumuz bu sınıf kullanıcı adı ve parolayı saklar. <em>getCredentials</em>() ve <em>getPrinciples</em>() methodları ile bunlara erişebiliriz. (Further info: <a href="https://goo.gl/bu6Qp2">https://goo.gl/bu6Qp2</a>)</p><p>Ardından, <strong>succesfulAuthentication</strong> ile başarılı bir şekilde login olmuş kullanıcıya JWT yollayacağız. Bunun için Jwts sınıfının builder() methodu ile Payload kısmı için subject ve expiration time’i set edip, kendi tanımladığımız SECRET ile imzalayıp Tokenimizi oluşturuyoruz ve Header’a ekliyoruz.</p><p>Şimdi başka sınıflarda da kullanılacak, Header’i oluşturmak için gerekli constanlar ve sign-up path’ini içeren bir constants sınıfı oluşturalım. Hiçbir fonksiyon yok, sadece kod kalabalığını önlemek için.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/404d3a0d8f5311ab510e8c77b80c7a97/href">https://medium.com/media/404d3a0d8f5311ab510e8c77b80c7a97/href</a></iframe><h4>Authorization Filtresi</h4><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/82d2c0e508798694db22afa6e1320a7a/href">https://medium.com/media/82d2c0e508798694db22afa6e1320a7a/href</a></iframe><p>Constructor’da kalıtım altığımız soyut <a href="https://docs.spring.io/autorepo/docs/spring-security/3.2.3.RELEASE/apidocs/org/springframework/security/web/authentication/www/BasicAuthenticationFilter.html">BasicAuthenticationFilter</a> sınıfı argüman olarak authenticationManager ister, bu authentication requestlerinin submit edildiği Bean’dır. Yine iki methodumuz var. İlk methodumuzda kalıtım aldığımız soyut BasicAuthenticationFilter sınıfının doFilter() methodunu implemente ediyoruz. Bu method, korunan bir kaynağa request geldiğinde bu request’i yakalar, JWT’yi validate eder ve herşey uygunsa kullanıcı authentication bilgilerini SecurityContextHolder ile SecurityContext’in içine yazar ve kaynağı client’a sunar. <br>İkincisi JWTAuthenticationFilter sınıfındaki successfulAuthentication() methoduyla benzer, Authorization Header’ından JWT değerini okur ve token’in geçerliliğini onaylar.</p><h3>Authentication/Authorization Filtrelerini Implemente Etme</h3><p>Su ana kadar gelen isteklere JWT yaratan, gelen JWT’lere gore filtreleme yapan iki Filter sinifi yazdik. Simdi bunlari Spring Security’e implemente edelim. Bunun icin bir WebSecurityConfig sinifi yazalim.<br>Bu sinifla hangi kaynaklara izin verip vermedigimizi ve hangi filtreleri kullanacagimizi yazacagiz. Genel guvenlik unsurlarinin hepsi burada yer alir.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/c7ad6fff105e1c9f1209227b6ebfffc6/href">https://medium.com/media/c7ad6fff105e1c9f1209227b6ebfffc6/href</a></iframe><p>3 methodumuz var. Bunlarin gorevlerine bakalim;</p><ul><li><strong>configure(HTTPSecurity http)=</strong> Kisaca burada hangi methodlara ve path’lere izin verdigimizi belirtiyoruz. Oncelikle <a href="https://docs.spring.io/spring-security/site/docs/current/reference/html/cors.html">CORS</a>’a izin verip <a href="https://docs.spring.io/spring-security/site/docs/current/reference/html/csrf.html">CSRF</a>’i disable ediyoruz. Sonrasinda /sign-up path’ine POST request’e izin verip, geri kalan tum kaynaklar icin authentication bekledigimizi soyluyoruz.<br>Ardindan az once yarattigimiz iki Filter’i ekleyip, session olusturmayi kaldiriyoruz. Buni JWT ile saglayacagiz.</li><li><strong>configure(AuthenticationManagerBuilder auth)= </strong>auth.userDetailsService(T) methodu, Spring Docs’ta arguman olarak verilen userDetailsService’e yani user-specific bilgileri authenticate ettigini soyluyor. Dogrusu burasi benim de biraz kafami karistirdi. Daha aciklayici bir yorumunuz varsa <strong>lutfen yorum olarak belirtin!</strong>🤓<strong> </strong>passwordEncoder kisminda ise encryption icin kullanacagimiz sinifi set ediyoruz.<br>Ardindan, bir in-memory user ekliyoruz. Kullanici adini ve parolasini istediginiz gibi verebilirsiniz.</li><li><strong>corsConfigurationSource()= </strong>Burada Cross Origin Resource Sharing(CORS) izinlerini set ediyoruz, simdilik herhangi kaynaktan gelen requestlere izin verdik.</li></ul><h4>Son adim!</h4><p>Spring Security, UserDetailsService DAO’sunu bize interface olarak verir. Yukarida kullanimi yaptigimiz bu interface’in soyut methodlarini implemente edecegiz. Yeni bir package yaratalim, adi “service” olsun. Bu sinifi service package icinde yazalim.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/6ac657b2f226849d8c282c6ed01beda1/href">https://medium.com/media/6ac657b2f226849d8c282c6ed01beda1/href</a></iframe><p>Bu layer, mantik olarak, Read/Write islemleri yapan DeveloperRepository sinifimla aramda bir katman, bir Data Access Object(DAO). Yani dataya ‘ulasmak’ icin bir layer. Gordugunuz gibi loadUserByUsername() methodu ile verilen username’i Repository’mden bulup varsa bana getiriyor, ona access etmemi sagliyor. Neden mi boyle?<strong> </strong><a href="https://softwareengineering.stackexchange.com/questions/32581/how-do-you-explain-separation-of-concerns-to-others"><strong>Separation of Concerns!</strong></a></p><h3>Test Edelim! 🍻🍻</h3><p>Hersey tamam. Simdi sistemimizi test edelim ve gelen token degerini bulmaya calisalim. Test icin <strong>cURL</strong> ya da <a href="https://chrome.google.com/webstore/detail/postman/fhbjgbiflinjbdggehcddcbncdddomop"><strong>POSTMAN</strong></a> kullanabilirsiniz. Daha iyi gorsel deneyim icin ben POSTMAN kullanacagim.</p><p>Buraya kadar okuyarak geldiyseniz test etmeniz icin size iki guzel secenek sunmak istiyorum.</p><ol><li>Local’de deploy etmeden, sadece test edecekseniz; Heroku Cloud’a ben deploy ettim, buraya HTTP Request’leri yollayarak test edebiliriz! (Heroku gercekten mukemmel! 🙏). Ben yazinin devaminda, buradan test edecegim.<br><strong>Test URL:</strong> <a href="https://jwt-springboot.herokuapp.com/">https://jwt-springboot.herokuapp.com/</a></li><li>Local’de calistirmak icin github’dan clone’layabilirsiniz.</li></ol><pre>git clone <a href="https://github.com/ugurcemozturk/JWT.git">https://github.com/ugurcemozturk/JWT.git</a></pre><h4>Senaryo #1 — Access Denied</h4><figure><img alt="" src="https://cdn-images-1.medium.com/max/916/1*5pZitaVAaEPOmFV6DRiXsQ.png" /></figure><p><a href="https://jwt-springboot.herokuapp.com/">https://jwt-springboot.herokuapp.com/</a> adresine GET Request yollayalim. Access Denied ile geri donmesi gerekli.</p><p>.</p><p>.</p><p>.</p><p>Done!</p><h4>Senaryo #2 — Yeni Kullanici Ekleme</h4><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*xB96CIQYUj7rax7J9MbW4w.png" /></figure><p>Burada /developers/sign-up path’ine Body bolumunde JSON olarak set ettigimiz degerler ile POST request yapiyoruz. Sonuc basarili!</p><p>Ornek olmasi acisindan, hatirlarsaniz CORS’u enable etmistik. Asagidaki access-control-allow-credentials:true Header’i bunu dogruluyor.</p><h4>Senaryo #3— Sisteme Giris Yapmak</h4><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*XkZqeuPwzIUx_3-uV0GiHw.png" /></figure><p>Az once register ettigmiz kullanici bilgileri ile /login sayfasina POST Request atalim. WebSecurityConfig sinifinda, bu kaynaga atilacak POST isteklerine izin vermistik.</p><p>Veee Boom💣..</p><p>Headers’a bakin. Authorization Header’i altinda “Bearer eyJhb..” diye baslayan bir Header’imiz var. Iste server’in bize atadigi JWT!</p><blockquote>3 parcadan olusuyor ve bu parcalar <strong>“.”</strong> ile ayriliyor. Formati su sekilde: <strong>HEADER.PAYLOAD.SIGNATURE</strong></blockquote><h4>Senaryo #3 — Yeni bir Project POST Etmek</h4><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*uHa3kw-BkoT5Mlr3Q0du7A.png" /></figure><p>Once Body kismina gelip, modal yapimiz olan Project sinifinin “description” degiskenini set edelim.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*QonLHhNZjoKyVUugKvJhtw.png" /></figure><p>JWT’mizi kullanarak POST Request yapmak icin, Authorization Header’ini kopyalayip, POSTMAN’daki Hearders kismina yapistiralim. Ardindan request’i yollayalim.</p><p>Ta daa.. POST islemi basariyla gerceklesti ve GET ile de bunun dogrulugunu sagladik.</p><p>Tum bu requestlerimizi yollarken Authorization’a JWT degerini ekledik ve tum filtreleri asarak isteklerimizi dogru sekilde gerceklestirdik.</p><p>Uzuuun yazimin sonuna geldik. Bu yaziyi ogrenirken eszamanli olarak yazdim. Tanimlarda, aciklamalarda bir hata ya da eksiklik oldugunu dusunurseniz, ya da gelistirmeyi dusundugunuz bir bolum varsa lutfen yorum olarak bana iletin.</p><p>Sabriniz icin tesekkurler.</p><p>Ugur Cem.<br><a href="https://ugurcem.com/">ugurcem.com</a></p><h3>🍻✌️</h3><blockquote>Better to have a look at:</blockquote><p><a href="https://spring.io/guides/topicals/spring-security-architecture/">Spring Security Architecture</a></p><p>Kaynak: <a href="https://auth0.com/blog/implementing-jwt-authentication-on-spring-boot/">https://auth0.com/blog/implementing-jwt-authentication-on-spring-boot/</a></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=38577fb5354b" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Google Firebase ile Ucretsiz Hosting]]></title>
            <link>https://ugurcemozturk.medium.com/google-firebase-ile-ucretsiz-hosting-9b6efcb7334?source=rss-5f14504ab1bb------2</link>
            <guid isPermaLink="false">https://medium.com/p/9b6efcb7334</guid>
            <category><![CDATA[firebase]]></category>
            <category><![CDATA[web-hosting]]></category>
            <category><![CDATA[free-hosting]]></category>
            <category><![CDATA[hosting]]></category>
            <dc:creator><![CDATA[Ugur Cem Ozturk]]></dc:creator>
            <pubDate>Wed, 18 Oct 2017 23:44:28 GMT</pubDate>
            <atom:updated>2017-10-18T23:44:28.775Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/650/1*EOw5uDG4wNmhkvUj0J8cTA.png" /></figure><p>Merhaba. Firebase nedir, nasil kullanir, hangi servisler vardir gibi detaylara bu yazida girmeyecegim. Daha detayli bilgi icin asagidaki linklere goz atabilirsiniz.</p><ul><li><a href="https://firebase.google.com/products/">Firebase Products</a></li><li><a href="https://howtofirebase.com/what-is-firebase-fcb8614ba442">What is Firebase?</a></li></ul><p>Eveet.. Gelelim hosting isine, ucretsiz hosting. Firebase’in ucretli ucretsiz cesitli paketleri ve ona gore bir pricing list’i var. Ucretsiz hostinge ihtiyacimiz oldugundan emin olmak icin once ihtiyaclarimiza bir goz gezdirelim;</p><ul><li>Hazir bir websitesi</li><li>Dusuk trafik ihtiyaci</li><li>Kisitli butce</li><li>Google/Gmail hesabi</li></ul><p>Eger 4&#39;te 3 evet ise, devam edebiliriz.</p><p>Oncelikle <a href="https://console.firebase.google.com/">https://console.firebase.google.com/</a> linkine gidip, Google hesabimiz ile giris yapiyoruz.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*jRVXYyf8JrgCBWXMWxGI6w.png" /><figcaption>Firebase anasayfasi</figcaption></figure><p>Sag ustte bulunun ‘Go to Console’ butonuna tiklayarak, calisma alanimiza giris yapiyoruz. Google Firebase, bize cesitli uygulamar icin cesitli playgroundlar sunuyor. Hosting projemiz icin oncelikle yeni bir proje yaratmamiz gerekli.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*Enmlib7pDexDsLqEjTjndA.png" /><figcaption>Firebase Console Görünümü</figcaption></figure><p>Oncelikle yeni bir proje yaratmamiz gerekli. Bunun icin “Proje Ekle” kismina tiklayalim. Firebase, yeni projemiz icin bizden Proje Adi, kimligi ve Ulkemizi doldurmamizi isteyecek. Ben demo projemiz icin adini ve kimligini “ucretsizhosting1” koyuyorum. Siz de “ucretsizhosting*” ya da istediginiz bir ismi girin ve yolumuza devam edelim. Neredeyse bitti!</p><p>Bizi karsilayacak ekran goruntusu boyle;</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*5_BKCU6cltpf2uUol61RHA.png" /></figure><p>Aslinda Firebase mobil agirlikli uygulamalarin Storage, Auth. , Testing, vs. gibi back-end islerini cozume ulastirmak icin yaratildi. Literaturde BaaS(Back-end As a Service) olarak geciyor. Soldaki menulerden;</p><ul><li>Authentication</li><li>Storage</li><li><strong>Hosting</strong></li><li>Functions</li><li>TestLab for Android</li><li>….</li></ul><p>Gibi cesitli servislere ulasabilirsiniz.</p><h3>E hadi artik hosting!</h3><p>Isimize donelim, hosting. Soldaki menude 7. sirada yer alan, dunya ikonu ile listelenmis “Hosting” butonuna basiyoruz.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*159nffYr1knZxjwIVYuPqQ.png" /><figcaption>Firebase Hosting Sayfasi</figcaption></figure><p>Buradan, -baska bir secenek de olmadigindan dolayi- Baslayin butonuna basiyoruz.</p><p>Karsimiza bir pop-up cikti! Firebase <strong>npm</strong> ile bizden kendi package’ini yuklememizi istiyor.</p><blockquote>(npm mi? : <a href="https://www.w3schools.com/nodejs/nodejs_npm.asp">https://www.w3schools.com/nodejs/nodejs_npm.asp</a>)</blockquote><p>Bunun icin sistemimizde npm kurulu olmali. Olmadigini varsayarak once npm’i yukleyelim. Yuklemeyi official siteden yapacagiz. Yukleme detaylarini anlatmaya gerek duymuyorum. Paketi indiriyor ve yukluyoruz! Bu kadar.</p><p>Indirme adresi : <a href="https://www.npmjs.com/get-npm">https://www.npmjs.com/get-npm</a></p><p>Yukleme tamamlandiktan sonra, ilgili Firebase paketlerini npm ile yuklemek icin console’umuzu acalim.</p><p>Simdi npm ile ilgili paketleri yuklemek icin;</p><p>$ npm install -g firebase-tools</p><p>yazip enter’a basin. Paketler yuklenmeye baslanacaktir.</p><p>Artik gercekten ilerledik. Bu paket ile sitemizi uzak sunucuya sadece 3 satir bash script ile yukleyebilecegiz!</p><h3>Yukleyelim madem!</h3><p>Oncelikle console’da projenin oldugu dizine atlamaliyiz. Ornek veriyorum ki suan “/” dizinindesiniz ve projeniz “/projem” dizininde.</p><p>$ cd projem</p><p>yazarak proje dizinine geciyoruz.</p><p>Proje dizininin icerigini soyle varsayiyorum:</p><pre>projem<br>├───index.html<br>├───Readme.md<br>├───assets<br>│   ├───js<br>│   ├───css</pre><p>Simdi yapmamiz gereken, proje dizini altindaki her dosya ve klasoru ‘public’ adinda bir klasor olusturup buraya atmak. Bu kisim gercekten cok onemli. projem klasorunun yeni hali aynen soyle olmali;</p><pre>projem<br>├───public<br>│   ├───index.html<br>│   ├───Readme.md<br>│   ├───assets<br>│   │   ├───js<br>│   │   ├───css</pre><p>Tekrar yaziyorum, sebebini ileride anlayacaksiniz. Once ‘projem’ altinda public adinda bir klasor olusturuyoruz. Ardindan ‘projem’ klasoru altindaki herseyi(public haric) son yarattigimiz klasorun icine atiyoruz.</p><h3>Copy Paste yapmak icin yazini okumuyorum!</h3><p>Tamam neredeyse bitti!</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*XuNIr3T2Lp35ElWFjZMQZA.png" /></figure><p>Bu ekrandaki isimiz bitti. npm yukledik ve public klasorune dosyalarimizi atadik Simdi devam diyelim.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*DGc6jRNqGenYTJwR8CGZbQ.png" /></figure><p>Gordugunuz gibi onumuzde 3 adim var.</p><ul><li>Firebase’e console’dan giris yapmak,</li><li>Projemizi bir firebase projesine cevirmek,</li><li>Ve son olarak, sitemizi yayinlamak!</li></ul><p>Simdi console’a geri donelim. Eger kapattiysak tekrar proje dosyasina geri gelmemiz gerekli. Bunun icin tekrar;</p><p>$ cd projem</p><h3>Son Dörtlü!</h3><p>Simdi Firebase’e giris yapalim.</p><p>$ firebase login</p><p>dedikten sonra bize ilk olarak bunu soracak:</p><blockquote>? <strong>Allow Firebase to collect anonymous CLI usage and error reporting information?</strong></blockquote><p>’<strong>n</strong>’ diyip gecelim. Cunku Google’da zaten yeterince bilgi var ;)</p><p>Simdi Google Sign-In sayfasi acilacak, giris yaparak devam edelim.</p><p>….</p><p>Bitti! Giris yaptik ve ilk adim tamamlandi!</p><p>Geldik ikinci ve en kritik adima. Lutfen burada dediklerimi sirayla ve dikkatle yapin.</p><p>Console’a geri donelim. Bulundugumuz dizinin proje dizini olduguna emin olun. Bunu,$ pwd komutu ile kontrol edebilirsiniz. Eger dogru dizindeysek, devam!</p><p>Simdi,$ firebase init diyoruz.</p><p>Karsimiza soyle bir ekran cikacak, <strong>Hosting</strong> diyip enter’a basalim.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*K_d6ecK2BdoL6lrpl8hIhw.png" /></figure><p>Ardindan, gelen ekranda yarattigimiz projeyi secip devam edelim. Ekran goruntusu soyle;</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*ooqhEueAbf04o1eW8J47bg.png" /></figure><p>Eger bu yaziyi gorebildiyseniz neredeyse oldu!</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*7bllHzr6fBl4GEtbTshflg.png" /></figure><p>Simdi, en onemli adim, $ firebase init ile yaratilan firebase.json dosyasini acalim. Icerigi ;</p><blockquote>{}</blockquote><p>olarak gozukuyor. Bu yanlis, boyle olsun istemiyoruz. Icerigini asagidaki ile degistirelim.</p><pre>{<br>  &quot;hosting&quot;: {<br>    &quot;public&quot;: &quot;public&quot;<br>  }<br>}</pre><h3>Son adim!</h3><p>Buraya kadar basariyla geldiyseniz harika. Cunku neredeyse bitti. Tek bir komutumuz kaldi, o da <strong>deploy. </strong>Bu komut ile sitemizi uzak sunucuya deploy edecegiz, gelin yapalim.</p><p>$ firebase deploy</p><p>Bu islem sitenizin boyutuna gore biraz vakit alabilir. Eger asagidaki ekrani gorduyseniz, islem tamamdir!</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*t8pT5IcBSNu1w-YNOlSYEw.png" /></figure><p><strong>Hosting URL </strong>bolumundeki link araciligi ile sitenize ulasabilirsiniz.</p><p>Umuyorum ki sorunsuzca sitesini ucretsiz olarak Firebase’e yuklediniz. Diger yazimda ise elinizdeki Domain ile Firebase Hosting’i baglamayi anlatacagim.</p><p>Tum sorulariniz icin hic cekinmeden <a href="/service/mailto://info.ugurcem@gmail.com">info.ugurcem@gmail.com</a> adresine mail atabilirsiniz.</p><p>Iyi calismalar!</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=9b6efcb7334" width="1" height="1" alt="">]]></content:encoded>
        </item>
    </channel>
</rss>