main.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: "main.aug.md" explains this file. Read it before changes; refresh with aug spec.
import Crypto and GnuTlsCrypto from crypto
import Clock and SystemClock from time
import HttpClient and WebHttpClient from web
import ExpiringStore and MemoryStore from memory
import LoginTransaction and SessionClaims and home and me and logout and startLogin and loginCallback from client
import AuthorizationRequest and AuthorizationCode and AccessGrant and discovery and jwks and authorize and providerLogin and token and userinfo from provider
import SigningKeys and MemorySigningKeys and initializeKeys and KeyError from common
implement Crypto with GnuTlsCrypto
implement Clock with SystemClock
implement HttpClient with WebHttpClient
implement SigningKeys with MemorySigningKeys shared mutable
implement ExpiringStore<LoginTransaction> with MemoryStore<LoginTransaction> shared mutable
implement ExpiringStore<AuthorizationRequest> with MemoryStore<AuthorizationRequest> shared mutable
implement ExpiringStore<AuthorizationCode> with MemoryStore<AuthorizationCode> shared mutable
implement ExpiringStore<SessionClaims> with MemoryStore<SessionClaims> shared mutable
implement ExpiringStore<AccessGrant> with MemoryStore<AccessGrant> shared mutable
try:
initializeKeys()
catch CryptoError error:
print(value="Cryptographic initialization failed")
exit(status=1)
catch KeyError error:
print(value="Signing keys could not be initialized")
exit(status=1)
serve home and me and logout and startLogin and loginCallback and discovery and jwks and authorize and providerLogin and token and userinfo on port 8787// aug-spec: "main.aug.md" explains this file. Read it before changes; refresh with aug spec.
import Crypto and GnuTlsCrypto from crypto
import Clock and SystemClock from time
import HttpClient and WebHttpClient from web
import ExpiringStore and MemoryStore from memory
import LoginTransaction and SessionClaims and home and me and logout and startLogin and loginCallback from client
import AuthorizationRequest and AuthorizationCode and AccessGrant and discovery and jwks and authorize and providerLogin and token and userinfo from provider
import SigningKeys and MemorySigningKeys and initializeKeys and KeyError from common
implement Crypto with GnuTlsCrypto
implement Clock with SystemClock
implement HttpClient with WebHttpClient
implement SigningKeys with MemorySigningKeys shared mutable
implement ExpiringStore<LoginTransaction> with MemoryStore<LoginTransaction> shared mutable
implement ExpiringStore<AuthorizationRequest> with MemoryStore<AuthorizationRequest> shared mutable
implement ExpiringStore<AuthorizationCode> with MemoryStore<AuthorizationCode> shared mutable
implement ExpiringStore<SessionClaims> with MemoryStore<SessionClaims> shared mutable
implement ExpiringStore<AccessGrant> with MemoryStore<AccessGrant> shared mutable
try {
initializeKeys()
}
catch CryptoError error {
print(value="Cryptographic initialization failed")
exit(status=1)
}
catch KeyError error {
print(value="Signing keys could not be initialized")
exit(status=1)
}
serve home and me and logout and startLogin and loginCallback and discovery and jwks and authorize and providerLogin and token and userinfo on port 8787Compiled specification
HTTP configuration
Listen on 127.0.0.1. Limit request bodies to 16384 bytes and buffered responses to 1048576 bytes. Serve OpenAPI at /openapi.json and API docs at /docs.
Providers
Crypto is provided by GnuTlsCrypto. The same instance is shared. Clock is provided by SystemClock. The same instance is shared.
HttpClient is provided by WebHttpClient. The same instance is shared.
SigningKeys is provided by MemorySigningKeys. The same instance is shared. Shared mutation is allowed.
ExpiringStore<LoginTransaction> is provided by MemoryStore<LoginTransaction>. The same instance is shared. Shared mutation is allowed.
ExpiringStore<AuthorizationRequest> is provided by MemoryStore<AuthorizationRequest>. The same instance is shared. Shared mutation is allowed.
ExpiringStore<AuthorizationCode> is provided by MemoryStore<AuthorizationCode>. The same instance is shared. Shared mutation is allowed.
ExpiringStore<SessionClaims> is provided by MemoryStore<SessionClaims>. The same instance is shared. Shared mutation is allowed.
ExpiringStore<AccessGrant> is provided by MemoryStore<AccessGrant>. The same instance is shared. Shared mutation is allowed.
Startup
It tries to call initializeKeys using injected Crypto for crypto and SigningKeys for keys. If this work raises CryptoError, it prints "Cryptographic initialization failed"; then it calls exit with status 1. If this work raises KeyError, it prints "Signing keys could not be initialized"; then it calls exit with status 1. It serves home, me, logout, startLogin, loginCallback, discovery, jwks, authorize, providerLogin, token, and userinfo on port 8787. source
Dependencies
It uses MemoryStore from memory. It uses WebHttpClient from web. It uses GnuTlsCrypto from crypto. It uses SystemClock from time.
It uses home, me, loginCallback, startLogin, and logout from client. It uses KeyError, MemorySigningKeys, and initializeKeys from common. It uses authorize, providerLogin, discovery, jwks, token, and userinfo from provider.
Built-in operations follow the language reference.