Browse Source

Add POST endpoint for Mastodon OAuth compat

master
Puck Meerburg 1 year ago
commit
dbdee2f1f8
4 changed files with 63 additions and 0 deletions
  1. 3
    0
      .gitignore
  2. 16
    0
      Cargo.toml
  3. 27
    0
      src/lib.rs
  4. 17
    0
      src/register.rs

+ 3
- 0
.gitignore View File

@@ -0,0 +1,3 @@
/target
**/*.rs.bk
Cargo.lock

+ 16
- 0
Cargo.toml View File

@@ -0,0 +1,16 @@
[package]
name = "kroeg-oauth"
version = "0.1.0"
authors = ["Puck Meerburg <puck@puckipedia.com>"]

[dependencies]
base64 = "0.9"
futures = "0.1"
hyper = "0.12"
kroeg-server = { path = "../server" }
kroeg-tap = { path = "../tap/tap" }
serde = "1.0"
serde_derive = "1.0"
serde_json = "1.0"
jsonld = { path = "../jsonld-rs" }
kroeg-mastodon = { path = "../mastodon" }

+ 27
- 0
src/lib.rs View File

@@ -0,0 +1,27 @@
extern crate base64;
extern crate futures;
extern crate hyper;
extern crate jsonld;
extern crate kroeg_mastodon;
extern crate kroeg_server;
#[macro_use]
extern crate kroeg_tap;
extern crate serde;
#[macro_use]
extern crate serde_derive;
#[macro_use]
extern crate serde_json;

use kroeg_server::router::Route;
use kroeg_server::KroegServiceBuilder;

mod register;
// mod endpoints;

pub fn register(builder: &mut KroegServiceBuilder) {
builder.routes.push(Route::post(
"/api/v1/apps",
Box::new(register::mastodon),
));
println!(" [+] OAuth registered");
}

+ 17
- 0
src/register.rs View File

@@ -0,0 +1,17 @@
use futures::{future, Future};
use hyper::{Body, Request, Response};
use kroeg_server::ServerError;
use kroeg_tap::{Context, EntityStore, QueueStore, StoreItem};
use serde_json::{self, Value as JValue};

pub fn mastodon<T: EntityStore, R: QueueStore>(
context: Context,
store: T,
queue: R,
request: Request<Body>
) -> Box<Future<Item = (T, R, Response<Body>), Error = (ServerError<T>, T)> + Send> {
Box::new(future::ok((store, queue, Response::builder()
.header("Content-Type", "application/json")
.body(Body::from(json!({"id":"0","client_id":"0","client_secret":"0"}).to_string()))
.unwrap())))
}

Loading…
Cancel
Save