File: auth.rst

package info (click to toggle)
python-hvac 2.3.0-5
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 2,800 kB
  • sloc: python: 29,360; makefile: 42; sh: 14
file content (146 lines) | stat: -rw-r--r-- 2,678 bytes parent folder | download | duplicates (3)
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
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
Auth
====

.. contents::
   :local:
   :depth: 1


Examples
--------

.. testcode:: sys_auth

    methods = client.sys.list_auth_methods()

    client.sys.enable_auth_method('userpass', path='customuserpass')
    client.sys.disable_auth_method('github')

List Auth Methods
-----------------

.. automethod:: hvac.api.system_backend.Auth.list_auth_methods
   :noindex:

Examples
````````

.. testcode:: sys_auth_list

    import hvac
    client = hvac.Client(url='https://127.0.0.1:8200')

    auth_methods = client.sys.list_auth_methods()
    print('The following auth methods are enabled: {auth_methods_list}'.format(
        auth_methods_list=', '.join(auth_methods['data'].keys()),
    ))

Example output:

.. testoutput:: sys_auth_list

    The following auth methods are enabled: token/


Enable Auth Method
------------------

.. automethod:: hvac.api.system_backend.Auth.enable_auth_method
   :noindex:

Examples
````````

.. testcode:: sys_auth

    import hvac
    client = hvac.Client(url='https://127.0.0.1:8200')

    client.sys.enable_auth_method(
        method_type='github',
        path='github-hvac',
    )


Disable Auth Method
-------------------

.. automethod:: hvac.api.system_backend.Auth.disable_auth_method
   :noindex:

Examples
````````

.. testcode:: sys_auth

    import hvac
    client = hvac.Client(url='https://127.0.0.1:8200')

    client.sys.disable_auth_method(
        path='github-hvac',
    )


Read Auth Method Tuning
-----------------------

.. automethod:: hvac.api.system_backend.Auth.read_auth_method_tuning
   :noindex:

Examples
````````

.. testsetup:: sys_auth_read

    client.sys.enable_auth_method(
        method_type='github',
        path='github-hvac',
    )

.. testcode:: sys_auth_read

    import hvac
    client = hvac.Client(url='https://127.0.0.1:8200')
    response = client.sys.read_auth_method_tuning(
        path='github-hvac',
    )

    print('The max lease TTL for the auth method under path "github-hvac" is: {max_ttl}'.format(
        max_ttl=response['data']['max_lease_ttl'],
    ))

Example output:

.. testoutput:: sys_auth_read

    The max lease TTL for the auth method under path "github-hvac" is: 2764800


Tune Auth Method
----------------

.. automethod:: hvac.api.system_backend.Auth.tune_auth_method
   :noindex:

Examples
````````

.. testsetup:: sys_auth_tune

    client.sys.enable_auth_method(
        method_type='github',
        path='github-hvac',
    )

.. testcode:: sys_auth_tune

    import hvac
    client = hvac.Client(url='https://127.0.0.1:8200')

    client.sys.tune_auth_method(
        path='github-hvac',
        description='The Github auth method for hvac users',
    )