Ecosyste.ms: Awesome

An open API service indexing awesome lists of open source software.

Awesome Lists | Featured Topics | Projects

https://github.com/yigitsadic/onetimecode

This project saves given identifier in memory and gives back random 7 character string. Can be used as user identifier.
https://github.com/yigitsadic/onetimecode

Last synced: about 1 month ago
JSON representation

This project saves given identifier in memory and gives back random 7 character string. Can be used as user identifier.

Awesome Lists containing this project

README

        

# Onetimecodego

This project, designed for mapping random strings to given identifiers. For example with given identifier `c96e40ed-1a06-427b-9c2d-a85ebea7d9e8`
is mapped to random **x** length of string (*HPI05VM*) for **y** seconds.

Application does not handle any authentication nor authorization and it's designed for single instance use only.

Generated codes stores in memory, because of that, any time service is down, your codes will go down.

## Configuration

Application configurable through environment variables.

```
CODE_EXP = 60
```

## Grpc

Example client can be found in **client.go**

```protobuf
syntax = "proto3";
package otcgo;

option go_package = "grpc;grpc";

message OneTimeCodeGen {
string identifier = 1;
}

message ReadCodeReq {
string value = 1;
}

message OneTimeCodeResponse {
string identifier = 1;
int64 expiresAt = 2;
string value = 3;
}

service OneTimeCodeService {
rpc CreateCode(OneTimeCodeGen) returns (OneTimeCodeResponse) {}
rpc ReadCode(ReadCodeReq) returns (OneTimeCodeResponse) {}
}
```

## Docker

You can run ` docker run --rm -e CODE_EXP=5 -p 9000:9000 yigitsadic/onetimecodego:latest`

For client: `go run client.go`