summaryrefslogtreecommitdiff
path: root/lib/chessh/ssh/server_key.ex
blob: 71b69976c7331c1fa79f7b7ffa0a241527278516 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
defmodule Chessh.SSH.ServerKey do
  alias Chessh.PlayerSession
  alias Chessh.Auth.KeyAuthenticator

  @behaviour :ssh_server_key_api

  @impl true
  def is_auth_key(key, username, _daemon_options) do
    PlayerSession.update_sessions_and_player_satisfies(
      username,
      fn player -> KeyAuthenticator.authenticate(player, key) end
    )
  end

  @impl true
  def host_key(algorithm, daemon_options) do
    :ssh_file.host_key(algorithm, daemon_options)
  end
end