github.com/kyleu/dbaudit@v0.0.2-0.20240321155047-ff2f2c940496/views/vauth/Authentication.html (about)

     1  <!-- Content managed by Project Forge, see [projectforge.md] for details. -->
     2  {% import (
     3    "github.com/kyleu/dbaudit/app"
     4    "github.com/kyleu/dbaudit/app/controller/cutil"
     5    "github.com/kyleu/dbaudit/app/lib/auth"
     6    "github.com/kyleu/dbaudit/views/components"
     7  ) %}
     8  
     9  {% func Authentication(as *app.State, ps *cutil.PageState) %}
    10    {%- code
    11      prvs, err := as.Auth.Providers(ps.Logger)
    12      if err != nil {
    13        panic(err)
    14      }
    15    -%}
    16    <div class="card">
    17      <div class="right"><a href="#modal-available"><button type="button">Available</button></a></div>
    18      <h3>{%= components.SVGRefIcon(`profile`, ps) %}Authentication</h3>
    19      {%- if len(prvs) == 0 -%}
    20      <em class="mt">no authentication providers configured, why not <a href="#modal-available">add one</a>?</em>
    21      {%- else -%}
    22      <table class="mt">
    23        {%- for _, prv := range prvs -%}
    24        <tr><td><a href="/auth/{%u prv.ID %}?refer={%u `/admin` %}">{%s auth.AvailableProviderNames[prv.ID] %}</a></td></tr>
    25        {%- endfor -%}
    26      </table>
    27      {%- endif -%}
    28    </div>
    29  
    30    <div id="modal-available" class="modal" style="display: none;">
    31      <a class="backdrop" href="#"></a>
    32      <div class="modal-content">
    33        <div class="modal-header">
    34          <a href="#" class="modal-close">×</a>
    35          <h2>Available Authentication Providers</h2>
    36        </div>
    37        <div class="modal-body">
    38          <table>
    39            {%- for _, x := range auth.AvailableProviderKeys -%}
    40            <tr>
    41              {%- if prvs.Contains(x) -%}
    42              <td class="nowrap"><em>{%s auth.AvailableProviderNames[x] %}</em></td>
    43              <td><em>{%s auth.ProviderUsage(x, prvs.Contains(x)) %}</em></td>
    44              {%- else -%}
    45              <td class="nowrap">{%s auth.AvailableProviderNames[x] %}</td>
    46              <td>{%s auth.ProviderUsage(x, prvs.Contains(x)) %}</td>
    47              {%- endif -%}
    48            </tr>
    49            {%- endfor -%}
    50          </table>
    51        </div>
    52      </div>
    53    </div>
    54  {% endfunc %}