By a single-page website we understand that
To help ensure that your single-page application is secure, we mandate
Your application should provide the following endpoints
login
: provide a redirect to the authorization_endpoint
fetched from the appropriate well-known endpoint from the table above.access_type=offline
to get a refresh token, and use this refresh token to obtain new access tokens when required.callback
: complete the authorization process
exchange the code for OAuth2 tokens (requires client authorization credentials to be provided)
create a session
switch
: login to a different team (which is a normal token exchange, but the parameter switch=bp
is passed to code generation)logout
: log out of your application. It's up to you to decide if that also means logging out of Topcon apps entirely; our sample code shows how to do this if you want to do so.token
: you will need an endpoint that takes a session value and returns a valid access token.This endpoint will be called from your page via Ajax. For ease of use, It should return a value of the form
{ "access_token": "ey.....", expiry: 12345677 }
We have written some code to demonstrate using go libraries to achieve integration with CIAM Phase 1.5.
This code integrates OAuth2 back-end processing with the Topcon brand-bar in the front end.
The code is available in full in singlepage.zip
Specifically we use
golang.org/x/oauth2
tps-git.topcon.com/event-sourcing
, particularly event-store-go
The OAuth2-specific code is shown in the fileoauthorize.go oauthorize.go
. This provides code to handle the following routes:
/auth.callback
: OAuth callback which exchanges an Authorization code for an access token;/auth.switch
: Route used to change teams;/logout
: Work towards a functional log out facility. Further configuration is required, depending on the client./auth.token
: Get hold of the access tokenTo use the example you will need to know:
topcon.ciam.phase.1.5
) is built inCLIENT_ID
and CLIENT_SECRET
.REDIRECT_PORT
.store
maps (sessionId → token-object) as this is the full state we need for auth;verifierStore
is used by auth to hide the verifier value. It maps (key → verifier) and passes the key as the state
value. This means other parties cannot access the verifier itself.endSessionStore
maps (key→sessionid), where these keys are only useful for logging out.The example provides the following public members:
NewOAuthorize
creates a new object for you that does the Oauth heavy lifting;AddHandlers
will add the required OAuth handlers to an existing mux.Router
The web server serves a single, and simple, page.
/auth.token
route. This is required by the brand-bar.index.html
. It is injected into the server in fixtures.go which is generated by the go-bindata utility.The file server.go
shows how to integrate the OAuthorize
code into a web server.
mux.Router
to do the routingAddHandlers