You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Clarified details about the Bifrost authentication service, including token issuance and structure. Updated sections on session creation, token renewal, and security considerations.
Copy file name to clipboardExpand all lines: docs/developer/auth.md
+14-14Lines changed: 14 additions & 14 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -5,7 +5,7 @@ pagination_prev: null
5
5
---
6
6
# Bifrost Authentication Service
7
7
8
-
Bifrost is an authentication service that enables secure communication between external applications and the Sourceful Energy App (SEA). It serves as a bridge that facilitates safe authentication without requiring users to install external wallets on multiple devices.
8
+
Bifrost is an authentication service that enables secure communication between external applications and the Sourceful Energy App (SEA). It serves as a bridge that facilitates safe authentication without requiring users to install external wallets on multiple devices. Basically Bifrost allows exchange of a delegation token that gives the token owner permission to access some of the users resources.
9
9
10
10
> **Security by Design**: Bifrost only handles public keys, never private keys. All private keys remain securely within either the SEA or the external application, ensuring that sensitive cryptographic material is never exposed to the bridge service.
11
11
@@ -61,7 +61,7 @@ sequenceDiagram
61
61
1.**Session Creation**: External application generates a private key and sends its public key and an attributes object to Bifrost
62
62
2.**Session Validity**: Sessions are valid for a maximum of 3 minutes
63
63
3.**User Approval**: During this time, the user must approve the session in SEA
64
-
4.**Token Issuance**: Upon approval, a signed JWT is returned to the external application
64
+
4.**Token Issuance**: Upon approval, a JWT signed by the user is returned to the external application
65
65
5.**API Access**: The JWT can then be used for authentication with the Sourceful Energy API
66
66
67
67
## JWT Delegate Token Structure
@@ -88,20 +88,16 @@ JWT tokens issued by Bifrost follow this structure:
88
88
```
89
89
90
90
Where:
91
-
-**issuer**: The user's public key whose corresponding private key signs the JWT in SEA
92
-
-**delegatedKey**: The public key of the external application whose generated private key can be used to sign messages
93
-
-**attributes**: Additional attributes that describe the token, currently `name`, `nonce`, and `permissions` are supporte by the SEA and API Backend. Permissions are of particular interest and are documented in its own section, but basically describe what the token is allowed to do with defined resources. The `nonce` attribute is added by bifrost automatically.
91
+
-**issuer**: The user's public key whose corresponding private key signs the JWT in SEA in base58 format
92
+
-**delegatedKey**: The public key of the external application whose generated private key can be used to sign messages in base58 format
93
+
-**attributes**: Additional attributes that describe the token, currently `name`, `nonce`, and `permissions` are supporte by the SEA and API Backend. Permissions are of particular interest and are documented in its own section, but basically describe what the token is allowed to do with defined resources. The `nonce` attribute is added by Bifrost automatically and must NOT be changed in the token exchange.
94
94
95
95
In an application it makes sense to show the issuer public key so the user understands what wallet is logged in, but at the same time make it clear that this is a delegatge token based authentication. It does not make sense to show the delegatedKey as this is only used internally in the application and JWT token. Also note that the expiration time can be changed, as of now the default time to live is 12h.
96
96
97
97
### Permissions
98
98
TODO: Document the permissions here.
99
99
100
100
101
-
### Future Enhancements
102
-
103
-
The JWT structure allows for extensibility. In future versions, additional fields can be added to the payload to provide fine-grained access rights, enabling more nuanced permission controls. The time to live can also be customized by either the protocl or the user in future versions.
104
-
105
101
## Security Considerations
106
102
107
103
```mermaid
@@ -133,6 +129,7 @@ To mitigate these risks, Bifrost implements:
133
129
- External application's private key remains in the external application
134
130
- User's private key remains in the SEA
135
131
- Bifrost only handles public keys and signed tokens
132
+
5.**No tokens Saved**: Bifrost does only save metadata regarding the delegate token, not the token itself. It is the responsibility of the external application to maintain its delegate token and private key.
136
133
137
134
## API Endpoints
138
135
@@ -146,6 +143,7 @@ Creates a new authentication session for key exchange between an external applic
@@ -223,12 +221,15 @@ The full OpenAPI documentation is available at:
223
221
https://bifrost.srcful.dev/docs
224
222
```
225
223
224
+
The Bifrost endpoints requires authentication in the form of a token. See the Bifrost documentation above for details.
225
+
226
226
## Token Renewal
227
-
In general the delegate token is short lived and cannot be renewed without involving signing by the issuer wallet in general this involves a user interaction. This poses a problem for usability in some applications and problems when working with automations and integrations that are long lived.
227
+
In general the delegate token is short lived and cannot be renewed without involving signing by the issuer wallet in this ofteninvolves a user interaction. This poses a problem for usability in some applications and issues when working with automations and integrations that are long lived.
228
228
229
229
A delegate token can be marked for renewal (has `renew`: true, in the attributes). In this case an application can ask bifrost for a renewal certificate. This certificate allows the client (as identified by the delegateKey) to create it's own delegateToken. This renew token has the following structure:
230
230
231
231
### JWT Renew Token Structure
232
+
This is a token that is built by the client application and basically consists of a renew certificate token.
232
233
233
234
JWT renew tokens follow this structure:
234
235
@@ -244,15 +245,14 @@ JWT renew tokens follow this structure:
244
245
**Payload**:
245
246
```json
246
247
{
247
-
"delegate": the original delegate token jwt (signed by the issuer)
248
-
"cert": the renew cert token (signed by bifrost)
248
+
"cert": "the renew cert token in base64 (signed by bifrost)"
249
249
}
250
250
```
251
251
252
252
Where:
253
253
-**cert**: The certificate token signed by bifrost. Importantly it contains new created and expiration times as well as the nonce of the original delegate token and a bifrost key id.
254
254
255
-
Note the subtype (styp) in the header is set to renew.
255
+
Note the subtype (`styp`) in the header is set to `renew`.
256
256
257
257
A client application will periodically ask Bifrost for a new certificate token and build its own renew token based on this. This can then be used in the backend API calls according to the permissions of the original token. If the original token is revoked by the user, bifrost will not issue a new certificate.
258
258
@@ -273,7 +273,7 @@ Bifrost creates the renew certificate and signs it with its internal private key
273
273
"iss": "7f3a9b2e",
274
274
"created": "2025-04-28T08:50:41Z",
275
275
"expiration": "2025-04-28T09:10:41Z",
276
-
**dtoken**: The original delegate token signed by the issuer
276
+
"dtoken": "The original delegate token signed by the issuer in base64"
0 commit comments