client/endpoints.aug
OpenID Connect login application · Source and specification
Files in this project
main.augclient/contracts.augclient/endpoints.augclient/export.augclient/login.augclient/logout.augclient/protocol.augclient/session.augclient/views.augcommon/export.augcommon/headers.augcommon/keys.augcommon/settings.augcommon/views.augprovider/authorization.augprovider/contracts.augprovider/credentials.augprovider/discovery.augprovider/export.augprovider/token.augprovider/userinfo.augprovider/views.aug
Code
// aug-spec: "endpoints.aug.md" explains this file. Read it before changes; refresh with aug spec.
import SessionClaims and SessionError from contracts
import authenticate from session
import LoginPage and Welcome from views
import UserInfo from provider
import settings and SigningKeys and KeyError and securityHeaders and withCookie from common
import Crypto from crypto
import Clock from time
import ExpiringStore from memory
/** The app renders a verified session or offers its OIDC login flow. No token claims are displayed before verification. */
endpoint GET "/" as home(optional string token from cookie "aug_session", resolve Crypto crypto, resolve Clock clock, resolve SigningKeys keys, resolve ExpiringStore<SessionClaims> sessions):
try:
session = authenticate(token)
return HttpResponse(body=Welcome(session), headers=securityHeaders())
catch SessionError error:
return HttpResponse(body=LoginPage(), headers=securityHeaders())
/** A protected JSON resource accepts only a live, verified application session. */
endpoint GET "/me" as me(optional string token from cookie "aug_session", resolve Crypto crypto, resolve Clock clock, resolve SigningKeys keys, resolve ExpiringStore<SessionClaims> sessions) unless SessionError with status 401 and KeyError and TimeError and HttpError:
session = authenticate(token)
return HttpResponse(
body=UserInfo(sub=session.sub, name=session.name),
headers=securityHeaders()
)// aug-spec: "endpoints.aug.md" explains this file. Read it before changes; refresh with aug spec.
import SessionClaims and SessionError from contracts
import authenticate from session
import LoginPage and Welcome from views
import UserInfo from provider
import settings and SigningKeys and KeyError and securityHeaders and withCookie from common
import Crypto from crypto
import Clock from time
import ExpiringStore from memory
/** The app renders a verified session or offers its OIDC login flow. No token claims are displayed before verification. */
endpoint GET "/" as home(optional string token from cookie "aug_session", resolve Crypto crypto, resolve Clock clock, resolve SigningKeys keys, resolve ExpiringStore<SessionClaims> sessions) {
try {
session = authenticate(token)
return HttpResponse(body=Welcome(session), headers=securityHeaders())
}
catch SessionError error {
return HttpResponse(body=LoginPage(), headers=securityHeaders())
}
}
/** A protected JSON resource accepts only a live, verified application session. */
endpoint GET "/me" as me(optional string token from cookie "aug_session", resolve Crypto crypto, resolve Clock clock, resolve SigningKeys keys, resolve ExpiringStore<SessionClaims> sessions) unless SessionError with status 401 and KeyError and TimeError and HttpError {
session = authenticate(token)
return HttpResponse(
body=UserInfo(sub=session.sub, name=session.name),
headers=securityHeaders()
)
}Compiled specification
Plain handler results default to HTTP 200 unless another status is declared. HttpResponse values choose their own status. Unhandled request failures return HTTP 500 and cancel the request tasks.
home · source
home handles GET /. The app renders a verified session or offers its OIDC login flow. No token claims are displayed before verification.
It takes token as optional string from the HTTP cookie aug_session. It gets crypto (Crypto), clock (Clock), keys (SigningKeys), and sessions (ExpiringStore<SessionClaims>) from dependency injection. Omitted optional inputs are null. It can call SigningKeys.session, Crypto.publicRsa, Clock.now, ExpiringStore<SessionClaims>.get, Crypto.equal, Crypto.decodeBase64url, and Crypto.verifyRsa.
It can also raise HttpError, KeyError, and TimeError. It tries to set session to authenticate with token using injected crypto, clock, keys, and sessions, then return HTTP 200 with Welcome with session and securityHeaders headers. If this work raises SessionError, it returns HTTP 200 with LoginPage and securityHeaders headers. source
Checked interface
home(optional string token, resolve Crypto crypto, resolve Clock clock, resolve SigningKeys keys, resolve ExpiringStore<SessionClaims> sessions) returns HttpResponse<Html> unless HttpError and KeyError and TimeError uses SigningKeys.session, Crypto.publicRsa, Clock.now, ExpiringStore<SessionClaims>.get, Crypto.equal, Crypto.decodeBase64url, Crypto.verifyRsaIt takes token as optional string from the HTTP cookie aug_session. It gets crypto (Crypto), clock (Clock), keys (SigningKeys), and sessions (ExpiringStore<SessionClaims>) from dependency injection. Omitted optional inputs are null. It can call SigningKeys.session, Crypto.publicRsa, Clock.now, ExpiringStore<SessionClaims>.get, Crypto.equal, Crypto.decodeBase64url, and Crypto.verifyRsa.
It can also raise HttpError, KeyError, and TimeError.
me · source
me handles GET /me. A protected JSON resource accepts only a live, verified application session.
It takes token as optional string from the HTTP cookie aug_session. It gets crypto (Crypto), clock (Clock), keys (SigningKeys), and sessions (ExpiringStore<SessionClaims>) from dependency injection. Omitted optional inputs are null. It can call SigningKeys.session, Crypto.publicRsa, Clock.now, ExpiringStore<SessionClaims>.get, Crypto.equal, Crypto.decodeBase64url, and Crypto.verifyRsa.
The handler responds with HTTP 401 for SessionError. It can also raise HttpError, KeyError, and TimeError. It sets session to authenticate with token using injected crypto, clock, keys, and sessions. It returns HTTP 200 with an UserInfo with session.sub and session.name and securityHeaders headers. source
Checked interface
me(optional string token, resolve Crypto crypto, resolve Clock clock, resolve SigningKeys keys, resolve ExpiringStore<SessionClaims> sessions) returns HttpResponse<UserInfo> unless HttpError and KeyError and SessionError and TimeError uses SigningKeys.session, Crypto.publicRsa, Clock.now, ExpiringStore<SessionClaims>.get, Crypto.equal, Crypto.decodeBase64url, Crypto.verifyRsaIt takes token as optional string from the HTTP cookie aug_session. It gets crypto (Crypto), clock (Clock), keys (SigningKeys), and sessions (ExpiringStore<SessionClaims>) from dependency injection. Omitted optional inputs are null. It can call SigningKeys.session, Crypto.publicRsa, Clock.now, ExpiringStore<SessionClaims>.get, Crypto.equal, Crypto.decodeBase64url, and Crypto.verifyRsa.
The handler responds with HTTP 401 for SessionError. It can also raise HttpError, KeyError, and TimeError.
Dependencies
It uses ExpiringStore (get) from memory. It uses Crypto (decodeBase64url, equal, publicRsa, and verifyRsa) from crypto. It uses Clock (now) from time. It uses SessionClaims (name and sub) and SessionError from contracts.
It uses authenticate from session. It uses LoginPage and Welcome from views. It uses securityHeaders, KeyError, and SigningKeys (session) from common. It uses UserInfo from provider.