197g / 197g/oxide-auth

Compatibility with IndieAuth

Abierto
#237 1 comentario 0 reacciones 0 asignados Ver en GitHub
Lenguaje dominante
Rust
Estrellas
783
Forks
102
Métricas de merge de PR
Sin PR fusionados en 30 d

Descripción

IndieAuth ([https://indieauth.spec.indieweb.org/](https://indieauth.spec.indieweb.org/)) is a specialization of OAuth2. It requires extra fields in a couple of responses to the client:

- The authorization return needs an _iss_ field which gives the ID of the issuer;
- The access token return needs a _me_ field which gives the ID of the user.

I have shoe-horned these into the code, but in the case of the access token I had to hard-wire the _me_ value. My modifications to the code are below the signature. I would love it if someone could guide me on a more correct way to go about this, or, if it can't be done, perhaps we can work together to develop the oxide-auth library?

-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
```
diff --git a/oxide-auth/src/code_grant/authorization.rs b/oxide-auth/src/code_grant/authorization.rs
index 422e859..2c82ca2 100644
--- a/oxide-auth/src/code_grant/authorization.rs
+++ b/oxide-auth/src/code_grant/authorization.rs
@@ -464,7 +464,7 @@ impl Pending {
let grant = handler
.authorizer()
.authorize(Grant {
- owner_id: owner_id.into_owned(),
+ owner_id: owner_id.clone().into_owned(),
client_id: self.pre_grant.client_id,
redirect_uri: self.pre_grant.redirect_uri.into_url(),
scope: self.pre_grant.scope,
@@ -476,6 +476,7 @@ impl Pending {
url.query_pairs_mut()
.append_pair("code", grant.as_str())
.extend_pairs(self.state.map(|v| ("state", v)))
+ .append_pair ("iss", &owner_id)
.finish();
Ok(url)
}
diff --git a/oxide-auth/src/code_grant/accesstoken.rs b/oxide-auth/src/code_grant/accesstoken.rs
index c5542ec..e92cbb4 100644
--- a/oxide-auth/src/code_grant/accesstoken.rs
+++ b/oxide-auth/src/code_grant/accesstoken.rs
@@ -18,6 +18,10 @@ use crate::primitives::scope::Scope;
/// Token Response
#[derive(Deserialize, Serialize)]
pub struct TokenResponse {
+
+ /// The user ID.
+ pub me: String,
+
/// The access token issued by the authorization server.
#[serde(skip_serializing_if = "Option::is_none")]
pub access_token: Option,
@@ -676,6 +680,7 @@ impl BearerToken {
pub fn to_json(&self) -> String {
let remaining = self.0.until.signed_duration_since(Utc::now());
let token_response = TokenResponse {
+ me: "https://khleedril.org/blog".to_string (),
access_token: Some(self.0.token.clone()),
refresh_token: self.0.refresh.clone(),
token_type: Some("bearer".to_owned()),
diff --git a/oxide-auth/src/code_grant/refresh.rs b/oxide-auth/src/code_grant/refresh.rs
index 24055f7..aa492c5 100644
--- a/oxide-auth/src/code_grant/refresh.rs
+++ b/oxide-auth/src/code_grant/refresh.rs
@@ -559,6 +559,7 @@ impl BearerToken {
pub fn to_json(&self) -> String {
let remaining = self.0.until.signed_duration_since(Utc::now());
let token_response = TokenResponse {
+ me: "https://khleedril.org/blog".to_string (),
access_token: Some(self.0.token.clone()),
refresh_token: self.0.refresh.clone(),
token_type: Some("bearer".to_owned()),

```

Guía de contribución

Abrir la guía de contribución

Línea de trabajo

The issue involves modifying the authorization and token response structures in oxide-auth. Start by examining the code_grant module, specifically authorization.rs and accesstoken.rs. The user's patch shows where to add the 'iss' and 'me' fields. Understand how the owner_id flows through the Grant and TokenResponse structs. Look at the existing OAuth2 flow and tests to ensure compatibility. The goal is to make these fields configurable rather than hardcoded, likely by extending the Grant or handler interfaces.

Escrito por el modelo de indexación a partir del texto del issue.

Evaluación

Stack tecnológico
rust
Área
api, authentication, backend
Tipo de issue
Nueva funcionalidad
Dificultad
4/5
Tiempo estimado
3-5 días
Estado de actividad
Estancado
Claridad
Bastante claro
Aptitud para principiantes
45/100

Recibe los nuevos issues en tu correo

Un resumen breve de issues de GitHub para principiantes.