Skip to content

AC Session

ElbyFross edited this page Jan 10, 2020 · 2 revisions

Remarks

Session is one of the most important entities of the Authority Controller addon. An instance of that class impersonates a current authority session and manages all generated tokens and its rights.

  • The class located at the AuthorityController namespace.
  • Implements Singleton pattern. A current instance available via the AuthorityController.Session.Current property.
  • Allows a multi-layer network architecture where existed following servers that must be informed about allocated tokens and provided rights.

Examples

Assigning of a new token

The following example demonstrates the way to assign a token to some User.

C#

// Generate new token.
string sessionToken = UniformQueries.Tokens.UnusedToken;

// Registrate token for user.
Session.Current.AssignTokenToUser(
    USER_PROFILE, 
    sessionToken);

// Set rights.
Session.Current.SetTokenRights(sessionToken, user.rights);
  • Where USER_PROFILE is an isntance of the AuthorityController.Data.Personal.User class or a derived one that contains a data relative to certain user.

Look at the USER LOGON query's source for full example.

Getting token info

The follwong example shows how to get an information about a token.

C#

AuthorityController.Session.Current.TryGetTokenInfo(
                    USER_TOKEN,
                    out TokenInfo info);
  • Where the USER_TOKEN is an unique token allocated for certain user.

You can get only the rights assigned to the token by using the TryGetTokenRights method.

Closing a session for token

In that example we will finalize the token rights and close it's session.

C#

AuthorityController.Session.Current.SetExpired(
                    USER_TOKEN);
  • Where the USER_TOKEN is an unique token allocated for certain user.

After that operation token will removed from the session and lose all rights.

Defining the AuthorityFollowers

In case if some of your servers must know tokens information managed by an authority server then you should describe routs to that servers into a RoutingTable and set the table to the AuthorityController.Session.Current.AuthorityFollowers property. After that any authority action procced by the authority server will be shared to the follwing servers via the SET TOKEN RIGHTS query.

Note that the shared data will be partially erased to prevent sharing some personal secure data. Following server will know only tokens and bonded rights but haven't know information about target users.

Links

Realted pages

Queries:

Articles: