Skip to main content

Issue Principal Token (Login)

Motivation

Issue (create) a new principal token in exchange for valid credentials.

Functional Design

POST /api/v2/apps/{owner}/{app}/auth/login

Headers

KeyValue
Content-Typeapplication/json

Parameters

ParameterTypeDescription
ownerstringname of a user who owns the application
appstringname of an application

Body

JSON object:

{
"login": "login",
"password": "password"
}

Result

CodeDescriptionBody
200OKReturns an access token, see below
400Bad Requesterror object
401Unauthorizederror object
409the profile workspace is not yet ready, repeat the requesterror object
429Too may requests, rate limitingerror object
500+Server errors / service unavailableerror object

Example result 200:

{
"principalToken": "abc.def.ghi",
"expiresInSeconds": 3600, // seconds
"profileWSID": 1234567890
}

Technical design

Components

  • pkg/router
    • URL path handler ~cmp.routerLoginPathHandler~covrd1✅:
      • reads Login and Password from the Body;
      • sends APIPath_Auth_Login request to QueryProcessor;
  • pkg/processors/query2
    • IApiPathHandler implementation for handling APIPath_Auth_Login
      • ~cmp.authLoginHandler~covrd2
        1. using login from the argument, generates pseudo-WSID
        2. makes federation post to registry to issue a token
    • newQueryProcessorPipeline: provide API handler for APIPath_Auth_Login
      • ~cmp.provideAuthLoginHandler~covrd3
    • openapi:
      • add /auth/login to the list of API paths; ~cmp.provideAuthLoginPath~covrd4
      • add PrincipalToken component schema; ~cmp.principalTokenSchema~covrd5
  • pkg/sys/it
    • integration test for /login
      • ~it.TestLogin~covrd6

Footnotes

  1. [~server.authnz/cmp.routerLoginPathHandler~impl] pkg/router/impl_apiv2.go:459:impl

  2. [~server.authnz/cmp.authLoginHandler~impl] pkg/processors/query2/impl_auth_login_handler.go:20:impl

  3. [~server.authnz/cmp.provideAuthLoginHandler~impl] pkg/processors/query2/impl.go:142:impl

  4. [~server.authnz/cmp.provideAuthLoginPath~impl] pkg/processors/query2/impl_openapi.go:419:impl

  5. [~server.authnz/cmp.principalTokenSchema~impl] pkg/processors/query2/impl_openapi.go:154:impl

  6. [~server.authnz/it.TestLogin~impl] pkg/sys/it/impl_qpv2_test.go:2539:impl