File: cockpit-session.xml

package info (click to toggle)
cockpit 337-1
  • links: PTS, VCS
  • area: main
  • in suites: trixie
  • size: 36,232 kB
  • sloc: javascript: 47,090; python: 38,766; ansic: 35,470; xml: 6,048; sh: 3,413; makefile: 614
file content (131 lines) | stat: -rw-r--r-- 5,266 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
<?xml version="1.0"?>
<!DOCTYPE refentry PUBLIC "-//OASIS//DTD DocBook XML V4.3//EN"
	"http://www.oasis-open.org/docbook/xml/4.3/docbookx.dtd">
<refentry id="cockpit-login">
  <refnamediv>
    <refname>cockpit.js: User Session</refname>
    <refpurpose>User information and login session state</refpurpose>
  </refnamediv>

  <refsection id="cockpit-logout">
    <title>cockpit.logout()</title>
<programlisting>
cockpit.logout([reload])
</programlisting>
    <para>Logout of Cockpit. Unless <code>reload</code> is <code>false</code> this will also
      cause the page to be reloaded, so that the user can see the logged out state.</para>
  </refsection>

  <refsection id="cockpit-user">
    <title>cockpit.user()</title>
<programlisting>
var promise = cockpit.user();
promise.then(user => { ... });
</programlisting>
    <para>This object contains information about the user that's currently logged into cockpit.
      The following fields are defined:</para>

    <variablelist>
      <varlistentry>
        <term><code>"id"</code></term>
        <listitem><para>This is unix user id.</para></listitem>
      </varlistentry>
      <varlistentry>
        <term><code>"gid"</code></term>
        <listitem><para>This is unix user group id.</para></listitem>
      </varlistentry>
      <varlistentry>
        <term><code>"name"</code></term>
        <listitem><para>This is the unix user name like <code>"root"</code>.</para></listitem>
      </varlistentry>
      <varlistentry>
        <term><code>"full_name"</code></term>
        <listitem><para>This is a readable name for the user.</para></listitem>
      </varlistentry>
      <varlistentry>
        <term><code>"groups"</code></term>
        <listitem><para>This is an array of group names to which the user belongs.  Since
        version 318, the first item in this list is the primary group.</para></listitem>
      </varlistentry>
      <varlistentry>
        <term><code>"home"</code></term>
        <listitem><para>This is user's home directory.</para></listitem>
      </varlistentry>
      <varlistentry>
        <term><code>"shell"</code></term>
        <listitem><para>This is unix user shell.</para></listitem>
      </varlistentry>
    </variablelist>

    <para>Returns a promise that completes once the user information is available.</para>
    <warning>
      <para>
	<code>cockpit.user()</code> is soft-deprecated since Cockpit 336, if
	your page does not need to maintain compatibility with older Cockpit
	versions you can use<link linkend="cockpit-info">cockpit.info</link> to
	obtain the user information.
      </para>
    </warning>
  </refsection>

  <refsection id="cockpit-permission">
    <title>Permission lookup</title>

    <para>Cockpit provides a mechanism for checking if the current user satisfies a
      given criteria. This is meant for updating UI elements based on what actions the
      user can perform. It is <emphasis>not an access control mechanism</emphasis>.</para>

    <refsection id="cockpit-permission-constructor">
      <title>cockpit.permission()</title>
<programlisting>
permission = cockpit.permission([options])
</programlisting>

      <para>Create a new permission object to check if the current user has a particular
      permission specified by <code>options</code>:</para>
      <variablelist>
        <varlistentry>
          <term><code>admin: true</code></term>
          <listitem><para>True if the session has superuser privileges, i.e. can run channels as root
            with <code>{ superuser: "require" }</code>.</para></listitem>
        </varlistentry>
        <varlistentry>
           <term><code>group:</code>&nbsp;<emphasis>name</emphasis></term>
           <listitem><para>True if the currently logged user is a member of group <emphasis>name</emphasis>.</para></listitem>
        </varlistentry>
      </variablelist>

      <para>The permission result is always true for the "root" user. When <code>options</code> is not given,
      check if the current user is root.</para>
    </refsection>

    <refsection id="cockpit-permission-allowed">
      <title>permission.allowed</title>

      <para>A boolean value which indicates if the permission is allowed or not. This will
        be <code>null</code> if the permission is unknown, or there was an error checking
        the permission or the permission data has not yet loaded. This property will update
        asynchronously and if you wish to be notified of changes connect to the
        <link linkend="cockpit-permission-changed">permission.onchanged</link> event.</para>
    </refsection>

    <refsection id="cockpit-permission-changed">
      <title>permission.onchanged</title>
<programlisting>
permission.addEventListener("changed", function() { ... })
</programlisting>
      <para>This event is fired when the permission changes. In particular the
        <link linkend="cockpit-permission-allowed">permission.allowed</link> property.</para>
    </refsection>

    <refsection id="cockpit-permission-close">
      <title>permission.close()</title>
<programlisting>
permission.close()
</programlisting>
      <para>Closes the permission object and tears down any registered callbacks and dbus subscriptions.</para>
    </refsection>

  </refsection>

</refentry>