Skip to content

Instantly share code, notes, and snippets.

View u-na-gi's full-sized avatar

Ryoji Uehara u-na-gi

  • Japan
View GitHub Profile

あれは…数年前のことでした。とある開発プロジェクトで、不思議な「トークン」を扱うシステムを構築していた時のことです。

その「トークン」っていうのは、まるでアクセストークンのように見えたんですが…何かが違うんです。通常、トークンには有効期限があるもんですが、このトークンには“期限”ってものがなかったんです。何かおかしいなと思いながらも、プロジェクトは進んでいきました。

ある日、プロジェクトチームの一人が「このトークン、JWTじゃないですよね?」とポツリと言いました。それがきっかけでした。確かに、名前こそ「トークン」って呼ばれていましたが、まるでセッションそのもののように動作していたんです。

でもね、ここからが怖い話ですよ…。

トークンに有効期限がないってことは、いつまでも使い続けられる。もしそのトークンが一度でも誰かに漏れたら…?その人は、永遠にそのシステムにアクセスできるんです。

use aws_config::default_provider::app_name::default_provider;
use aws_sdk_s3::{
config::{
endpoint::{Endpoint, EndpointFuture, Params, ResolveEndpoint},
Credentials, Region, SharedCredentialsProvider,
},
Client,
};
#[derive(Clone)]

1. Conclusion

In this development, we successfully connected to Minio using the AWS SDK in Rust and performed S3-compatible bucket operations. By using a custom resolver, we specified the Minio endpoint and employed Tokio for asynchronous programming.

Here is the key code for connecting to Minio and creating a bucket:

use aws_sdk_s3::{Client, Credentials, Region};
use aws_sdk_s3::config::Builder;
use aws_sdk_s3::endpoint::{Endpoint, ResolveEndpoint, EndpointFuture, Params};

WorkerdがWASMを受け取って処理する流れ

はじめに

workerd は、高性能な JavaScript と WebAssembly (WASM) の実行エンジンで、V8 エンジンを活用してスクリプトや WASM モジュールを処理します。本記事では、workerd がクライアントから受け取った WASM モジュールをどのようにしてコンパイルし、実行するのか、その流れを解説します。

1. WASM モジュールの受け取り

Introduction to Trait Bounds in Rust

Rust enables safe and efficient programming through its powerful type system. Among its features, traits and trait bounds are crucial for enhancing code reusability and promoting abstraction. In this article, we will introduce the basic concepts of trait bounds and demonstrate their usage through actual code examples.

What Are Traits?

Traits are features that define specific behaviors. By implementing a particular trait, a type can utilize the methods defined by that trait. Below is the definition of a trait called Cryptable.

Building a Web App with Cloudflare Workers, D1, and Rust**

Chapter 1: Integrating Cloudflare D1 with Workers

  1. Introduction to D1
    D1 is Cloudflare’s SQLite-compatible database that is perfect for serverless environments like Cloudflare Workers. It brings SQL to the edge, enabling performant and durable queries.

  2. Setting Up D1 in Your Project
    Explain how to set up D1 by creating a new Cloudflare project and connecting D1. You can follow this process: